Parse ranges + concat is "++"

This commit is contained in:
2026-04-30 19:32:23 -06:00
parent b29c25d9dc
commit 8d08273330
5 changed files with 1968 additions and 1891 deletions

View File

@@ -205,6 +205,7 @@ pub enum BinaryOpKind {
Mul,
Div,
Concat,
Range,
And,
Or,
Eq,
@@ -220,6 +221,7 @@ impl EnumRepr for BinaryOpKind {
Mul => "*",
Div => "/",
Concat => "++",
Range => "..",
And => "&&",
Or => "||",
Eq => "=",
@@ -229,6 +231,7 @@ impl EnumRepr for BinaryOpKind {
}
}
// TODO: is this type necessary?
pub enum BinaryOpCategory {
Arithmetic,
String,
@@ -241,7 +244,7 @@ impl From<BinaryOpKind> for BinaryOpCategory {
use BinaryOpCategory::*;
use BinaryOpKind::*;
match op {
Add | Mul | Div => Arithmetic,
Add | Mul | Div | Range => Arithmetic,
Concat => String,
And | Or => Logical,
Eq | Lt | Le => Comparison,

View File

@@ -155,7 +155,7 @@ export default grammar({
binary_expr: $ => choice(
expr_prec($.expr, 4, choice("*", "/")),
expr_prec($.expr, 3, choice("+", "-")),
expr_prec($.expr, 2, ".."),
expr_prec($.expr, 2, choice("..", "++")),
expr_prec($.expr, 1, choice("=", "!=", ">=", "<=", "<", ">")),
expr_prec($.expr, 0, choice("&&", "||")),
),

View File

@@ -962,8 +962,17 @@
"type": "FIELD",
"name": "op",
"content": {
"type": "STRING",
"value": ".."
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ".."
},
{
"type": "STRING",
"value": "++"
}
]
}
},
{

View File

@@ -131,6 +131,10 @@
"type": "+",
"named": false
},
{
"type": "++",
"named": false
},
{
"type": "-",
"named": false
@@ -639,6 +643,10 @@
"type": "+",
"named": false
},
{
"type": "++",
"named": false
},
{
"type": ",",
"named": false

File diff suppressed because it is too large Load Diff