Restructure language grammar

This commit is contained in:
Jeff 2023-10-05 22:26:44 -04:00
parent d0806c2694
commit 6ed376335b
8 changed files with 6098 additions and 6153 deletions

View File

@ -92,7 +92,6 @@ else if 4 == 9
(expression (expression
(value (value
(integer))) (integer)))
(logic_operator)
(expression (expression
(value (value
(integer))))) (integer)))))
@ -105,7 +104,6 @@ else if 4 == 9
(expression (expression
(value (value
(integer))) (integer)))
(logic_operator)
(expression (expression
(value (value
(integer))))) (integer)))))

View File

@ -14,7 +14,6 @@ Simple Equality
(expression (expression
(value (value
(integer))) (integer)))
(logic_operator)
(expression (expression
(value (value
(integer)))))))) (integer))))))))
@ -39,15 +38,12 @@ Complex Equality
(expression (expression
(value (value
(integer))) (integer)))
(math_operator)
(expression (expression
(value (value
(integer))))) (integer)))))
(math_operator)
(expression (expression
(value (value
(integer))))) (integer)))))
(logic_operator)
(expression (expression
(value (value
(integer)))))))) (integer))))))))

View File

@ -66,7 +66,6 @@ select number from foobar where text == 'answer'
(logic (logic
(expression (expression
(identifier)) (identifier))
(logic_operator)
(expression (expression
(value (value
(string))))))))) (string)))))))))

View File

@ -33,7 +33,6 @@ Complex Yield
(expression (expression
(value (value
(integer))) (integer)))
(math_operator)
(expression (expression
(value (value
(integer))))) (integer)))))

View File

@ -95,11 +95,11 @@ module.exports = grammar({
math: $ => prec.left(seq( math: $ => prec.left(seq(
$.expression, $.expression,
$.math_operator, $._math_operator,
$.expression, $.expression,
)), )),
math_operator: $ => choice( _math_operator: $ => choice(
'+', '+',
'-', '-',
'*', '*',
@ -109,11 +109,11 @@ module.exports = grammar({
logic: $ => prec.left(seq( logic: $ => prec.left(seq(
$.expression, $.expression,
$.logic_operator, $._logic_operator,
$.expression, $.expression,
)), )),
logic_operator: $ => choice( _logic_operator: $ => choice(
'==', '==',
'!=', '!=',
'&&', '&&',

View File

@ -424,7 +424,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "math_operator" "name": "_math_operator"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -433,7 +433,7 @@
] ]
} }
}, },
"math_operator": { "_math_operator": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -470,7 +470,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "logic_operator" "name": "_logic_operator"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -479,7 +479,7 @@
] ]
} }
}, },
"logic_operator": { "_logic_operator": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {

View File

@ -203,19 +203,10 @@
{ {
"type": "expression", "type": "expression",
"named": true "named": true
},
{
"type": "logic_operator",
"named": true
} }
] ]
} }
}, },
{
"type": "logic_operator",
"named": true,
"fields": {}
},
{ {
"type": "loop", "type": "loop",
"named": true, "named": true,
@ -284,19 +275,10 @@
{ {
"type": "expression", "type": "expression",
"named": true "named": true
},
{
"type": "math_operator",
"named": true
} }
] ]
} }
}, },
{
"type": "math_operator",
"named": true,
"fields": {}
},
{ {
"type": "root", "type": "root",
"named": true, "named": true,

12209
src/parser.c

File diff suppressed because it is too large Load Diff