Skip to content

Commit 175c2a2

Browse files
committed
fix(grammar): make else if have higher priority than else
1 parent 3bd2c5d commit 175c2a2

File tree

4 files changed

+1046588
-1046568
lines changed

4 files changed

+1046588
-1046568
lines changed

grammar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,12 +2827,12 @@ const rules = {
28272827

28282828

28292829
// ** A.6.6 Conditional statements
2830-
conditional_statement: $ => prec.right(seq(
2830+
conditional_statement: $ => seq(
28312831
optional($.unique_priority),
28322832
'if', '(', $.cond_predicate, ')', $.statement_or_null, optional($.conditional_compilation_directive), // $.conditional_compilation_directive out of LRM
28332833
repseq('else', 'if', '(', $.cond_predicate, ')', $.statement_or_null, optional($.conditional_compilation_directive)), // $.conditional_compilation_directive out of LRM
2834-
optseq('else', $.statement_or_null)
2835-
)),
2834+
prec.dynamic(-1, optseq('else', $.statement_or_null))
2835+
),
28362836

28372837
unique_priority: $ => choice('unique', 'unique0', 'priority'),
28382838

0 commit comments

Comments
 (0)