Skip to content

feat: supports a.b.c variables and refactor lexer/parser#693

Merged
killme2008 merged 2 commits intomasterfrom
feature/refactor-parser-lexer
Mar 4, 2026
Merged

feat: supports a.b.c variables and refactor lexer/parser#693
killme2008 merged 2 commits intomasterfrom
feature/refactor-parser-lexer

Conversation

@killme2008
Copy link
Owner

@killme2008 killme2008 commented Dec 24, 2025

Close #565
Close #529

  • New: Regular variables now support nested property/index access without #, e.g. foo.bars[0].name.
  • Lookup behavior clarified: For dotted paths like a.b.c, Aviator first checks whether "a.b.c" exists as a full key in the environment; if not, it falls back to chained property traversal (a -> b -> c).
  • Stricter syntax validation: Malformed property chains with empty segments (for example a..b) are now rejected with a syntax error.
  • Literal safety: Literal keywords (true, false, nil) are consistently treated as literals and cannot be used as indexable values in expressions like true[0].

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances AviatorScript's variable syntax by enabling direct property access notation (e.g., a.b.c) without requiring the # quote prefix, and performs a comprehensive refactoring of the lexer and parser for improved clarity and maintainability.

Key Changes:

  • Added support for dotted property access notation (a.b.c) and array index syntax (foo.bars[0].name) without the # prefix
  • Refactored parser methods with descriptive names (e.g., ternary()parseTernary(), expr()parseAdditive())
  • Restructured lexer scanning logic into separate methods (scanNumber(), scanVariable(), scanString(), etc.) for better modularity

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
QuoteVarTest.java Added tests for property access without quote prefix, including priority behavior when both full key and property chain exist
ExpressionLexerUnitTest.java Added lexer unit tests for scanning dotted variables with array indices
ExpressionParser.java Renamed parser methods to be more descriptive, added comprehensive operator precedence documentation, added memory limit for token history, fixed typos
Variable.java Added utility methods isKeyword() and isLiteralKeyword() to identify reserved variable tokens
OperatorType.java Enhanced documentation with operator categorization and clarifying comments about token semantics
DelegateToken.java Fixed typo: Ternay_EndTernary_End
ExpressionLexer.java Refactored monolithic scan method into separate scanner methods per token type, improved documentation, optimized character lookup using String.indexOf()
OptimizeCodeGenerator.java Fixed typo: Ternay_EndTernary_End

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
@killme2008 killme2008 merged commit 2cdc53d into master Mar 4, 2026
1 check passed
@killme2008 killme2008 deleted the feature/refactor-parser-lexer branch March 4, 2026 10:09
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.

无法通过.访问list元素的属性 【请教】a.b.c语法糖性能问题

2 participants