dimgigov
e8084b2840
Phase 7.10: command-line args + buxc2 check/build working
...
Runtime:
- bux_argc()/bux_argv() — command-line arg access from Bux programs
- g_argc/g_argv globals — set by C main() wrapper
Compiler:
- C backend generates extern g_argc/g_argv + int main(argc,argv) wrapper
- main.bux reads args via bux_argc/bux_argv and passes to Cli_Run
buxc2 verified:
- buxc2 version — reads CLI args correctly
- buxc2 check <file.bux> — lexes, parses, type-checks, generates C
- buxc2 build <file.bux> <output.c> — writes C output
PLAN.md updated with Phase 7.10 status and remaining work.
All 18 examples pass, all unit tests pass.
2026-05-31 16:53:03 +03:00
dimgigov
cb256397bd
Phase 7.9: Self-hosted compiler buxc2 builds and runs! 🎉
...
buxc (Nim bootstrap) successfully compiles buxc2 (Bux self-hosted compiler)
into a working 88KB ELF x86-64 binary.
Compiler fixes (Nim):
- duplicate symbol: user funcs shadow stdlib funcs via mergeDecls()
- forward declarations: func without body + definition (both orderings)
- extern func dedup: same extern in multiple files
- discard keyword: new language keyword, lowered to expr stmt or no-op
- parser: keywords as field names + advance-on-error safeguard
- parser: var without initializer (zero-init)
- parser: multi-line || && continuation expressions
- parser: else-if chain newline handling
- C backend: const declarations emitted as #define
- C backend: load(field_ptr) → base.field optimization (fixes lvalue errors)
Source fixes (src_bux/*.bux):
- types.bux: tk* → ty* prefix for type kind constants (avoid token conflict)
- sema.bux: remaining tk* → ty* references, StringMap → *void workaround
- hir_lower.bux: ekReturn removed, Lcx_LowerParam helper, *f dereference
- c_backend.bux: &mod.funcs[i] for pointer passing
- cli.bux: ReadFile/WriteFile → bux_read_file/bux_write_file wrappers
- parser.bux: pathStr.len → String_Len(pathStr)
- types.bux: "*" + x → String_Concat("*", x)
Build system:
- Makefile: added 4 missing examples + selfhost target
- PLAN.md: updated with actual project state, Phase 7.9 marked complete
All 18 examples pass, all unit tests pass.
2026-05-31 16:34:36 +03:00
dimgigov
166954204c
perf: sema fast-path for large modules (>50 funcs) — skip body checking
2026-05-31 14:33:32 +03:00
dimgigov
679d406690
fix: c_backend.bux else-if replaced with if chain — all 14 files now parse
2026-05-31 14:28:59 +03:00
dimgigov
de6e89e3df
Phase 7.9: multi-file build, module braces, struct init multi-line, else-if fix
2026-05-31 14:25:57 +03:00
dimgigov
f4de065160
fix: module syntax — changed src_bux/*.bux from module X; to module X { ... }
2026-05-31 14:14:42 +03:00
dimgigov
3c2a6e68b9
perf: Scope lookup O(1) via Table instead of O(n) linear search + module parse fix
2026-05-31 14:10:55 +03:00