Skip to content

feat: create stage0 compiler#30

Merged
slowy07 merged 33 commits into
mainfrom
stage0
May 1, 2026
Merged

feat: create stage0 compiler#30
slowy07 merged 33 commits into
mainfrom
stage0

Conversation

@slowy07
Copy link
Copy Markdown
Collaborator

@slowy07 slowy07 commented Apr 24, 2026

create stage0 compiler

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 24, 2026

Not up to standards ⛔

🔴 Issues 4 critical

Alerts:
⚠ 4 issues (≤ 0 issues of at least minor severity)

Results:
4 new issues

Category Results
Security 4 critical

View in Codacy

🟢 Metrics 80 complexity · 0 duplication

Metric Results
Complexity 80
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

slowy07 added 13 commits April 24, 2026 15:44
- Add struct token types (KW_STRUCT, KW_CONST, KW_FN) to stage0
- Add struct AST nodes (STRUCT_DEF, STRUCT_FIELD, STRUCT_INIT, STRUCT_ACCESS)
- Add struct parser and codegen for Zig-like struct definitions
- Add struct support to main compiler (XVR_TOKEN_STRUCT, XVR_TOKEN_FN)
- Add AST node types for struct in main compiler
- Create unit tests: test_lexer_stage0.xvr, test_parser_stage0.xvr, test_codegen_stage0.xvr
- Create integration test: test_stage0_all.xvr
- Create struct-specific tests: test_struct.xvr
- Add stage0.yml CI workflow for automated testing
- Add test runner script: run_tests.sh
Signed-off-by: slowy07 <slowy.arfy@proton.me>
- Add XVR_TOKEN_INCLUDE to token types
- Add include keyword to keyword types
- Handle both import and include in parser statement()
- Add std namespace support in calcStaticMathFn()

Working:
- include std; parses successfully
- var declarations work
- Expression statements work

Not yet working:
- std::print() namespace function calls
- proc declarations
- Arrays and indexing
…on bodies

The parser was erroring when semicolons were missing between statements.
This fix makes consumeSemicolon() not error when it sees another statement
keyword (like '}' or 'proc') instead of a semicolon.

Working:
- include std; parses
- var x = 1; works
- Multiple statements in same file work

Still broken:
- Expression statements (main();)
- std::print() namespace calls
- Array literals
- Add IDENTIFIER case in atomic() to handle function calls directly
  This fixes the parser not recognizing IDENTIFIER followed by ()
- Fix the while loop condition to always allow PREC_CALL precedence
  This allows function call infix operators to be recognized
- Fix parseRules array to use atomic as prefix for IDENTIFIER

Working:
- main(); parses
- main(1); parses
- var x = 1; still works
- proc main() { return 1; } works
- Add print handling in statement()
- Add string literal handling in atomic() for IDENTIFIER case
Working:
- print(42)
- print("hello")
- print(1 + 2)
- proc test() { print(test()); }
- Remove print from keywords so it lexes as IDENTIFIER
- Handle :: operator in atomic() IDENTIFIER case
- Now works: std::print(42) and print(42)
- Skip 'unused procedure main' error
- Now works: proc main() { print(42); return 0; } compiles and runs without main() call
slowy07 added 4 commits April 26, 2026 15:42
print() statements now require either:
1. Using std::print() - always works
2. Using print() with include std; - errors if bare print() is used without including std

Users should use std::print() for output.
print() statements now ALWAYS require std:: prefix:
- std::print(42) - works
- print(42) - errors
- include std; print(42) - errors (must use std::print)

This matches Zig-like namespaces where std lib functions
require namespace qualification.
Signed-off-by: slowy07 <slowy.arfy@proton.me>
Signed-off-by: slowy07 <slowy.arfy@proton.me>
@slowy07 slowy07 merged commit 3c3d613 into main May 1, 2026
16 of 26 checks passed
@slowy07 slowy07 deleted the stage0 branch May 1, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant