Begin fixing tests for new grammar

This commit is contained in:
Jeff 2023-10-01 00:01:02 -04:00
parent 57d908af9c
commit 17ba01c0dc
8 changed files with 8192 additions and 6774 deletions

View File

@ -10,9 +10,8 @@ not_a_comment
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (identifier))))
(identifier)))))
(item (item
(comment))) (comment)))
@ -27,8 +26,7 @@ not_a_comment # comment
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (identifier))))
(identifier)))))
(item (item
(comment))) (comment)))

View File

@ -9,16 +9,15 @@ Simple Equality
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (logic
(operation (expression
(expression (value
(value (integer)))
(integer))) (logic_operator)
(operator) (expression
(expression (value
(value (integer))))))))
(integer)))))))))
================== ==================
Complex Equality Complex Equality
@ -31,19 +30,18 @@ Complex Equality
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (logic
(operation (expression
(expression (math
(operation (expression
(expression (value
(value (integer)))
(integer))) (math_operator)
(operator) (expression
(expression (value
(value (integer)))))
(integer))))) (logic_operator)
(operator) (expression
(expression (value
(value (integer))))))))
(integer)))))))))

View File

@ -7,24 +7,22 @@ Simple Statements
x x
--- ---
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (value
(value (integer)))))
(integer))))))
(item (item
(statement (statement
(open_statement (expression
(expression (value
(value (string)))))
(string))))))
(item (item
(statement (statement
(open_statement (expression
(expression (identifier)))))
(identifier))))))
================== ==================
Simple Assignment Simple Assignment
@ -37,27 +35,21 @@ y = "one"
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (assignment
(operation (identifier)
(expression (expression
(identifier)) (value
(operator) (integer)))))))
(expression
(value
(integer))))))))
(item (item
(statement (statement
(open_statement (expression
(expression (assignment
(operation (identifier)
(expression (expression
(identifier)) (value
(operator) (string))))))))
(expression
(value
(string)))))))))
================== ==================
Complex Assignment Complex Assignment
@ -70,18 +62,15 @@ x = 1 + 1
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (assignment
(operation (identifier)
(expression (expression
(identifier)) (math
(operator) (expression
(expression (value
(operation (integer)))
(expression (math_operator)
(value (expression
(integer))) (value
(operator) (integer))))))))))
(expression
(value
(integer)))))))))))

View File

@ -11,17 +11,16 @@ table <text, number> {
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (value
(value (table
(table (identifier)
(identifier) (identifier)
(identifier) (list
(list (value
(value (string))
(string)) (value
(value (integer)))))))))
(integer))))))))))
================== ==================
Table Assignment Table Assignment
@ -36,22 +35,19 @@ foobar = table <text, number> {
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (assignment
(operation (identifier)
(expression (expression
(identifier)) (value
(operator) (table
(expression (identifier)
(value (identifier)
(table (list
(identifier) (value
(identifier) (string))
(list (value
(value (integer)))))))))))
(string))
(value
(integer))))))))))))
================== ==================
Table Access Table Access
@ -64,19 +60,18 @@ select number from foobar where text == 'answer'
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (select
(select (identifier)
(identifier) (identifier)
(identifier) (expression
(expression (logic
(operation (expression
(expression (identifier))
(identifier)) (logic_operator)
(operator) (expression
(expression (value
(value (string))))))))))
(string)))))))))))
================== ==================
@ -90,12 +85,11 @@ insert ['bob was here', 0] into foobar
(root (root
(item (item
(statement (statement
(open_statement (expression
(expression (insert
(insert (list
(list (value
(value (string))
(string)) (value
(value (integer)))
(integer))) (identifier))))))
(identifier)))))))

View File

@ -44,16 +44,15 @@ module.exports = grammar({
$.float, $.float,
$.string, $.string,
$.list, $.list,
$.empty,
$.boolean, $.boolean,
$.function, $.function,
$.table, $.table,
$.map, $.map,
)), )),
float: $ => /\d+\.\d*/, float: $ => /[-]*[0-9]*[.]{1}[0-9]+/,
integer: $ => /\d+/, integer: $ => /[-]*[0-9]+[.]{0}/,
string: $ => /(".*?")|('.*?')|(`.*?`)/, string: $ => /(".*?")|('.*?')|(`.*?`)/,

View File

@ -173,10 +173,6 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "list" "name": "list"
}, },
{
"type": "SYMBOL",
"name": "empty"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "boolean" "name": "boolean"
@ -198,11 +194,11 @@
}, },
"float": { "float": {
"type": "PATTERN", "type": "PATTERN",
"value": "\\d+\\.\\d*" "value": "[-]*[0-9]*[.]{1}[0-9]+"
}, },
"integer": { "integer": {
"type": "PATTERN", "type": "PATTERN",
"value": "\\d+" "value": "[-]*[0-9]+[.]{0}"
}, },
"string": { "string": {
"type": "PATTERN", "type": "PATTERN",

View File

@ -340,10 +340,6 @@
"type": "boolean", "type": "boolean",
"named": true "named": true
}, },
{
"type": "empty",
"named": true
},
{ {
"type": "float", "type": "float",
"named": true "named": true
@ -474,10 +470,6 @@
"type": "else", "type": "else",
"named": false "named": false
}, },
{
"type": "empty",
"named": true
},
{ {
"type": "false", "type": "false",
"named": false "named": false

14712
src/parser.c

File diff suppressed because it is too large Load Diff