Parse ranges + concat is "++"
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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("&&", "||")),
|
||||
),
|
||||
|
||||
13
tree-sitter-kerolox/src/grammar.json
generated
13
tree-sitter-kerolox/src/grammar.json
generated
@@ -962,8 +962,17 @@
|
||||
"type": "FIELD",
|
||||
"name": "op",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": ".."
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ".."
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "++"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
8
tree-sitter-kerolox/src/node-types.json
generated
8
tree-sitter-kerolox/src/node-types.json
generated
@@ -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
|
||||
|
||||
3831
tree-sitter-kerolox/src/parser.c
generated
3831
tree-sitter-kerolox/src/parser.c
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user