mirror of
https://github.com/hi-language/transpiler.git
synced 2026-01-14 00:28:05 +00:00
Fix: Resolve ambiguity in statement rule with GATE
This commit is contained in:
@@ -14,7 +14,12 @@ class HiParser extends CstParser {
|
||||
$.RULE('statement', () => {
|
||||
$.OR([
|
||||
{ ALT: () => $.SUBRULE($.declaration) },
|
||||
{ ALT: () => $.SUBRULE($.assignment) },
|
||||
// Gated lookahead to resolve ambiguity. An assignment must be
|
||||
// an `assignable` expression followed by an `Eq` token.
|
||||
{
|
||||
GATE: () => this.BACKTRACK($.assignable) && this.LA(1).tokenType === T.Eq,
|
||||
ALT: () => $.SUBRULE($.assignment)
|
||||
},
|
||||
{ ALT: () => $.SUBRULE($.returnStatement) },
|
||||
{ ALT: () => $.SUBRULE($.expressionStatement) },
|
||||
]);
|
||||
@@ -223,4 +228,3 @@ class HiParser extends CstParser {
|
||||
}
|
||||
|
||||
export const parser = new HiParser();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user