Skip to content

Commit

Permalink
Fix predence of attribute expressions
Browse files Browse the repository at this point in the history
Fixes #61
  • Loading branch information
maxbrunsfeld committed Mar 5, 2020
1 parent 2eb10f4 commit aeebb11
Show file tree
Hide file tree
Showing 4 changed files with 1,946 additions and 1,896 deletions.
6 changes: 3 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ module.exports = grammar({
field('operator', operator),
field('right', $._primary_expression)
))));
},
},

unary_operator: $ => prec(PREC.unary, seq(
field('operator', choice('+', '-', '~')),
Expand Down Expand Up @@ -624,11 +624,11 @@ module.exports = grammar({
)
),

attribute: $ => seq(
attribute: $ => prec(PREC.call, seq(
field('object', $._primary_expression),
'.',
field('attribute', $.identifier)
),
)),

subscript: $ => seq(
field('value', $._primary_expression),
Expand Down
48 changes: 26 additions & 22 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3179,29 +3179,33 @@
]
},
"attribute": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "object",
"content": {
"type": "SYMBOL",
"name": "_primary_expression"
}
},
{
"type": "STRING",
"value": "."
},
{
"type": "FIELD",
"name": "attribute",
"content": {
"type": "SYMBOL",
"name": "identifier"
"type": "PREC",
"value": 20,
"content": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "object",
"content": {
"type": "SYMBOL",
"name": "_primary_expression"
}
},
{
"type": "STRING",
"value": "."
},
{
"type": "FIELD",
"name": "attribute",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
}
}
]
]
}
},
"subscript": {
"type": "SEQ",
Expand Down

0 comments on commit aeebb11

Please sign in to comment.