1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
02cded4af4 Continue syntax revision 2023-10-31 06:21:21 -04:00
47f50931d9 Continue syntax revision 2023-10-31 05:51:37 -04:00
21 changed files with 14658 additions and 8761 deletions

View File

@ -7,16 +7,14 @@ async { (output 'Whaddup') }
--- ---
(root (root
(item
(statement (statement
(async (async
(item
(statement (statement
(expression (expression
(tool (tool
(expression (expression
(value (value
(string))))))))))) (string)))))))))
================== ==================
Complex Async Statements Complex Async Statements
@ -35,10 +33,8 @@ async {
--- ---
(root (root
(item
(statement (statement
(async (async
(item
(statement (statement
(if_else (if_else
(if (if
@ -57,18 +53,15 @@ async {
(expression (expression
(value (value
(integer))))) (integer)))))
(item (statement
(expression
(value
(boolean)))))
(else
(statement (statement
(expression (expression
(value (value
(boolean)))))) (boolean))))))
(else
(item
(statement
(expression (expression
(value (value
(boolean)))))))) (string)))))))
(statement
(expression
(value
(string)))))))))

View File

@ -1,240 +0,0 @@
==================
If
==================
if true { "True" }
---
(root
(item
(statement
(if_else
(if
(expression
(value
(boolean)))
(item
(statement
(expression
(value
(string))))))))))
==================
Complex If
==================
if (1 == 1) && (2 == 2) && (3 == 3) { "True" }
---
(root
(item
(statement
(if_else
(if
(expression
(logic
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(logic
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))))))
(item
(statement
(expression
(value
(string))))))))))
==================
If Assignment
==================
x = if true { 1 }
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(if_else
(if
(expression
(value
(boolean)))
(item
(statement
(expression
(value
(integer))))))))))))
==================
If Else
==================
if false { "True" } else { "False" }
---
(root
(item
(statement
(if_else
(if
(expression
(value
(boolean)))
(item
(statement
(expression
(value
(string))))))
(else
(item
(statement
(expression
(value
(string))))))))))
==================
If Else If
==================
if 1 == 1 {
"math is fun"
} else if 4 == 9 {
"math is broken"
}
---
(root
(item
(statement
(if_else
(if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(item
(statement
(expression
(value
(string))))))
(else_if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(item
(statement
(expression
(value
(string))))))))))
==================
If Else Else If Else
==================
if false {
"no"
} else if false {
"no"
} else if 1 + 1 == 9 {
"not the answer"
} else {
"42"
}
---
(root
(item
(statement
(if_else
(if
(expression
(value
(boolean)))
(item
(statement
(expression
(value
(string))))))
(else_if
(expression
(value
(boolean)))
(item
(statement
(expression
(value
(string))))))
(else_if
(expression
(logic
(expression
(math
(expression
(value
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(item
(statement
(expression
(value
(string))))))
(else
(item
(statement
(expression
(value
(string))))))))))

View File

@ -1,5 +1,5 @@
================== ==================
Filter Loop Simple Filter Loop
================== ==================
filter i in [1, 2, 3] { filter i in [1, 2, 3] {
@ -9,7 +9,6 @@ filter i in [1, 2, 3] {
--- ---
(root (root
(item
(statement (statement
(filter (filter
(identifier) (identifier)
@ -25,7 +24,39 @@ filter i in [1, 2, 3] {
(expression (expression
(value (value
(integer)))))) (integer))))))
(item (statement
(expression
(logic
(expression
(identifier))
(logic_operator)
(expression
(value
(integer)))))))))
==================
Nested Filter Loop
==================
filter i in big_list {
filter j in i {
i != 42
}
}
---
(root
(statement
(filter
(identifier)
(expression
(identifier))
(statement
(filter
(identifier)
(expression
(identifier))
(statement (statement
(expression (expression
(logic (logic
@ -35,45 +66,3 @@ filter i in [1, 2, 3] {
(expression (expression
(value (value
(integer))))))))))) (integer)))))))))))
==================
Filter Loop Assignment
==================
list = filter i in ["one", "two", "three"] {
i == "one"
}
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(filter
(identifier)
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(string)))
(expression
(value
(string))))))
(item
(statement
(expression
(logic
(expression
(identifier))
(logic_operator)
(expression
(value
(string)))))))))))))

View File

@ -1,5 +1,5 @@
================== ==================
Find Loop Simple Find Loop
================== ==================
find i in [1, 2, 3] { find i in [1, 2, 3] {
@ -9,7 +9,6 @@ find i in [1, 2, 3] {
--- ---
(root (root
(item
(statement (statement
(find (find
(identifier) (identifier)
@ -25,7 +24,6 @@ find i in [1, 2, 3] {
(expression (expression
(value (value
(integer)))))) (integer))))))
(item
(statement (statement
(expression (expression
(logic (logic
@ -34,24 +32,28 @@ find i in [1, 2, 3] {
(logic_operator) (logic_operator)
(expression (expression
(value (value
(integer))))))))))) (integer)))))))))
================== ==================
Find Loop Assignment Nested Find Loop
================== ==================
found = find i in ["one", "two", "three"] { find i in ["one", "two", "three"] {
i == "three" found = find j in i {
i == "e"
}
if (type found) != 'empty' {
true
} else {
false
}
} }
--- ---
(root (root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement (statement
(find (find
(identifier) (identifier)
@ -67,7 +69,15 @@ found = find i in ["one", "two", "three"] {
(expression (expression
(value (value
(string)))))) (string))))))
(item (statement
(assignment
(identifier)
(assignment_operator)
(statement
(find
(identifier)
(expression
(identifier))
(statement (statement
(expression (expression
(logic (logic
@ -76,4 +86,25 @@ found = find i in ["one", "two", "three"] {
(logic_operator) (logic_operator)
(expression (expression
(value (value
(string))))))))))))) (string)))))))))
(if_else
(if
(expression
(logic
(expression
(tool
(expression
(identifier))))
(logic_operator)
(expression
(value
(string)))))
(statement
(expression
(value
(boolean)))))
(else
(statement
(expression
(value
(boolean))))))))))

View File

@ -9,7 +9,6 @@ for i in [1, 2, 3] {
--- ---
(root (root
(item
(statement (statement
(for (for
(identifier) (identifier)
@ -25,12 +24,11 @@ for i in [1, 2, 3] {
(expression (expression
(value (value
(integer)))))) (integer))))))
(item
(statement (statement
(expression (expression
(tool (tool
(expression (expression
(identifier)))))))))) (identifier))))))))
================== ==================
Nested For Loop Nested For Loop
@ -45,21 +43,18 @@ for list in list_of_lists {
--- ---
(root (root
(item
(statement (statement
(for (for
(identifier) (identifier)
(expression (expression
(identifier)) (identifier))
(item
(statement (statement
(for (for
(identifier) (identifier)
(expression (expression
(identifier)) (identifier))
(item
(statement (statement
(expression (expression
(tool (tool
(expression (expression
(identifier))))))))))))) (identifier))))))))))

View File

@ -7,16 +7,14 @@ function { "Hiya" }
--- ---
(root (root
(item
(statement (statement
(expression (expression
(value (value
(function (function
(item
(statement (statement
(expression (expression
(value (value
(string))))))))))) (string)))))))))
================== ==================
Function Call Function Call
@ -27,14 +25,13 @@ Function Call
--- ---
(root (root
(item
(statement (statement
(expression (expression
(function_call (function_call
(identifier) (identifier)
(expression (expression
(value (value
(string)))))))) (string)))))))
================== ==================
Complex Function Complex Function
@ -48,24 +45,21 @@ function <message number> {
--- ---
(root (root
(item
(statement (statement
(expression (expression
(value (value
(function (function
(identifier) (identifier)
(identifier) (identifier)
(item
(statement (statement
(expression (expression
(tool (tool
(expression (expression
(identifier))))) (identifier))))
(statement
(expression (expression
(tool (tool
(expression (expression
(identifier)))))))))))) (identifier))))))))))
================== ==================
Complex Function Call Complex Function Call
@ -83,7 +77,6 @@ Complex Function Call
--- ---
(root (root
(item
(statement (statement
(expression (expression
(function_call (function_call
@ -104,4 +97,4 @@ Complex Function Call
(identifier) (identifier)
(expression (expression
(value (value
(integer))))))))))) (integer))))))))))

View File

@ -9,15 +9,12 @@ __xyz__
--- ---
(root (root
(item (statement
(expression
(identifier)))
(statement
(expression
(identifier)))
(statement (statement
(expression (expression
(identifier)))) (identifier))))
(item
(statement
(expression
(identifier))))
(item
(statement
(expression
(identifier)))))

View File

@ -0,0 +1,242 @@
==================
Simple If
==================
if true { "True" }
---
(root
(statement
(if_else
(if
(expression
(value
(boolean)))
(statement
(expression
(value
(string))))))))
==================
Complex If
==================
if 1 == 1 && 2 == 2 && 3 == 3 { "True" }
---
(root
(statement
(if_else
(if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))))))))))
(statement
(expression
(value
(string))))))))
==================
Nested If
==================
if true {
if 42 == 12 {
'hiya'
} else {
'bye'
}
}
---
(root
(statement
(if_else
(if
(expression
(value
(boolean)))
(statement
(if_else
(if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression
(value
(string)))))
(else
(statement
(expression
(value
(string)))))))))))
==================
If Else
==================
if false { "True" } else { "False" }
---
(root
(statement
(if_else
(if
(expression
(value
(boolean)))
(statement
(expression
(value
(string)))))
(else
(statement
(expression
(value
(string))))))))
==================
If Else If
==================
if 1 == 1 {
"math is fun"
} else if 4 == 9 {
"math is broken"
}
---
(root
(statement
(if_else
(if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression
(value
(string)))))
(else_if
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression
(value
(string))))))))
==================
If Else Else If Else
==================
if false {
"no"
} else if false {
"no"
} else if 1 + 1 == 9 {
"not the answer"
} else {
"42"
}
---
(root
(statement
(if_else
(if
(expression
(value
(boolean)))
(statement
(expression
(value
(string)))))
(else_if
(expression
(value
(boolean)))
(statement
(expression
(value
(string)))))
(else_if
(expression
(logic
(expression
(math
(expression
(value
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression
(value
(string)))))
(else
(statement
(expression
(value
(string))))))))

View File

@ -1,5 +1,5 @@
================== ==================
Indexing Simple Indexes
================== ==================
dust_data:1:name dust_data:1:name
@ -11,7 +11,6 @@ foobar:1:42
--- ---
(root (root
(item
(statement (statement
(expression (expression
(index (index
@ -23,16 +22,14 @@ foobar:1:42
(value (value
(integer))))) (integer)))))
(expression (expression
(identifier)))))) (identifier)))))
(item
(statement (statement
(expression (expression
(index (index
(expression (expression
(identifier)) (identifier))
(expression (expression
(identifier)))))) (identifier)))))
(item
(statement (statement
(expression (expression
(index (index
@ -45,36 +42,51 @@ foobar:1:42
(integer))))) (integer)))))
(expression (expression
(value (value
(integer)))))))) (integer)))))))
================== ==================
Sublist Nested Indexes
================== ==================
['answers', 42, 666]:1..2 [['answers' 'foobar'], 42, 666]:0:1:0..2
--- ---
(root (root
(item
(statement (statement
(expression (expression
(index (index
(expression
(index
(expression
(index
(expression
(value
(list
(expression (expression
(value (value
(list (list
(expression (expression
(value (value
(string))) (string)))
(expression
(value
(string))))))
(expression (expression
(value (value
(integer))) (integer)))
(expression (expression
(value (value
(integer)))))) (integer))))))
(expression
(value
(integer)))))
(expression
(value
(integer)))))
(expression (expression
(value (value
(integer))) (integer)))
(expression (expression
(value (value
(integer)))))))) (integer)))))))

View File

@ -7,7 +7,6 @@ List Declaration
--- ---
(root (root
(item
(statement (statement
(expression (expression
(value (value
@ -17,39 +16,7 @@ List Declaration
(string))) (string)))
(expression (expression
(value (value
(integer))))))))) (integer))))))))
==================
List Assignment
==================
empty = []
foobar = ['foobar']
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(list)))))))
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(list
(expression
(value
(string)))))))))))
================== ==================
List Nesting List Nesting
@ -60,7 +27,6 @@ List Nesting
--- ---
(root (root
(item
(statement (statement
(expression (expression
(value (value
@ -79,4 +45,4 @@ List Nesting
(list (list
(expression (expression
(value (value
(integer))))))))))))))) (integer))))))))))))))

View File

@ -2,14 +2,11 @@
Simple Map Simple Map
================== ==================
{ { answer = 42 }
answer = 42
}
--- ---
(root (root
(item
(statement (statement
(expression (expression
(value (value
@ -17,20 +14,25 @@ Simple Map
(identifier) (identifier)
(expression (expression
(value (value
(integer))))))))) (integer))))))))
================== ==================
Map Assignment Nested Maps
================== ==================
x = { x = {
answer = 42 y = {
foo = 'bar'
z = {
message = 'hiya'
}
}
f = 12
} }
--- ---
(root (root
(item
(statement (statement
(assignment (assignment
(identifier) (identifier)
@ -42,4 +44,20 @@ x = {
(identifier) (identifier)
(expression (expression
(value (value
(integer))))))))))) (map
(identifier)
(expression
(value
(string)))
(identifier)
(expression
(value
(map
(identifier)
(expression
(value
(string)))))))))
(identifier)
(expression
(value
(integer))))))))))

View File

@ -7,7 +7,6 @@ Equality
--- ---
(root (root
(item
(statement (statement
(expression (expression
(logic (logic
@ -29,19 +28,17 @@ Equality
(math_operator) (math_operator)
(expression (expression
(value (value
(integer)))))))))) (integer)))))))))
================== ==================
&& &&
================== ==================
4 + 2 == 42 && true 4 + 2 == 42 && true
(((4 + 2) == 42) && true)
--- ---
(root (root
(item
(statement (statement
(expression (expression
(logic (logic
@ -64,40 +61,16 @@ Equality
(expression (expression
(value (value
(boolean))))))))) (boolean)))))))))
(item
(statement
(expression
(logic
(expression
(logic
(expression
(math
(expression
(value
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(boolean))))))))
================== ==================
\|| \||
================== ==================
4 + 2 == 42 || true 4 + 2 == 42 || true
((4 + 2) == 42) || true
--- ---
(root (root
(item
(statement (statement
(expression (expression
(logic (logic
@ -120,26 +93,3 @@ Equality
(expression (expression
(value (value
(boolean))))))))) (boolean)))))))))
(item
(statement
(expression
(logic
(expression
(logic
(expression
(math
(expression
(value
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(boolean))))))))

View File

@ -8,16 +8,14 @@ false
--- ---
(root (root
(item (statement
(expression
(value
(boolean))))
(statement (statement
(expression (expression
(value (value
(boolean))))) (boolean)))))
(item
(statement
(expression
(value
(boolean))))))
================== ==================
Integers Integers
@ -29,31 +27,26 @@ Integers
--- ---
(root (root
(item (statement
(expression
(value
(integer))))
(statement
(expression
(value
(integer))))
(statement
(expression
(value
(integer))))
(statement
(expression
(value
(integer))))
(statement (statement
(expression (expression
(value (value
(integer))))) (integer)))))
(item
(statement
(expression
(value
(integer)))))
(item
(statement
(expression
(value
(integer)))))
(item
(statement
(expression
(value
(integer)))))
(item
(statement
(expression
(value
(integer))))))
================== ==================
Strings Strings
@ -64,28 +57,23 @@ Strings
--- ---
(root (root
(item (statement
(expression
(value
(string))))
(statement
(expression
(value
(string))))
(statement
(expression
(value
(string))))
(statement
(expression
(value
(string))))
(statement (statement
(expression (expression
(value (value
(string))))) (string)))))
(item
(statement
(expression
(value
(string)))))
(item
(statement
(expression
(value
(string)))))
(item
(statement
(expression
(value
(string)))))
(item
(statement
(expression
(value
(string))))))

View File

@ -9,20 +9,17 @@ x
--- ---
(root (root
(item
(statement (statement
(expression (expression
(value (value
(integer))))) (integer))))
(item
(statement (statement
(expression (expression
(value (value
(string))))) (string))))
(item
(statement (statement
(expression (expression
(identifier))))) (identifier))))
================== ==================
Simple Assignment Simple Assignment
@ -34,7 +31,6 @@ y = "one"
--- ---
(root (root
(item
(statement (statement
(assignment (assignment
(identifier) (identifier)
@ -42,8 +38,7 @@ y = "one"
(statement (statement
(expression (expression
(value (value
(integer))))))) (integer))))))
(item
(statement (statement
(assignment (assignment
(identifier) (identifier)
@ -51,23 +46,30 @@ y = "one"
(statement (statement
(expression (expression
(value (value
(string)))))))) (string)))))))
================== ==================
Complex Assignment Complex Assignment
================== ==================
x = 1 + 1 x = if 1 + 1 == 2 {
'yo'
} else {
'no'
}
--- ---
(root (root
(item
(statement (statement
(assignment (assignment
(identifier) (identifier)
(assignment_operator) (assignment_operator)
(statement (statement
(if_else
(if
(expression
(logic
(expression (expression
(math (math
(expression (expression
@ -76,18 +78,30 @@ x = 1 + 1
(math_operator) (math_operator)
(expression (expression
(value (value
(integer)))))))))) (integer)))))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression
(value
(string)))))
(else
(statement
(expression
(value
(string))))))))))
================== ==================
Expression Precedence Expression Precedence
================== ==================
x = (3 == (1 + (2 + 2))) x = 3 == 1 + 2 + 2
--- ---
(root (root
(item
(statement (statement
(assignment (assignment
(identifier) (identifier)
@ -101,10 +115,6 @@ x = (3 == (1 + (2 + 2)))
(logic_operator) (logic_operator)
(expression (expression
(math (math
(expression
(value
(integer)))
(math_operator)
(expression (expression
(math (math
(expression (expression
@ -113,4 +123,8 @@ x = (3 == (1 + (2 + 2)))
(math_operator) (math_operator)
(expression (expression
(value (value
(integer)))))))))))))) (integer)))))
(math_operator)
(expression
(value
(integer)))))))))))

View File

@ -11,7 +11,6 @@ table <messages, numbers> [
--- ---
(root (root
(item
(statement (statement
(expression (expression
(value (value
@ -47,43 +46,7 @@ table <messages, numbers> [
(string))) (string)))
(expression (expression
(value (value
(float))))))))))))))) (float))))))))))))))
==================
Table Assignment
==================
foobar = table <text, number> [
['answer', 42]
]
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(table
(identifier)
(identifier)
(expression
(value
(list
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(integer)))))))))))))))))
================== ==================
Table Access Table Access
================== ==================
@ -95,13 +58,11 @@ select <number> from foobar {
--- ---
(root (root
(item
(statement (statement
(select (select
(identifier) (identifier)
(expression (expression
(identifier)) (identifier))
(item
(statement (statement
(expression (expression
(logic (logic
@ -110,7 +71,7 @@ select <number> from foobar {
(logic_operator) (logic_operator)
(expression (expression
(value (value
(string))))))))))) (string)))))))))
================== ==================
Table Insert Table Insert
@ -123,7 +84,6 @@ insert into foobar [
--- ---
(root (root
(item
(statement (statement
(insert (insert
(identifier) (identifier)
@ -138,4 +98,4 @@ insert into foobar [
(string))) (string)))
(expression (expression
(value (value
(integer))))))))))))) (integer))))))))))))

View File

@ -9,7 +9,6 @@ transform i in [1, 2, 3] {
--- ---
(root (root
(item
(statement (statement
(transform (transform
(identifier) (identifier)
@ -25,29 +24,25 @@ transform i in [1, 2, 3] {
(expression (expression
(value (value
(integer)))))) (integer))))))
(item
(statement (statement
(expression (expression
(tool (tool
(expression (expression
(identifier)))))))))) (identifier))))))))
================== ==================
Transform Loop Assignment Nested Transform Loop
================== ==================
list = transform i in ["one", "two", "three"] { transform i in [['one'] ['two'] ['three']] {
(output i) transform j in i {
j += 'foobar'
}
} }
--- ---
(root (root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement (statement
(transform (transform
(identifier) (identifier)
@ -56,16 +51,32 @@ list = transform i in ["one", "two", "three"] {
(list (list
(expression (expression
(value (value
(string))) (list
(expression
(value
(string)))
(expression (expression
(value (value
(string)))))) (string))))))
(item (expression
(value
(list
(expression
(value
(string))))))
(expression
(value
(list
(expression
(value
(string)))))))))
(statement
(transform
(identifier)
(expression
(identifier))
(statement
(assignment
(identifier)
(assignment_operator)
(statement (statement
(expression (expression
(tool (value
(expression (string)))))))))))
(identifier))))))))))))

View File

@ -9,42 +9,58 @@ while true {
--- ---
(root (root
(item
(statement (statement
(while (while
(expression (expression
(value (value
(boolean))) (boolean)))
(item
(statement (statement
(expression (expression
(tool (tool
(expression (expression
(value (value
(string))))))))))) (string)))))))))
================== ==================
While Loop Assignment Nested While Loop
================== ==================
answer = while false { while true {
42 x = 4
while x > 0 {
x -= 1
}
} }
--- ---
(root (root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement (statement
(while (while
(expression (expression
(value (value
(boolean))) (boolean)))
(item (statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(integer)))))
(while
(expression
(logic
(expression
(identifier))
(logic_operator)
(expression
(value
(integer)))))
(statement
(assignment
(identifier)
(assignment_operator)
(statement (statement
(expression (expression
(value (value

View File

@ -11,8 +11,8 @@ module.exports = grammar({
comment: $ => /[#][^#\n]*[#|\n]/, comment: $ => /[#][^#\n]*[#|\n]/,
statement: $ => prec.left(choice( statement: $ => prec.left(choice(
$._statement_kind, repeat1($._statement_kind),
seq('{', $._statement_kind, '}'), seq('{', repeat1($._statement_kind), '}'),
)), )),
_statement_kind: $ => prec.left(choice( _statement_kind: $ => prec.left(choice(
@ -37,7 +37,7 @@ module.exports = grammar({
seq('(', $._expression_kind, ')'), seq('(', $._expression_kind, ')'),
), ),
_expression_kind: $ => prec.left(choice( _expression_kind: $ => prec.right(choice(
$.function_call, $.function_call,
$.identifier, $.identifier,
$.index, $.index,
@ -60,9 +60,19 @@ module.exports = grammar({
$.map, $.map,
), ),
integer: $ => /0[bB][01](_?[01])*|0[oO]?[0-7](_?[0-7])*|(0[dD])?\d(_?\d)*|0[xX][0-9a-fA-F](_?[0-9a-fA-F])*/, integer: $ => prec.left(token(seq(
optional('-'),
repeat1(
choice('1', '2', '3', '4', '5', '6', '7', '8', '9', '0')
),
))),
float: $ => /\d(_?\d)*(\.\d)?(_?\d)*([eE][\+-]?\d(_?\d)*)?/, float: $ => prec.left(token(seq(
optional('-'),
repeat1(choice('1', '2', '3', '4', '5', '6', '7', '8', '9', '0')),
'.',
repeat1(choice('1', '2', '3', '4', '5', '6', '7', '8', '9', '0')),
))),
string: $ => /("[^"]*?")|('[^']*?')|(`[^`]*?`)/, string: $ => /("[^"]*?")|('[^']*?')|(`[^`]*?`)/,
@ -73,13 +83,18 @@ module.exports = grammar({
list: $ => seq( list: $ => seq(
'[', '[',
repeat(seq($.expression, optional(','))), repeat(prec.left(seq($.expression, optional(',')))),
']', ']',
), ),
map: $ => seq( map: $ => seq(
'{', '{',
$.assignment, repeat(seq(
$.identifier,
'=',
$.expression,
optional(',')
)),
'}', '}',
), ),
@ -113,13 +128,13 @@ module.exports = grammar({
$.expression, $.expression,
)), )),
math_operator: $ => choice( math_operator: $ => token(choice(
'+', '+',
'-', '-',
'*', '*',
'/', '/',
'%', '%',
), )),
logic: $ => prec.right(seq( logic: $ => prec.right(seq(
$.expression, $.expression,
@ -127,7 +142,7 @@ module.exports = grammar({
$.expression, $.expression,
)), )),
logic_operator: $ => choice( logic_operator: $ => token(choice(
'==', '==',
'!=', '!=',
'&&', '&&',
@ -136,7 +151,7 @@ module.exports = grammar({
'<', '<',
">=", ">=",
"<=", "<=",
), )),
assignment: $ => prec.right(seq( assignment: $ => prec.right(seq(
$.identifier, $.identifier,
@ -144,11 +159,11 @@ module.exports = grammar({
$.statement, $.statement,
)), )),
assignment_operator: $ => choice( assignment_operator: $ => token(choice(
"=", "=",
"+=", "+=",
"-=", "-=",
), )),
if_else: $ => prec.left(seq( if_else: $ => prec.left(seq(
$.if, $.if,
@ -182,7 +197,7 @@ module.exports = grammar({
function_call: $ => seq( function_call: $ => seq(
'(', '(',
$.identifier, $.identifier,
repeat(seq($.expression, optional(','))), repeat(prec.left(seq($.expression, optional(',')))),
')', ')',
), ),
@ -289,15 +304,13 @@ module.exports = grammar({
async: $ => seq( async: $ => seq(
'async', 'async',
'{', '{',
repeat($.statement), $.statement,
'}' '}'
), ),
tool: $ => prec.right(seq( tool: $ => prec.right(seq(
'(',
$._tool_kind, $._tool_kind,
repeat(seq($.expression, optional(','))), repeat(prec.left(seq($.expression, optional(',')))),
')',
)), )),
_tool_kind: $ => choice( _tool_kind: $ => choice(
@ -317,7 +330,6 @@ module.exports = grammar({
'metadata', 'metadata',
'move', 'move',
'read', 'read',
'remove',
'write', 'write',
// Format conversion // Format conversion

View File

@ -20,8 +20,11 @@
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "REPEAT1",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_statement_kind" "name": "_statement_kind"
}
}, },
{ {
"type": "SEQ", "type": "SEQ",
@ -31,8 +34,11 @@
"value": "{" "value": "{"
}, },
{ {
"type": "REPEAT1",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_statement_kind" "name": "_statement_kind"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -135,7 +141,7 @@
] ]
}, },
"_expression_kind": { "_expression_kind": {
"type": "PREC_LEFT", "type": "PREC_RIGHT",
"value": 0, "value": 0,
"content": { "content": {
"type": "CHOICE", "type": "CHOICE",
@ -213,12 +219,200 @@
] ]
}, },
"integer": { "integer": {
"type": "PATTERN", "type": "PREC_LEFT",
"value": "0[bB][01](_?[01])*|0[oO]?[0-7](_?[0-7])*|(0[dD])?\\d(_?\\d)*|0[xX][0-9a-fA-F](_?[0-9a-fA-F])*" "value": 0,
"content": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "-"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "1"
},
{
"type": "STRING",
"value": "2"
},
{
"type": "STRING",
"value": "3"
},
{
"type": "STRING",
"value": "4"
},
{
"type": "STRING",
"value": "5"
},
{
"type": "STRING",
"value": "6"
},
{
"type": "STRING",
"value": "7"
},
{
"type": "STRING",
"value": "8"
},
{
"type": "STRING",
"value": "9"
},
{
"type": "STRING",
"value": "0"
}
]
}
}
]
}
}
}, },
"float": { "float": {
"type": "PATTERN", "type": "PREC_LEFT",
"value": "\\d(_?\\d)*(\\.\\d)?(_?\\d)*([eE][\\+-]?\\d(_?\\d)*)?" "value": 0,
"content": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "-"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "1"
},
{
"type": "STRING",
"value": "2"
},
{
"type": "STRING",
"value": "3"
},
{
"type": "STRING",
"value": "4"
},
{
"type": "STRING",
"value": "5"
},
{
"type": "STRING",
"value": "6"
},
{
"type": "STRING",
"value": "7"
},
{
"type": "STRING",
"value": "8"
},
{
"type": "STRING",
"value": "9"
},
{
"type": "STRING",
"value": "0"
}
]
}
},
{
"type": "STRING",
"value": "."
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "1"
},
{
"type": "STRING",
"value": "2"
},
{
"type": "STRING",
"value": "3"
},
{
"type": "STRING",
"value": "4"
},
{
"type": "STRING",
"value": "5"
},
{
"type": "STRING",
"value": "6"
},
{
"type": "STRING",
"value": "7"
},
{
"type": "STRING",
"value": "8"
},
{
"type": "STRING",
"value": "9"
},
{
"type": "STRING",
"value": "0"
}
]
}
}
]
}
}
}, },
"string": { "string": {
"type": "PATTERN", "type": "PATTERN",
@ -246,6 +440,9 @@
}, },
{ {
"type": "REPEAT", "type": "REPEAT",
"content": {
"type": "PREC_LEFT",
"value": 0,
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -267,6 +464,7 @@
} }
] ]
} }
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -281,9 +479,37 @@
"type": "STRING", "type": "STRING",
"value": "{" "value": "{"
}, },
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "assignment" "name": "identifier"
},
{
"type": "STRING",
"value": "="
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -475,6 +701,8 @@
} }
}, },
"math_operator": { "math_operator": {
"type": "TOKEN",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -498,6 +726,7 @@
"value": "%" "value": "%"
} }
] ]
}
}, },
"logic": { "logic": {
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
@ -521,6 +750,8 @@
} }
}, },
"logic_operator": { "logic_operator": {
"type": "TOKEN",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -556,6 +787,7 @@
"value": "<=" "value": "<="
} }
] ]
}
}, },
"assignment": { "assignment": {
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
@ -579,6 +811,8 @@
} }
}, },
"assignment_operator": { "assignment_operator": {
"type": "TOKEN",
"content": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -594,6 +828,7 @@
"value": "-=" "value": "-="
} }
] ]
}
}, },
"if_else": { "if_else": {
"type": "PREC_LEFT", "type": "PREC_LEFT",
@ -716,6 +951,9 @@
}, },
{ {
"type": "REPEAT", "type": "REPEAT",
"content": {
"type": "PREC_LEFT",
"value": 0,
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -737,6 +975,7 @@
} }
] ]
} }
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1159,11 +1398,8 @@
"value": "{" "value": "{"
}, },
{ {
"type": "REPEAT",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "statement"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1177,16 +1413,15 @@
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{
"type": "STRING",
"value": "("
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_tool_kind" "name": "_tool_kind"
}, },
{ {
"type": "REPEAT", "type": "REPEAT",
"content": {
"type": "PREC_LEFT",
"value": 0,
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -1208,10 +1443,7 @@
} }
] ]
} }
}, }
{
"type": "STRING",
"value": ")"
} }
] ]
} }
@ -1271,10 +1503,6 @@
"type": "STRING", "type": "STRING",
"value": "read" "value": "read"
}, },
{
"type": "STRING",
"value": "remove"
},
{ {
"type": "STRING", "type": "STRING",
"value": "write" "value": "write"

View File

@ -22,18 +22,13 @@
] ]
} }
}, },
{
"type": "assignment_operator",
"named": true,
"fields": {}
},
{ {
"type": "async", "type": "async",
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": false,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "statement", "type": "statement",
@ -189,6 +184,11 @@
] ]
} }
}, },
{
"type": "float",
"named": true,
"fields": {}
},
{ {
"type": "for", "type": "for",
"named": true, "named": true,
@ -326,6 +326,11 @@
] ]
} }
}, },
{
"type": "integer",
"named": true,
"fields": {}
},
{ {
"type": "list", "type": "list",
"named": true, "named": true,
@ -360,21 +365,20 @@
] ]
} }
}, },
{
"type": "logic_operator",
"named": true,
"fields": {}
},
{ {
"type": "map", "type": "map",
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": false, "multiple": true,
"required": true, "required": false,
"types": [ "types": [
{ {
"type": "assignment", "type": "expression",
"named": true
},
{
"type": "identifier",
"named": true "named": true
} }
] ]
@ -418,11 +422,6 @@
] ]
} }
}, },
{
"type": "math_operator",
"named": true,
"fields": {}
},
{ {
"type": "reduce", "type": "reduce",
"named": true, "named": true,
@ -512,7 +511,7 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": false, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{ {
@ -693,18 +692,6 @@
] ]
} }
}, },
{
"type": "!=",
"named": false
},
{
"type": "%",
"named": false
},
{
"type": "&&",
"named": false
},
{ {
"type": "(", "type": "(",
"named": false "named": false
@ -713,38 +700,14 @@
"type": ")", "type": ")",
"named": false "named": false
}, },
{
"type": "*",
"named": false
},
{
"type": "+",
"named": false
},
{
"type": "+=",
"named": false
},
{ {
"type": ",", "type": ",",
"named": false "named": false
}, },
{
"type": "-",
"named": false
},
{
"type": "-=",
"named": false
},
{ {
"type": "..", "type": "..",
"named": false "named": false
}, },
{
"type": "/",
"named": false
},
{ {
"type": ":", "type": ":",
"named": false "named": false
@ -753,18 +716,10 @@
"type": "<", "type": "<",
"named": false "named": false
}, },
{
"type": "<=",
"named": false
},
{ {
"type": "=", "type": "=",
"named": false "named": false
}, },
{
"type": "==",
"named": false
},
{ {
"type": "=>", "type": "=>",
"named": false "named": false
@ -773,10 +728,6 @@
"type": ">", "type": ">",
"named": false "named": false
}, },
{
"type": ">=",
"named": false
},
{ {
"type": "[", "type": "[",
"named": false "named": false
@ -797,6 +748,10 @@
"type": "assert_equal", "type": "assert_equal",
"named": false "named": false
}, },
{
"type": "assignment_operator",
"named": true
},
{ {
"type": "async", "type": "async",
"named": false "named": false
@ -841,10 +796,6 @@
"type": "fish", "type": "fish",
"named": false "named": false
}, },
{
"type": "float",
"named": true
},
{ {
"type": "for", "type": "for",
"named": false "named": false
@ -881,10 +832,6 @@
"type": "insert", "type": "insert",
"named": false "named": false
}, },
{
"type": "integer",
"named": true
},
{ {
"type": "into", "type": "into",
"named": false "named": false
@ -893,10 +840,18 @@
"type": "length", "type": "length",
"named": false "named": false
}, },
{
"type": "logic_operator",
"named": true
},
{ {
"type": "match", "type": "match",
"named": false "named": false
}, },
{
"type": "math_operator",
"named": true
},
{ {
"type": "metadata", "type": "metadata",
"named": false "named": false
@ -1017,10 +972,6 @@
"type": "{", "type": "{",
"named": false "named": false
}, },
{
"type": "||",
"named": false
},
{ {
"type": "}", "type": "}",
"named": false "named": false

File diff suppressed because it is too large Load Diff