Skip to content

Commit

Permalink
Merge pull request tree-sitter#12 from tausbn/add-expression-annotations
Browse files Browse the repository at this point in the history
Add support for expression annotations
  • Loading branch information
aibaars authored Jun 2, 2021
2 parents 2c94445 + 31ad3d4 commit 8e7fd7e
Show file tree
Hide file tree
Showing 5 changed files with 32,334 additions and 29,890 deletions.
12 changes: 11 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ module.exports = grammar({

par_expr: $ => seq("(", $._exprOrTerm, ")"),

expr_annotation: $ => seq(
field('name', $.annotName),
"[",
field('annot_arg',$.annotName),
"]",
"(",
$._exprOrTerm,
")",
),

_exprOrTerm: $ => choice(
$.special_call,
Expand Down Expand Up @@ -292,7 +301,8 @@ module.exports = grammar({
$.aggregate,
$.range,
$.set_literal,
$.par_expr // ParExpr
$.par_expr, // ParExpr
$.expr_annotation
),

literal: $ => choice(
Expand Down
45 changes: 45 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,47 @@
}
]
},
"expr_annotation": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "annotName"
}
},
{
"type": "STRING",
"value": "["
},
{
"type": "FIELD",
"name": "annot_arg",
"content": {
"type": "SYMBOL",
"name": "annotName"
}
},
{
"type": "STRING",
"value": "]"
},
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "_exprOrTerm"
},
{
"type": "STRING",
"value": ")"
}
]
},
"_exprOrTerm": {
"type": "CHOICE",
"members": [
Expand Down Expand Up @@ -2166,6 +2207,10 @@
{
"type": "SYMBOL",
"name": "par_expr"
},
{
"type": "SYMBOL",
"name": "expr_annotation"
}
]
},
Expand Down
Loading

0 comments on commit 8e7fd7e

Please sign in to comment.