Skip to content

Commit

Permalink
feat(sol-syntax): fix syntax reading
Browse files Browse the repository at this point in the history
  • Loading branch information
aripiprazole committed May 9, 2024
1 parent a095dba commit 30cb04f
Show file tree
Hide file tree
Showing 5 changed files with 58,011 additions and 55,498 deletions.
12 changes: 10 additions & 2 deletions tree-sitter-sol/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ module.exports = grammar({
[$.if_stmt, $.if_expr],
[$._expr, $.type_app_expr, $.app_expr],
[$._pattern, $.primary],
[$._expr, $._primary_or_binary],
[$._type_expr, $._primary_or_binary],
[$._primary_or_binary, $.app_expr],
[$._primary_or_binary, $.type_app_expr, $.app_expr],
[$._primary_or_binary, $._expr, $.app_expr],
[$._primary_or_binary, $._type_expr, $.type_app_expr],
],

precedences: ($) => [
Expand Down Expand Up @@ -276,12 +282,14 @@ module.exports = grammar({
),
),

_primary_or_binary: ($) => choice($.primary, $.binary_expr),

binary_expr: ($) =>
prec.left(
seq(
field('lhs', $._expr),
field('op', $.infix_op),
field('rhs', $._expr),
field('rhs', $._primary_or_binary),
),
),

Expand Down Expand Up @@ -514,7 +522,7 @@ module.exports = grammar({
char: () => /'[^'\\]'/,
string: () => /"([^"\\\n\r]|\\[^\n\r])*"/,

infix_op: () => prec.left(repeat1($._symbol)),
infix_op: ($) => prec.left(repeat1($._symbol)),

attribute_id: () => /[a-zA-Z][a-zA-Z\d_$#]*/,

Expand Down
42 changes: 41 additions & 1 deletion tree-sitter-sol/src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,19 @@
]
}
},
"_primary_or_binary": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "primary"
},
{
"type": "SYMBOL",
"name": "binary_expr"
}
]
},
"binary_expr": {
"type": "PREC_LEFT",
"value": 0,
Expand Down Expand Up @@ -1366,7 +1379,7 @@
"name": "rhs",
"content": {
"type": "SYMBOL",
"name": "_expr"
"name": "_primary_or_binary"
}
}
]
Expand Down Expand Up @@ -2794,6 +2807,33 @@
[
"_pattern",
"primary"
],
[
"_expr",
"_primary_or_binary"
],
[
"_type_expr",
"_primary_or_binary"
],
[
"_primary_or_binary",
"app_expr"
],
[
"_primary_or_binary",
"type_app_expr",
"app_expr"
],
[
"_primary_or_binary",
"_expr",
"app_expr"
],
[
"_primary_or_binary",
"_type_expr",
"type_app_expr"
]
],
"precedences": [
Expand Down
28 changes: 0 additions & 28 deletions tree-sitter-sol/src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,41 +408,13 @@
"multiple": false,
"required": true,
"types": [
{
"type": "ann_expr",
"named": true
},
{
"type": "app_expr",
"named": true
},
{
"type": "binary_expr",
"named": true
},
{
"type": "forall_expr",
"named": true
},
{
"type": "lam_expr",
"named": true
},
{
"type": "match_expr",
"named": true
},
{
"type": "pi_expr",
"named": true
},
{
"type": "primary",
"named": true
},
{
"type": "sigma_expr",
"named": true
}
]
}
Expand Down
Loading

0 comments on commit 30cb04f

Please sign in to comment.