Commit Graph

158 Commits

Author SHA1 Message Date
dimgigov 52608d5601 feat: add enum path expression support in codegen
- Support ekPath in lowerExpr for enum variants (Color::Red → Color_Red)
- Support module paths (Std::Io::PrintLine → Std_Io_PrintLine)
- Add enums.bux example demonstrating enum usage
- Enums now compile and run correctly
2026-05-30 23:11:03 +03:00
dimgigov 3b03d43dd1 docs: add example programs
- hello.bux: Hello World with PrintLine
- fibonacci.bux: Recursive Fibonacci with while loop
- factorial.bux: Recursive Factorial computation
- structs.bux: Struct creation and field access

All examples compile and run successfully via 'bux run'
2026-05-30 23:04:33 +03:00
dimgigov bbb7e60042 fix: add tkAssign and compound assignment operators to C codegen
- Map tkAssign to '=' in operatorToC
- Add tkAmpAssign, tkPipeAssign, tkCaretAssign, tkShlAssign, tkShrAssign
- Fibonacci program now works correctly with while loops and assignment
2026-05-30 23:02:33 +03:00
dimgigov 782aaa729d feat: add stdlib IO and extern function support
- Add stdlib/io.c with PrintLine, Print, PrintInt, PrintFloat, PrintBool, ReadLine
- Support extern function declarations (functions without body)
- Generate C forward declarations for extern functions
- Map Bux type names (String, int, etc.) to C types in codegen
- Update build system to copy all stdlib files
- Hello World example works: prints 'Hello, Bux!'
2026-05-30 22:56:03 +03:00
dimgigov 8e74215378 feat: add HIR, C backend, and end-to-end compilation
- Phase 3: High-Level IR (HIR) with lowering from AST
  - Method call desugaring (obj.method() → Type_method(obj))
  - if/else, while, loop, break, continue lowering
  - struct, enum, function lowering
  - 8 HIR tests passing

- Phase 5A: C backend code generation
  - Type mapping (Bux types → C11 types)
  - Expression and statement emission
  - Struct, enum, function generation
  - C main() wrapper for Bux Main()

- Runtime shim (stdlib/runtime.c)
  - bux_alloc, bux_free, bux_print, bux_panic
  - BuxString, BuxSlice types
  - Bounds checking, division by zero

- Build integration
  - bux build: lex → parse → sema → HIR → C → cc
  - bux run: build + execute
  - bux clean: remove build directory

- Parser fixes
  - Newline handling in struct, enum, extend, interface blocks
  - self keyword as expression and parameter name

- Sema improvements
  - Method resolution (extend blocks)
  - Interface conformance checking
  - collectGlobals made public

- All 70 tests passing (25 lexer + 16 parser + 21 sema + 8 HIR)
- End-to-end: Bux programs compile to native ELF64 binaries
2026-05-30 22:40:34 +03:00
dimgigov 8e637c89e7 feat: semantic analysis + type checker (Phase 2) 2026-05-30 21:36:42 +03:00
dimgigov 713ab8e4d6 feat: parser + AST (Phase 1) 2026-05-30 21:19:43 +03:00
dimgigov 1b708ec755 feat: bootstrap skeleton + lexer (Phase 0) 2026-05-30 21:01:26 +03:00