Skip to content

More robust handling of AST validation#267

Merged
AlexNisnevich merged 2 commits intomainfrom
an-better-ast-validation
Feb 4, 2025
Merged

More robust handling of AST validation#267
AlexNisnevich merged 2 commits intomainfrom
an-better-ast-validation

Conversation

@AlexNisnevich
Copy link
Member

(Fixes #257)

  • Introduces ErrorAnalyzer.bestValidParse(), which wraps SemanticParseResult.bestParse and additionally prefers parses that pass the AstValidator, if any (this resolves issues where the "best" parse fails the AstValidator but there is actually a passing parse further down)
  • Use ErrorAnalyzer.bestValidParse everywhere we run the parser (server, console, tests)
  • Treat ConditionalAction the same as TriggeredAbility for certain AST validation rules (fixes an edge-case bug caught by test suite where "When this robot is destroyed, destroy a robot" has two valid parses, one as TriggeredAbility and one as ConditionalAction)
  • Parse "if this robot is not adjacent to an object" correctly (returning a parse that doesn't violate AST validation)

@AlexNisnevich AlexNisnevich merged commit 687590c into main Feb 4, 2025
1 check passed
@AlexNisnevich AlexNisnevich deleted the an-better-ast-validation branch February 4, 2025 03:55
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.

"if this robot is not adjacent to an object" doesn't work.

1 participant