Closed 0xF6 closed 2 months ago
The update introduces significant additions and changes to the Vein syntax handling, particularly focusing on adding support for for
loops, enhancing variable declarations, and improving position awareness in syntax trees. It also includes IL generator updates to handle the new for
loop syntax and additional tests to verify these features, with overall improvements to syntax parsing and error handling.
Files | Summary |
---|---|
lib/ast/syntax/Statement.cs |
Modified declarationStatement , introduced ValidateSemicolon , added for_statement , and updated embedded_statement |
lib/.../ast/ForStatementSyntax.cs |
Introduced ForStatementSyntax class with properties for loop variables and statement body |
lib/.../ast/ForeachStatementSyntax.cs |
Changed constructor signature for handling variables and statements |
lib/.../ast/IfStatementSyntax.cs |
Made ElseStatement property nullable in IfStatementSyntax |
lib/.../ast/LocalVariableDeclaration.cs |
Implement IAdvancedPositionAware instead of IPositionAware for LocalVariableDeclaration |
lib/ast/vein.ast.csproj |
Enabled implicit usings and nullable reference types |
runtime/.../generators/cycles.cs |
Added EmitForStatement method to ILGenerator for compiling for loops |
runtime/.../generators/logic.cs |
Added handling of ForStatementSyntax in the EmitStatement method of ILGenerator |
runtime/.../generators/operators.cs |
Added post-increment assignment (ExpressionType.PostIncrementAssign ) logic in EmitUnary |
test/vc_test/Features/ForFeatureTest.cs |
Introduced tests for parsing for statements in ForFeatureTest class |
test/vc_test/Features/GenericDocumentFeature.cs |
Added multiple syntax tests in GenericDocumentFeature class for various struct definitions and methods |
sequenceDiagram
participant User
participant Parser
participant ILGenerator
participant SyntaxTree
User->>Parser: Parse code with `for` loop
Parser->>SyntaxTree: Create ForStatementSyntax
SyntaxTree-->>Parser: Return ForStatementSyntax Node
Parser->>ILGenerator: Emit ForStatementSyntax
ILGenerator->>ILGenerator: Generate IL for loop variable
ILGenerator->>ILGenerator: Generate IL for loop condition
ILGenerator->>ILGenerator: Generate IL for loop iteration
ILGenerator->>User: Return compiled code
Amidst the code, a loop does glide,
Afor
loop's journey, side by side,
Semicolons check, no errors to hide,
Expressions parsed, in perfect stride.
Variables declare, they now confide,
Syntax trees bloom, with loops inside. 🌸🐇
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Summary by CodeRabbit
New Features
for
loop statements.ForStatementSyntax
for representingfor
loops in the syntax tree.Enhancements
IfStatementSyntax
to support nullableElseStatement
.LocalVariableDeclaration
to implementIAdvancedPositionAware
.Bug Fixes
Tests
ForFeatureTest
to validate the parsing offor
statement syntax.GenericDocumentFeature
tests for various struct definitions and methods, including Fibonacci calculation.