- Lexer (Nim + Bux): resolve escape sequences (\n, \t, \r, etc) instead of
keeping raw source text in token. This was the root cause of \n being
double-escaped to \\n in generated C code.
- Manifest parser (src_bux/manifest.bux): use bux_strlen instead of broken
String_SplitCount(s, "") hack for string length; fix quote stripping.
- CLI (src_bux/cli.bux): --version/--help now recognized alongside version/help.
- Remove ~30+ debug Print statements from cli, parser, lexer, sema, main.
- Clean up unneeded Print/PrintInt extern declarations.
- _selfhost/src/: synced from src_bux/.
- Fix segfault from uninitialized Symbol structs in scope/hir_lower/sema
- Fix null ReadFile crash in Cli_MergeFileInto (missing stdlib files)
- Extend function params from 6 to 9 (bux_str_format needs 9 args)
- Add ExprList/HirArgList linked lists for >2 call arguments
- Add banner image to README
- Update docs: C backend is now primary (not QBE)
Major changes:
- Cli_BuildProject now uses CBackend_Generate instead of QBE SSA generation
- Replaced QBE invocation (vendor/qbe/qbe) with direct cc compilation
- Cli_Build (single-file) now compiles C output with cc including runtime.c/io.c
- Added import-based stdlib merging: only imported Std::* modules are merged,
eliminating unused generic code from Array/Map/Set/Channel in simple programs
C backend fixes:
- Fixed struct typedef redefinition: struct definitions now use 'struct Name {}'
instead of 'typedef struct {} Name' to avoid conflicting with forward typedefs
- Added enum support: HirEnum struct, enum emission in C backend, variant
constants emitted as #define Name_Value
- Added char8 typedef
- Skip generic structs/functions (T/K/V type parameters) in C emission
Sema fixes:
- Fixed Sema_IsNumeric: now correctly recognizes uint, float32, float64
- Fixed return type check: allow pointer compatibility (String <-> *T)
Tested: hello, fibonacci, factorial, enums examples build and run via buxc2
- Iterate function body statements and call Sema_CheckStmt on each
- Add Sema_CheckBlock helper for child scope creation in if/while/for/loop blocks
- Extend Sema_CheckStmt to handle all statement kinds: skIf, skWhile, skDoWhile,
skLoop, skFor, skMatch, skBreak, skContinue, skDecl, skReturn
- Extend Sema_CheckExpr with ekAssign, ekField, ekIndex, ekBlock, ekSelf
- Fix ekCall to resolve return type from function declaration
- Fix ekBinary to handle assignment operators (tkAssign, +=, -=, etc.)
- Add Sema_CollectGlobals handling for dkUse (imports), dkConst, dkEnum variants
- Add tkColonColon path parsing in parser (Color::Red)
- Add decl field to Symbol struct for function/type resolution
- Add Sema_ZeroInitSymbol helper to avoid garbage from uninitialized struct fields
- Fix concurrency.bux missing Task_Join import
All examples now pass buxc2 check. make selfhost succeeds.
- QBE_IsTerminator(hBlock) checks ALL children, not just last
- Removed legacy c_backend.bux and nim_backend.bux from _selfhost/src/
- QBE self-hosting QBE phase: PASSES (SSA valid, assembled to .s)
- Remaining: linker errors from missing String_Eq/StringBuilder in runtime
- Fix lexer unterminated char error test (was treating 'a as lifetime)
- Fix parser test sample.bux path for root-dir execution
- Add bux_system() to runtime.c and run command to selfhost CLI
- Switch bux_alloc from malloc to calloc for zero-init
- Fix module flattening in Cli_Check/Cli_Compile to scan full decl list
- Make test passes fully, selfhost builds successfully
- Parser_Parse: add beforePos safeguard to skip unrecognized tokens
instead of looping forever when parserParseDecl returns null
- Lexer: increase maxTokens 4096 -> 32768; add explicit break on limit
- CLI: null-check ReadFile result before String_Eq
- Nim CLI: add -O2 to cc invocation for faster self-hosted builds
- Fixed module flattening in self-hosted compiler (Cli_Compile now unwraps module wrappers)
- buxc2 check now finds functions in module-wrapped files (token.bux: funcCount=6, Main.bux: funcCount=2)
- Added debug prints to trace lexer.bux timeout and check x segfault
- Remaining issues: lexer.bux hangs in self-hosted pipeline, check x segfaults in runtime
Self-hosted compiler (buxc2):
- Add async/await/spawn tokens, parsing, HIR, lowering, C emission
- Fix pointer type emission (*T -> T*) in C backend
- Fix sizeof(Type) parsing with parentheses
- Fix import ::{...} infinite loop guard
- Fix int64 emission by avoiding else-if chain workaround
- Add debug-free cli and hir_lower
Bootstrap compiler (Nim):
- Fix critical else-if lowering bug in hir_lower.nim:
when both elseIfs and else block exist, elseIfs were dropped
causing all else-if chains to collapse to if+else only
Runtime:
- Fix bux_async_await memory corruption (don't free in run)
- Add bux_remove_from_ready for safe cleanup
- Fix forward declaration and deduplicate bux_now_ms
Docs & examples:
- Update async.bux example with proper int64 params
- Update README, LanguageRef, Stdlib, PLAN for async features
- Mark Phase 7.10 bootstrap loop as completed
All 27 examples pass. buxc2 check/build work on all examples.
Parser (src_bux/parser.bux):
- Increased struct field limit from 8 to 64
- Added field4-field7 slots in struct field assignment
- Safeguard: fields beyond slot 7 are parsed but not stored (counted only)
Known issues:
- buxc2 segfaults on ast.bux (Decl struct has 30+ fields, sizeof mismatch
between Bux parser's Decl and C compiler's Decl)
- Full bootstrap requires Decl struct in ast.bux to match actual Decl layout
All 18 examples pass, all unit tests pass.
Lexer (src_bux/lexer.bux):
- Rewrote lexSkipWhitespace to use nested if/else instead of else-if
chain (workaround for Nim C backend else-if lowering bug)
- lexPeek: mask with & 255 for UTF-8 signed char bytes
Known: buxc2 project build hangs on ast.bux parsing (infinite loop).
buxc2 single-file build works correctly with else-if.
All 18 examples pass, all unit tests pass.
Parser (src_bux/parser.bux):
- Block stores statements as linked list (firstStmt/lastStmt/nextStmt)
- Block struct: added firstStmt, lastStmt fields
- Stmt struct: added nextStmt field
HIR Lowering (src_bux/hir_lower.bux):
- Lcx_LowerBlock: iterates statement linked list, chains HirNodes via child3
- hIf: else block stored in extraData (child3 reserved for block chaining)
C Backend (src_bux/c_backend.bux):
- hBlock: emits statements via child3 linked list with proper indentation
- hStore: combines alloca + value into single declaration (int x = value;)
- hIf: full if/else emission with proper newlines
- Function decl: proper return types and parameter types (not just "int")
- int main() wrapper: generated when Main function exists
- No duplicate return 0 when body already has return
Tested:
- buxc2 compiles hello world program → runs correctly
- buxc2 compiles multi-statement program (let, if, function calls) → runs correctly
- All 18 examples still pass, all unit tests pass
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.