Skip to content

Commit a4c339c

Browse files
committed
Fix right associativity of conditional operator (#28)
1 parent 0dc5d86 commit a4c339c

File tree

186 files changed

+88669
-88897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+88669
-88897
lines changed

grammar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3838,7 +3838,9 @@ const rules = {
38383838
seq($.variable_lvalue, repeat($.attribute_instance), $.inc_or_dec_operator)
38393839
)),
38403840

3841-
conditional_expression: $ => conditional_expr($, $.cond_predicate, $.expression),
3841+
// INFO: $.cond_predicate already includes $.expression as a choice, but right associativity
3842+
// will not be preserved if there are intermediate nodes between $.expression
3843+
conditional_expression: $ => conditional_expr($, choice($.cond_predicate, $.expression), $.expression),
38423844

38433845
constant_expression: $ => choice(
38443846
$.constant_primary,

src/grammar.json

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)