Skip to content

Commit

Permalink
Fix pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter John committed May 3, 2023
1 parent 27426a3 commit 47e9b71
Show file tree
Hide file tree
Showing 6 changed files with 9,757 additions and 11,182 deletions.
24 changes: 20 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ module.exports = grammar({
"=",
field("value", $._const_expression)
),
_const_expression: ($) => choice($._const_expression_unit, $._const_binary_expression),
_const_binary_expression: ($) => arithmeticExpression($._const_expression),
_const_expression: ($) => choice($._const_expression_unit, $.const_binary_expression),
const_binary_expression: ($) => arithmeticExpression($._const_expression),
_const_expression_unit: ($) =>
choice(
$.string,
Expand Down Expand Up @@ -134,7 +134,23 @@ module.exports = grammar({
_statement_seq: ($) => repeat1($._statement),
_statement: ($) => choice($._expression, $.let),
_expression: ($) => choice($._expression_unit, $.binary_expression),
binary_expression: ($) => arithmeticExpression($._expression),
binary_expression: ($) => choice(
binaryExpr(prec.left, 1, "||", $._expression),
binaryExpr(prec.left, 2, "&&", $._expression),
binaryExpr(prec.left, 3, "==", $._expression),
binaryExpr(prec.left, 3, "!=", $._expression),
binaryExpr(prec.left, 4, "<", $._expression),
binaryExpr(prec.left, 4, "<=", $._expression),
binaryExpr(prec.left, 4, ">", $._expression),
binaryExpr(prec.left, 4, ">=", $._expression),
binaryExpr(prec.left, 5, "|>", $._expression),
binaryExpr(prec.left, 6, "+", $._expression),
binaryExpr(prec.left, 6, "-", $._expression),
binaryExpr(prec.left, 7, "*", $._expression),
binaryExpr(prec.left, 7, "/", $._expression),
binaryExpr(prec.left, 7, "%", $._expression),
binaryExpr(prec.left, 7, "<>", $._expression)
),
_expression_unit: ($) =>
choice(
$.string,
Expand Down Expand Up @@ -223,7 +239,7 @@ module.exports = grammar({

when_entry: $ => seq(
choice(
seq($._expression, repeat(seq(",", $._expression))),
$._expression,
"_"
),
"->",
Expand Down
29 changes: 4 additions & 25 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,11 @@
},
{
"type": "SYMBOL",
"name": "_const_binary_expression"
"name": "const_binary_expression"
}
]
},
"_const_binary_expression": {
"const_binary_expression": {
"type": "CHOICE",
"members": [
{
Expand Down Expand Up @@ -2419,29 +2419,8 @@
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_expression"
}
]
}
}
]
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "STRING",
Expand Down
Loading

0 comments on commit 47e9b71

Please sign in to comment.