Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit d9bb21e

Browse files
committed
grammar: inline expression and solve conflicts
1 parent 11e9c6f commit d9bb21e

34 files changed

+53685
-20579
lines changed

grammar.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,17 @@ module.exports = grammar({
112112

113113
extras: ($) => [/[\x00-\x20\x80-\xA0]/, $.comment],
114114

115-
inline: ($) => [$.term],
116-
117-
conflicts: ($) => [],
115+
inline: ($) => [$.term, $.expression],
116+
117+
conflicts: ($) => [
118+
[$._structure_item, $.expr_operator_binary],
119+
[
120+
$._structure_item,
121+
$.expr_map_update,
122+
$.expr_record_access,
123+
$.expr_record_update,
124+
],
125+
],
118126

119127
rules: {
120128
source_file: ($) => repeat($._structure_item),
@@ -405,7 +413,7 @@ module.exports = grammar({
405413
expr_op: ($) => choice($.expr_operator_unary, $.expr_operator_binary),
406414

407415
expr_operator_unary: ($) =>
408-
prec(
416+
prec.right(
409417
PREC.UNARY_OP,
410418
seq(field("operator", oneOf(OP1)), field("operand", $.expression))
411419
),

src/grammar.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@
20972097
]
20982098
},
20992099
"expr_operator_unary": {
2100-
"type": "PREC",
2100+
"type": "PREC_RIGHT",
21012101
"value": 10,
21022102
"content": {
21032103
"type": "SEQ",
@@ -3918,10 +3918,22 @@
39183918
"name": "comment"
39193919
}
39203920
],
3921-
"conflicts": [],
3921+
"conflicts": [
3922+
[
3923+
"_structure_item",
3924+
"expr_operator_binary"
3925+
],
3926+
[
3927+
"_structure_item",
3928+
"expr_map_update",
3929+
"expr_record_access",
3930+
"expr_record_update"
3931+
]
3932+
],
39223933
"externals": [],
39233934
"inline": [
3924-
"term"
3935+
"term",
3936+
"expression"
39253937
],
39263938
"supertypes": []
39273939
}

0 commit comments

Comments
 (0)