Fix parser to support advanced Modelica features from Chua Circuit example #40
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.
Summary
This PR addresses parsing issues identified in GitHub issue #8, specifically with the Chua Circuit example that includes advanced Modelica language features that weren't previously supported by the parser.
Changes Made
1. Comment Prefix Support
//! base 0.1.0base_modelicarule to acceptStar(LINE_COMMENT)before package declarations2. Final Keyword Support
finalparameter modifiertype_prefixgrammar to include optionalfinalkeywordBaseModelicaTypePrefixAST node to includefinal_flagfieldfinal parameter Boolean flag = false3. Complex Parameter Modifications
argument_listrule to include proper whitespace handling between comma-separated arguments4. Annotation Parsing Improvements
comment.matcherto properly combine string comments and annotationsannotation(Evaluate = true)5. If-Expression Parsing
if_expressionto support bothelseifandelse ifsyntax with safeguardselse ifstill has some limitations)Testing
Added comprehensive test cases that verify each feature works individually:
elseifImpact
These changes significantly expand the parser's capabilities, enabling it to handle more realistic Base Modelica code from the Modelica Standard Library. The Chua Circuit example can now be parsed successfully (with minor syntax adjustments for
else if->elseif).Test Plan
else iffix)Addresses #8
🤖 Generated with Claude Code