Skip to content

Commit f6ee258

Browse files
authored
Merge pull request #50 from henry-hsieh/fix-grammar-else-if
fix(grammar): make `else if` have higher priority than `else`
2 parents 3bd2c5d + 806e267 commit f6ee258

File tree

5 files changed

+1046586
-1046567
lines changed

5 files changed

+1046586
-1046567
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)