Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR supports the
while
statement in the Pascal parser and code generator. The changes include additions to theJASM
struct and methods to handlewhile
statements, modifications to theTreeShapeListener
to invoke these methods, and adjustments to the Pascal grammar file to correctly parsewhile
statements. Test files have also been added to ensure the correct functionality.Key changes include:
Support for
while
statement in the JASM code generator:codegen/jasm.go
: AddedwhileTestLabel
andnextStatementLabel
to theJASM
struct to handlewhile
statements. IntroducedStartWhileStatement
,FinishWhileStatement
, andStartWhileBlock
methods to generate the appropriate JASM code forwhile
statements. [1] [2]Integration of
while
statement handling in the TreeShapeListener:codegen/tree_shape_listener.go
: AddedEnterWhileStatement
,ExitWhileStatement
, andEnterWhileBlock
methods to theTreeShapeListener
to invoke the corresponding methods in theJASM
struct.Changes to the Pascal grammar:
parser/Pascal.g4
: Modified thewhileStatement
rule to include awhileBlock
, and added a newwhileBlock
rule to correctly parsewhile
statements.Addition of test files:
tests/expected_jasm_files/while.jasm
: Added an expected output file for a test case involvingwhile
statements.tests/pascal_programs/while.pas
: Added a Pascal program to test the parsing and code generation ofwhile
statements.