Skip to content

Commit

Permalink
Added binary operator and removed concatenation
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal <[email protected]>
  • Loading branch information
Vishalk91-4 committed Jul 13, 2024
1 parent 02e0b7c commit 36ef52b
Show file tree
Hide file tree
Showing 5 changed files with 73,980 additions and 77,902 deletions.
13 changes: 6 additions & 7 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,31 +712,30 @@ module.exports = grammar({
];

// @ts-ignore
return choice(...table.map(([fn, operator, precedence]) => fn(precedence, seq(
return prec(13, choice(...table.map(([fn, operator, precedence]) => fn(precedence, seq(
field('left', $.primary_expression),
// @ts-ignore
field('operator', operator),
field('right', $.primary_expression),
))));
)))));
},

unary_operator: $ => prec(PREC.unary, seq(
field('operator', choice('+', '-', '~')),
field('argument', $.primary_expression),
)),

sequence_operation: $ => prec(23, seq(choice(
sequence_operation: $ => seq(choice(
$.in_operation,
$.not_in_operation,
$.concatenation,
$.binary_operator,
$.subscript,
$.call,
))),
)),

in_operation: $ => prec.left(3, seq(choice($.list_comprehension, $.dictionary_comprehension, $.list, $.dictionary), 'in', choice($.list_comprehension, $.dictionary_comprehension, $.list, $.dictionary))),
not_in_operation: $ => prec.left(11, seq(choice($.list_comprehension, $.dictionary_comprehension, $.list, $.dictionary), 'not', 'in', $.expression)),
concatenation: $ => prec.left(12, seq(choice($.list_comprehension, $.dictionary_comprehension, $.list, $.dictionary), '+', $.expression)),


comparison_operator: $ => prec.left(2, seq(
choice($.primary_expression,$.identifier,$.dotted_name, $.selector_expression),
repeat1(seq(
Expand Down
Loading

0 comments on commit 36ef52b

Please sign in to comment.