Adding commands to the compiler. - #14
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds a command system to the Cx compiler (
cx <command>) and makes several other changes. Summary:New CLI commands
cx build— scaffolds a new Cx project (generatessrc/main.cxandcx.json), implemented in the newsrc/builder.d.cx compile— compiles an existing Cx project by reading itscx.json.cx run— compiles and then runs the project.main.d: the compilation logic was extracted into a reusablecompile()function that takes aCXArgsstruct (previously everything lived inline inmain), allowingcompile/run/direct.cxfile usage to share the same code path.--gccflag to force GCC as the C compiler, and the auto-detection order for the C compiler now preferstcc→gcc→cc.Language/compiler (codegen & parser)
_idsarray in the emitted C code (Foo_ids[]) mapping each variant to its name as a string, and support was added forenum.idsyntax to get the enum variant's name at runtime (used to replace manual functions likeopCodeToStr).=> expr) now require a trailing;(fixed across several examples and the standard library where the semicolon was missing).foreachloop.returnwas changed tocontinuein the "Print" opcode case.New examples
examples/kernel/: a small bare-metal x86 kernel written in Cx (assembly bootloader, entry trampoline, linker script, Makefile, and akernel.cxthat draws a text-mode VGA interface).examples/windows/langtoy.cx: a toy language interpreter (lexer + parser + expression evaluator supportinglet,print, assignments) written in Cx.examples/windows/main.cx: a simple example with addition and pointers.examples/enum2.cxandexamples/dot_anon4.cx: new examples testing enums and nested anonymous initializers.Other
.gitignorenow ignores*.o,*.bin,*.img(build artifacts from the kernel example).0.2.1to0.2.2.tests/unit.d) now wrapsto!intin try/catch instead of letting the exception propagate.