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 (statement
(item (expression
(statement (tool
(expression (expression
(tool (value
(expression (string)))))))))
(value
(string)))))))))))
================== ==================
Complex Async Statements Complex Async Statements
@ -35,40 +33,35 @@ async {
--- ---
(root (root
(item (statement
(statement (async
(async (statement
(item (if_else
(statement (if
(if_else (expression
(if (logic
(expression (expression
(logic (math
(expression (expression
(math (value
(expression (integer)))
(value (math_operator)
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression (expression
(value (value
(integer))))) (integer)))))
(item (logic_operator)
(statement (expression
(expression (value
(value (integer)))))
(boolean)))))) (statement
(else (expression
(item (value
(statement (boolean)))))
(expression (else
(value (statement
(boolean)))))))) (expression
(statement (value
(expression (boolean))))))
(value (expression
(string))))))))) (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,23 +9,54 @@ filter i in [1, 2, 3] {
--- ---
(root (root
(item (statement
(statement (filter
(filter (identifier)
(identifier) (expression
(value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(statement
(expression (expression
(value (logic
(list (expression
(expression (identifier))
(value (logic_operator)
(integer))) (expression
(expression (value
(value (integer)))))))))
(integer)))
(expression ==================
(value Nested Filter Loop
(integer)))))) ==================
(item
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,65 +9,75 @@ find i in [1, 2, 3] {
--- ---
(root (root
(item (statement
(statement (find
(find (identifier)
(identifier) (expression
(expression (value
(value (list
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(item
(statement
(expression (expression
(logic (value
(expression (integer)))
(identifier)) (expression
(logic_operator) (value
(expression (integer)))
(value (expression
(integer))))))))))) (value
(integer))))))
(statement
(expression
(logic
(expression
(identifier))
(logic_operator)
(expression
(value
(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
(statement (find
(assignment (identifier)
(identifier) (expression
(assignment_operator) (value
(statement (list
(find
(identifier)
(expression (expression
(value (value
(list (string)))
(expression (expression
(value (value
(string))) (string)))
(expression (expression
(value (value
(string))) (string))))))
(expression (statement
(value (assignment
(string)))))) (identifier)
(item (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,28 +9,26 @@ for i in [1, 2, 3] {
--- ---
(root (root
(item (statement
(statement (for
(for (identifier)
(identifier) (expression
(expression (value
(value (list
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(item
(statement
(expression (expression
(tool (value
(expression (integer)))
(identifier)))))))))) (expression
(value
(integer)))
(expression
(value
(integer))))))
(statement
(expression
(tool
(expression
(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)) (statement
(item (for
(identifier)
(expression
(identifier))
(statement (statement
(for (expression
(identifier) (tool
(expression (expression
(identifier)) (identifier))))))))))
(item
(statement
(expression
(tool
(expression
(identifier)))))))))))))

View File

@ -7,16 +7,14 @@ function { "Hiya" }
--- ---
(root (root
(item (statement
(statement (expression
(expression (value
(value (function
(function (statement
(item (expression
(statement (value
(expression (string)))))))))
(value
(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) (statement
(item (expression
(statement (tool
(expression (expression
(tool (identifier))))
(expression (expression
(identifier))))) (tool
(statement
(expression (expression
(tool (identifier))))))))))
(expression
(identifier))))))))))))
================== ==================
Complex Function Call Complex Function Call
@ -83,25 +77,24 @@ Complex Function Call
--- ---
(root (root
(item (statement
(statement (expression
(expression (function_call
(function_call (identifier)
(identifier) (expression
(expression (value
(value (string)))
(string))) (expression
(expression (value
(value (integer)))
(integer))) (expression
(expression (value
(value (map
(map (identifier)
(identifier) (expression
(expression (value
(value (integer)))
(integer))) (identifier)
(identifier) (expression
(expression (value
(value (integer))))))))))
(integer)))))))))))

View File

@ -9,15 +9,12 @@ __xyz__
--- ---
(root (root
(item (statement
(statement (expression
(expression (identifier)))
(identifier)))) (statement
(item (expression
(statement (identifier)))
(expression (statement
(identifier)))) (expression
(item (identifier))))
(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,70 +11,82 @@ foobar:1:42
--- ---
(root (root
(item (statement
(statement (expression
(expression (index
(index (expression
(expression (index
(index (expression
(expression (identifier))
(identifier)) (expression
(expression (value
(value (integer)))))
(integer))))) (expression
(expression (identifier)))))
(identifier)))))) (statement
(item (expression
(statement (index
(expression (expression
(index (identifier))
(expression (expression
(identifier)) (identifier)))))
(expression (statement
(identifier)))))) (expression
(item (index
(statement (expression
(expression (index
(index (expression
(expression (identifier))
(index (expression
(expression (value
(identifier)) (integer)))))
(expression (expression
(value (value
(integer))))) (integer)))))))
(expression
(value
(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
(expression (index
(value (expression
(list (index
(expression (expression
(value (value
(string))) (list
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(string))))))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(expression (expression
(value (value
(integer))) (integer)))))
(expression (expression
(value (value
(integer)))))) (integer)))))
(expression (expression
(value (value
(integer))) (integer)))
(expression (expression
(value (value
(integer)))))))) (integer)))))))

View File

@ -7,49 +7,16 @@ List Declaration
--- ---
(root (root
(item (statement
(statement (expression
(expression (value
(value (list
(list
(expression
(value
(string)))
(expression
(value
(integer)))))))))
==================
List Assignment
==================
empty = []
foobar = ['foobar']
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression (expression
(value (value
(list))))))) (string)))
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression (expression
(value (value
(list (integer))))))))
(expression
(value
(string)))))))))))
================== ==================
List Nesting List Nesting
@ -60,23 +27,22 @@ List Nesting
--- ---
(root (root
(item (statement
(statement (expression
(expression (value
(value (list
(list (expression
(expression (value
(value (string)))
(string))) (expression
(expression (value
(value (list
(list (expression
(expression (value
(value (integer)))
(integer))) (expression
(expression (value
(value (list
(list (expression
(expression (value
(value (integer))))))))))))))
(integer)))))))))))))))

View File

@ -2,44 +2,62 @@
Simple Map Simple Map
================== ==================
{ { answer = 42 }
answer = 42
}
--- ---
(root (root
(item (statement
(statement (expression
(expression (value
(value (map
(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) (assignment_operator)
(assignment_operator) (statement
(statement (expression
(expression (value
(value (map
(map (identifier)
(identifier) (expression
(expression (value
(value (map
(integer))))))))))) (identifier)
(expression
(value
(string)))
(identifier)
(expression
(value
(map
(identifier)
(expression
(value
(string)))))))))
(identifier)
(expression
(value
(integer))))))))))

View File

@ -7,139 +7,89 @@ Equality
--- ---
(root (root
(item (statement
(statement (expression
(expression (logic
(logic (expression
(expression (value
(value (integer)))
(integer))) (logic_operator)
(logic_operator) (expression
(expression (math
(math (expression
(expression (math
(math (expression
(expression (value
(value (integer)))
(integer))) (math_operator)
(math_operator) (expression
(expression (value
(value (integer)))))
(integer))))) (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 (expression
(expression (math
(math (expression
(expression (value
(value (integer)))
(integer))) (math_operator)
(math_operator) (expression
(expression (value
(value (integer)))))
(integer))))) (logic_operator)
(logic_operator) (expression
(expression (logic
(logic (expression
(expression (value
(value (integer)))
(integer))) (logic_operator)
(logic_operator) (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 (expression
(expression (math
(math (expression
(expression (value
(value (integer)))
(integer))) (math_operator)
(math_operator) (expression
(expression (value
(value (integer)))))
(integer))))) (logic_operator)
(logic_operator) (expression
(expression (logic
(logic (expression
(expression (value
(value (integer)))
(integer))) (logic_operator)
(logic_operator) (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
(statement (expression
(expression (value
(value (boolean))))
(boolean))))) (statement
(item (expression
(statement (value
(expression (boolean)))))
(value
(boolean))))))
================== ==================
Integers Integers
@ -29,31 +27,26 @@ Integers
--- ---
(root (root
(item (statement
(statement (expression
(expression (value
(value (integer))))
(integer))))) (statement
(item (expression
(statement (value
(expression (integer))))
(value (statement
(integer))))) (expression
(item (value
(statement (integer))))
(expression (statement
(value (expression
(integer))))) (value
(item (integer))))
(statement (statement
(expression (expression
(value (value
(integer))))) (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))))) (statement
(item (expression
(statement (value
(expression (string))))
(value (statement
(string))))) (expression
(item (identifier))))
(statement
(expression
(identifier)))))
================== ==================
Simple Assignment Simple Assignment
@ -34,83 +31,100 @@ y = "one"
--- ---
(root (root
(item (statement
(statement (assignment
(assignment (identifier)
(identifier) (assignment_operator)
(assignment_operator) (statement
(statement (expression
(expression (value
(value (integer))))))
(integer))))))) (statement
(item (assignment
(statement (identifier)
(assignment (assignment_operator)
(identifier) (statement
(assignment_operator) (expression
(statement (value
(expression (string)))))))
(value
(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
(expression (if
(math (expression
(logic
(expression
(math
(expression
(value
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression (expression
(value (value
(integer))) (string)))))
(math_operator) (else
(statement
(expression (expression
(value (value
(integer)))))))))) (string))))))))))
================== ==================
Expression Precedence Expression Precedence
================== ==================
x = (3 == (1 + (2 + 2))) x = 3 == 1 + 2 + 2
--- ---
(root (root
(item (statement
(statement (assignment
(assignment (identifier)
(identifier) (assignment_operator)
(assignment_operator) (statement
(statement (expression
(expression (logic
(logic (expression
(expression (value
(value (integer)))
(integer))) (logic_operator)
(logic_operator) (expression
(expression (math
(math (expression
(expression (math
(value (expression
(integer))) (value
(math_operator) (integer)))
(expression (math_operator)
(math (expression
(expression (value
(value (integer)))))
(integer))) (math_operator)
(math_operator) (expression
(expression (value
(value (integer)))))))))))
(integer))))))))))))))

View File

@ -11,79 +11,42 @@ table <messages, numbers> [
--- ---
(root (root
(item (statement
(statement (expression
(expression (value
(value (table
(table (identifier)
(identifier) (identifier)
(identifier)
(expression
(value
(list
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(integer))))))
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(integer))))))
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(float)))))))))))))))
==================
Table Assignment
==================
foobar = table <text, number> [
['answer', 42]
]
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression (expression
(value (value
(table (list
(identifier)
(identifier)
(expression (expression
(value (value
(list (list
(expression (expression
(value (value
(list (string)))
(expression (expression
(value (value
(string))) (integer))))))
(expression (expression
(value (value
(integer))))))))))))))))) (list
(expression
(value
(string)))
(expression
(value
(integer))))))
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(float))))))))))))))
================== ==================
Table Access Table Access
================== ==================
@ -95,22 +58,20 @@ select <number> from foobar {
--- ---
(root (root
(item (statement
(statement (select
(select (identifier)
(identifier) (expression
(identifier))
(statement
(expression (expression
(identifier)) (logic
(item
(statement
(expression (expression
(logic (identifier))
(expression (logic_operator)
(identifier)) (expression
(logic_operator) (value
(expression (string)))))))))
(value
(string)))))))))))
================== ==================
Table Insert Table Insert
@ -123,19 +84,18 @@ insert into foobar [
--- ---
(root (root
(item (statement
(statement (insert
(insert (identifier)
(identifier) (expression
(expression (value
(value (list
(list (expression
(expression (value
(value (list
(list (expression
(expression (value
(value (string)))
(string))) (expression
(expression (value
(value (integer))))))))))))
(integer)))))))))))))

View File

@ -9,63 +9,74 @@ transform i in [1, 2, 3] {
--- ---
(root (root
(item (statement
(statement (transform
(transform (identifier)
(identifier) (expression
(expression (value
(value (list
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(item
(statement
(expression (expression
(tool (value
(expression (integer)))
(identifier)))))))))) (expression
(value
(integer)))
(expression
(value
(integer))))))
(statement
(expression
(tool
(expression
(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
(statement (transform
(assignment (identifier)
(identifier) (expression
(assignment_operator) (value
(statement (list
(transform
(identifier)
(expression (expression
(value (value
(list (list
(expression (expression
(value (value
(string))) (string))))))
(expression (expression
(value (value
(string))) (list
(expression (expression
(value (value
(string)))))) (string))))))
(item (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
(value
(boolean)))
(statement
(expression (expression
(value (tool
(boolean)))
(item
(statement
(expression (expression
(tool (value
(expression (string)))))))))
(value
(string)))))))))))
================== ==================
While Loop Assignment Nested While Loop
================== ==================
answer = while false { while true {
42 x = 4
while x > 0 {
x -= 1
}
} }
--- ---
(root (root
(item (statement
(statement (while
(assignment (expression
(identifier) (value
(assignment_operator) (boolean)))
(statement (statement
(while (assignment
(identifier)
(assignment_operator)
(statement
(expression (expression
(value (value
(boolean))) (integer)))))
(item (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": "SYMBOL", "type": "REPEAT1",
"name": "_statement_kind" "content": {
"type": "SYMBOL",
"name": "_statement_kind"
}
}, },
{ {
"type": "SEQ", "type": "SEQ",
@ -31,8 +34,11 @@
"value": "{" "value": "{"
}, },
{ {
"type": "SYMBOL", "type": "REPEAT1",
"name": "_statement_kind" "content": {
"type": "SYMBOL",
"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",
@ -244,11 +438,60 @@
"type": "STRING", "type": "STRING",
"value": "[" "value": "["
}, },
{
"type": "REPEAT",
"content": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
}
},
{
"type": "STRING",
"value": "]"
}
]
},
"map": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{ {
"type": "REPEAT", "type": "REPEAT",
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "="
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "expression" "name": "expression"
@ -268,23 +511,6 @@
] ]
} }
}, },
{
"type": "STRING",
"value": "]"
}
]
},
"map": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "assignment"
},
{ {
"type": "STRING", "type": "STRING",
"value": "}" "value": "}"
@ -475,29 +701,32 @@
} }
}, },
"math_operator": { "math_operator": {
"type": "CHOICE", "type": "TOKEN",
"members": [ "content": {
{ "type": "CHOICE",
"type": "STRING", "members": [
"value": "+" {
}, "type": "STRING",
{ "value": "+"
"type": "STRING", },
"value": "-" {
}, "type": "STRING",
{ "value": "-"
"type": "STRING", },
"value": "*" {
}, "type": "STRING",
{ "value": "*"
"type": "STRING", },
"value": "/" {
}, "type": "STRING",
{ "value": "/"
"type": "STRING", },
"value": "%" {
} "type": "STRING",
] "value": "%"
}
]
}
}, },
"logic": { "logic": {
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
@ -521,41 +750,44 @@
} }
}, },
"logic_operator": { "logic_operator": {
"type": "CHOICE", "type": "TOKEN",
"members": [ "content": {
{ "type": "CHOICE",
"type": "STRING", "members": [
"value": "==" {
}, "type": "STRING",
{ "value": "=="
"type": "STRING", },
"value": "!=" {
}, "type": "STRING",
{ "value": "!="
"type": "STRING", },
"value": "&&" {
}, "type": "STRING",
{ "value": "&&"
"type": "STRING", },
"value": "||" {
}, "type": "STRING",
{ "value": "||"
"type": "STRING", },
"value": ">" {
}, "type": "STRING",
{ "value": ">"
"type": "STRING", },
"value": "<" {
}, "type": "STRING",
{ "value": "<"
"type": "STRING", },
"value": ">=" {
}, "type": "STRING",
{ "value": ">="
"type": "STRING", },
"value": "<=" {
} "type": "STRING",
] "value": "<="
}
]
}
}, },
"assignment": { "assignment": {
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
@ -579,21 +811,24 @@
} }
}, },
"assignment_operator": { "assignment_operator": {
"type": "CHOICE", "type": "TOKEN",
"members": [ "content": {
{ "type": "CHOICE",
"type": "STRING", "members": [
"value": "=" {
}, "type": "STRING",
{ "value": "="
"type": "STRING", },
"value": "+=" {
}, "type": "STRING",
{ "value": "+="
"type": "STRING", },
"value": "-=" {
} "type": "STRING",
] "value": "-="
}
]
}
}, },
"if_else": { "if_else": {
"type": "PREC_LEFT", "type": "PREC_LEFT",
@ -717,25 +952,29 @@
{ {
"type": "REPEAT", "type": "REPEAT",
"content": { "content": {
"type": "SEQ", "type": "PREC_LEFT",
"members": [ "value": 0,
{ "content": {
"type": "SYMBOL", "type": "SEQ",
"name": "expression" "members": [
}, {
{ "type": "SYMBOL",
"type": "CHOICE", "name": "expression"
"members": [ },
{ {
"type": "STRING", "type": "CHOICE",
"value": "," "members": [
}, {
{ "type": "STRING",
"type": "BLANK" "value": ","
} },
] {
} "type": "BLANK"
] }
]
}
]
}
} }
}, },
{ {
@ -1159,11 +1398,8 @@
"value": "{" "value": "{"
}, },
{ {
"type": "REPEAT", "type": "SYMBOL",
"content": { "name": "statement"
"type": "SYMBOL",
"name": "statement"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1177,10 +1413,6 @@
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{
"type": "STRING",
"value": "("
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_tool_kind" "name": "_tool_kind"
@ -1188,30 +1420,30 @@
{ {
"type": "REPEAT", "type": "REPEAT",
"content": { "content": {
"type": "SEQ", "type": "PREC_LEFT",
"members": [ "value": 0,
{ "content": {
"type": "SYMBOL", "type": "SEQ",
"name": "expression" "members": [
}, {
{ "type": "SYMBOL",
"type": "CHOICE", "name": "expression"
"members": [ },
{ {
"type": "STRING", "type": "CHOICE",
"value": "," "members": [
}, {
{ "type": "STRING",
"type": "BLANK" "value": ","
} },
] {
} "type": "BLANK"
] }
]
}
]
}
} }
},
{
"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