Skip to content

Commit f98e4d1

Browse files
committed
fix: Improve binary expression and pipe arguments parsing
1 parent 3e205be commit f98e4d1

15 files changed

+14738
-14957
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tree-sitter-angular-codemod"
33
description = "Angular grammar for tree-sitter"
4-
version = "0.6.1"
4+
version = "0.6.2"
55
keywords = ["incremental", "parsing", "angular"]
66
categories = ["parsing", "text-editors"]
77
repository = "https://github.com/tree-sitter/tree-sitter-angular"

grammar.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,11 @@ module.exports = grammar(HTML, {
400400
// Binary expression
401401
binary_expression: ($) =>
402402
prec.left(
403-
PREC.CALL,
403+
PREC.CALL + 1, // Increase precedence slightly above CALL to ensure nesting
404404
seq(
405-
field('left', $.expression),
405+
field('left', choice($.expression, $.binary_expression)),
406406
field('operator', $._binary_op),
407-
field('right', choice($.binary_expression, $.expression)),
407+
field('right', $._primitive),
408408
),
409409
),
410410

@@ -461,9 +461,15 @@ module.exports = grammar(HTML, {
461461
seq(field('name', $.identifier), optional(field('arguments', $.pipe_arguments))),
462462
),
463463

464-
pipe_arguments: ($) => prec.left(PREC.PIPE, repeat1($._pipe_argument)),
465-
_pipe_argument: ($) =>
466-
prec.left(PREC.PIPE, seq(':', choice($._any_expression, $.group))),
464+
pipe_arguments: ($) =>
465+
prec.left(
466+
PREC.PIPE,
467+
seq(
468+
':',
469+
field('argument', $._any_expression), // Use _any_expression to allow full expression parsing
470+
repeat(seq(':', field('argument', $._any_expression))), // Allow multiple arguments
471+
),
472+
),
467473

468474
// ---------- Primitives ----------
469475
_primitive: ($) =>

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codemod.com/tree-sitter-angular",
3-
"version": "0.6.1",
3+
"version": "0.6.2",
44
"description": "Tree-sitter grammar for the Angular framework",
55
"main": "bindings/node",
66
"types": "bindings/node",

src/grammar.json

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

src/node-types.json

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

0 commit comments

Comments
 (0)