1
0

Begin syntax revision

This commit is contained in:
Jeff 2023-10-31 01:09:29 -04:00
parent 9c565e810e
commit 42339e1171
17 changed files with 8738 additions and 7450 deletions

2
Cargo.lock generated
View File

@ -459,7 +459,7 @@ dependencies = [
[[package]] [[package]]
name = "dust-lang" name = "dust-lang"
version = "0.3.4" version = "0.3.5"
dependencies = [ dependencies = [
"ansi_term", "ansi_term",
"async-std", "async-std",

View File

@ -10,7 +10,7 @@ take_turn = function <current_room opponent_card> {
remove_card = function <opponent_card> { remove_card = function <opponent_card> {
for card_list in cards { for card_list in cards {
removed = remove card in card_list { removed = remove card from card_list {
card == opponent_card card == opponent_card
} }
} }
@ -21,16 +21,16 @@ remove_card = function <opponent_card> {
} }
make_guess = function <current_room> { make_guess = function <current_room> {
if ((length suspects) == 1) if (length suspects) == 1
&& ((length rooms) == 1) && (length rooms) == 1
&& ((length weapons) == 1) && (length weapons) == 1
{ {
(output 'It was ' (output 'It was '
+ suspects.{0} + suspects:0
+ ' in the ' + ' in the '
+ rooms.{0} + rooms:0
+ ' with the ' + ' with the '
+ weapons.{0} + weapons:0
+ '!') + '!')
} else { } else {
(output 'I accuse ' (output 'I accuse '
@ -42,3 +42,5 @@ make_guess = function <current_room> {
+ '!') + '!')
} }
} }
(make_guess 'Library')

View File

@ -1,6 +1,6 @@
list = [1 2 3] list = [1 2 3]
async for i in list { for i in list {
i += 1 i += 1
(output i) (output i)
} }

View File

@ -1,60 +0,0 @@
# Function
x = "bar"
func = function <> {
x = "foo"
x
}
assert_equal("foo", (func))
assert_equal("bar", x)
# For Loop
x = 42
for number in [1 2 3] {
x += number
}
assert_equal(48, x)
# Async Loops
## Transform Loop
x = 42
y = [1 2 3]
transform number in y {
number += x
x = 1000
}
assert_equal([43, 44, 45], y)
assert_equal(42, x)
## Filter Loop
x = 42
y = [1 2 3]
transform number in y {
number += x
x = 1000
}
assert_equal([43, 44, 45], y)
assert_equal(42, x)
## Filter Loop
x = 42
y = [1 2 3]
filter number in y {
number += x
x = 1000
}
assert_equal([43, 44, 45], y)
assert_equal(42, x)

View File

@ -1,5 +1,5 @@
data = (from_json (read "examples/assets/jq_data.json")) data = (from_json (read "examples/assets/jq_data.json"))
transform item in data { transform item in data {
item.{commit}.{committer}.{name} item:commit:committer:name
} }

View File

@ -6,41 +6,58 @@ use crate::{AbstractTree, Error, Expression, Identifier, Item, List, Map, Result
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Filter { pub struct Filter {
identifier: Identifier, count: Option<Expression>,
expression: Expression, item_id: Identifier,
item: Item, collection: Expression,
predicate: Item,
} }
impl AbstractTree for Filter { impl AbstractTree for Filter {
fn from_syntax_node(source: &str, node: Node) -> Result<Self> { fn from_syntax_node(source: &str, node: Node) -> Result<Self> {
let identifier_node = node.child(1).unwrap(); let count = match node.child_by_field_name("count") {
let identifier = Identifier::from_syntax_node(source, identifier_node)?; Some(node) => Some(Expression::from_syntax_node(source, node)?),
None => None,
};
let expression_node = node.child(3).unwrap(); let item_id_node = node.child(1).unwrap();
let expression = Expression::from_syntax_node(source, expression_node)?; let item_id = Identifier::from_syntax_node(source, item_id_node)?;
let item_node = node.child(5).unwrap(); let collection_node = node.child(3).unwrap();
let item = Item::from_syntax_node(source, item_node)?; let collection = Expression::from_syntax_node(source, collection_node)?;
let predicate_node = node.child(5).unwrap();
let predicate = Item::from_syntax_node(source, predicate_node)?;
Ok(Filter { Ok(Filter {
identifier, count,
expression, item_id,
item, collection,
predicate,
}) })
} }
fn run(&self, source: &str, context: &mut Map) -> Result<Value> { fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
let value = self.expression.run(source, context)?; let value = self.collection.run(source, context)?;
let values = value.as_list()?.items(); let values = value.as_list()?.items();
let key = self.identifier.inner(); let key = self.item_id.inner();
let new_values = List::new(); let new_values = List::new();
let count = match &self.count {
Some(expression) => Some(expression.run(source, context)?.as_integer()? as usize),
None => None,
};
values.par_iter().try_for_each(|value| { values.par_iter().try_for_each(|value| {
if let Some(max) = count {
if new_values.items().len() == max {
return Ok(());
}
}
let mut context = Map::new(); let mut context = Map::new();
context.variables_mut().insert(key.clone(), value.clone()); context.variables_mut().insert(key.clone(), value.clone());
let should_include = self.item.run(source, &mut context)?.as_boolean()?; let should_include = self.predicate.run(source, &mut context)?.as_boolean()?;
if should_include { if should_include {
new_values.items_mut().push(value.clone()); new_values.items_mut().push(value.clone());

View File

@ -17,10 +17,9 @@ impl AbstractTree for For {
let for_node = node.child(0).unwrap(); let for_node = node.child(0).unwrap();
let is_async = match for_node.kind() { let is_async = match for_node.kind() {
"for" => false, "for" => false,
"async for" => true,
_ => { _ => {
return Err(Error::UnexpectedSyntaxNode { return Err(Error::UnexpectedSyntaxNode {
expected: "\"for\" or \"async for\"", expected: "for",
actual: for_node.kind(), actual: for_node.kind(),
location: for_node.start_position(), location: for_node.start_position(),
relevant_source: source[for_node.byte_range()].to_string(), relevant_source: source[for_node.byte_range()].to_string(),

View File

@ -59,12 +59,6 @@ fn remove_loop() {
evaluate(&file_contents).unwrap(); evaluate(&file_contents).unwrap();
} }
#[test]
fn scope() {
let file_contents = read_to_string("examples/scope.ds").unwrap();
evaluate(&file_contents).unwrap();
}
#[test] #[test]
fn table() { fn table() {
let file_contents = read_to_string("examples/table.ds").unwrap(); let file_contents = read_to_string("examples/table.ds").unwrap();

View File

@ -10,12 +10,13 @@ async { (output 'Whaddup') }
(item (item
(statement (statement
(async (async
(item
(statement (statement
(expression (expression
(tool (tool
(expression (expression
(value (value
(string)))))))))) (string)))))))))))
================== ==================
Complex Async Statements Complex Async Statements
@ -23,12 +24,12 @@ Complex Async Statements
async { async {
if 1 % 2 == 0 { if 1 % 2 == 0 {
(output 'true') true
} else { } else {
(output 'false') false
} }
(output 'foobar') 'foobar'
} }
--- ---
@ -37,6 +38,7 @@ async {
(item (item
(statement (statement
(async (async
(item
(statement (statement
(if_else (if_else
(if (if
@ -55,109 +57,18 @@ async {
(expression (expression
(value (value
(integer))))) (integer)))))
(item
(statement (statement
(expression
(tool
(expression (expression
(value (value
(string))))))) (boolean))))))
(else (else
(item
(statement (statement
(expression (expression
(tool (value
(boolean))))))))
(statement
(expression (expression
(value (value
(string))))))))) (string)))))))))
(statement
(expression
(tool
(expression
(value
(string))))))))))
==================
Simple Async Await Statements
==================
x = async {
1
}
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(async
(statement
(expression
(value
(integer))))))))))
==================
Complex Async Await Statements
==================
x = async {
i = 0
while i < 5 {
(output i)
i += 1
}
(read "examples/assets/faithful.csv")
}
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(async
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(integer))))))
(statement
(while
(expression
(logic
(expression
(identifier))
(logic_operator)
(expression
(value
(integer)))))
(item
(statement
(expression
(tool
(expression
(identifier)))))
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(integer)))))))))
(statement
(expression
(tool
(expression
(value
(string))))))))))))

View File

@ -14,10 +14,11 @@ if true { "True" }
(expression (expression
(value (value
(boolean))) (boolean)))
(item
(statement (statement
(expression (expression
(value (value
(string))))))))) (string))))))))))
================== ==================
Complex If Complex If
@ -65,10 +66,11 @@ if (1 == 1) && (2 == 2) && (3 == 3) { "True" }
(expression (expression
(value (value
(integer))))))))) (integer)))))))))
(item
(statement (statement
(expression (expression
(value (value
(string))))))))) (string))))))))))
================== ==================
If Assignment If Assignment
@ -90,10 +92,11 @@ x = if true { 1 }
(expression (expression
(value (value
(boolean))) (boolean)))
(item
(statement (statement
(expression (expression
(value (value
(integer))))))))))) (integer))))))))))))
================== ==================
If Else If Else
@ -111,15 +114,17 @@ if false { "True" } else { "False" }
(expression (expression
(value (value
(boolean))) (boolean)))
(item
(statement (statement
(expression (expression
(value (value
(string))))) (string))))))
(else (else
(item
(statement (statement
(expression (expression
(value (value
(string))))))))) (string))))))))))
================== ==================
If Else If If Else If
@ -147,10 +152,11 @@ if 1 == 1 {
(expression (expression
(value (value
(integer))))) (integer)))))
(item
(statement (statement
(expression (expression
(value (value
(string))))) (string))))))
(else_if (else_if
(expression (expression
(logic (logic
@ -161,10 +167,11 @@ if 1 == 1 {
(expression (expression
(value (value
(integer))))) (integer)))))
(item
(statement (statement
(expression (expression
(value (value
(string))))))))) (string))))))))))
================== ==================
If Else Else If Else If Else Else If Else
@ -190,18 +197,20 @@ if false {
(expression (expression
(value (value
(boolean))) (boolean)))
(item
(statement (statement
(expression (expression
(value (value
(string))))) (string))))))
(else_if (else_if
(expression (expression
(value (value
(boolean))) (boolean)))
(item
(statement (statement
(expression (expression
(value (value
(string))))) (string))))))
(else_if (else_if
(expression (expression
(logic (logic
@ -218,12 +227,14 @@ if false {
(expression (expression
(value (value
(integer))))) (integer)))))
(item
(statement (statement
(expression (expression
(value (value
(string))))) (string))))))
(else (else
(item
(statement (statement
(expression (expression
(value (value
(string))))))))) (string))))))))))

View File

@ -33,17 +33,13 @@ for i in [1, 2, 3] {
(identifier)))))))))) (identifier))))))))))
================== ==================
Complex For Loop Nested For Loop
================== ==================
for list in list_of_lists { for list in list_of_lists {
for item in list { for item in list {
(output item) (output item)
} }
if (length list) > 1 {
(output "List is long...")
}
} }
--- ---
@ -66,23 +62,4 @@ for list in list_of_lists {
(expression (expression
(tool (tool
(expression (expression
(identifier)))))))) (identifier)))))))))))))
(statement
(if_else
(if
(expression
(logic
(expression
(tool
(expression
(identifier))))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression
(tool
(expression
(value
(string))))))))))))))

View File

@ -0,0 +1,77 @@
==================
Reduce Loop
==================
reduce i to acc in [1, 2, 3] {
acc += i
}
---
(root
(item
(statement
(reduce
(identifier)
(identifier)
(expression
(value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(identifier))))))))))
==================
Reduce Loop Assignment
==================
together = reduce i to acc in ["one", "two", "three"] {
acc += i
}
---
(root
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(reduce
(identifier)
(identifier)
(expression
(value
(list
(expression
(value
(string)))
(expression
(value
(string)))
(expression
(value
(string))))))
(item
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(expression
(identifier))))))))))))

View File

@ -2,7 +2,7 @@
Remove Loop Remove Loop
================== ==================
remove i in [1, 2, 3] { remove i from [1, 2, 3] {
i <= 2 i <= 2
} }
@ -40,7 +40,7 @@ remove i in [1, 2, 3] {
Remove Loop Assignment Remove Loop Assignment
================== ==================
removed = remove i in ["one", "two", "three"] { removed = remove i from ["one", "two", "three"] {
i == "two" i == "two"
} }

View File

@ -4,24 +4,29 @@ module.exports = grammar({
word: $ => $.identifier, word: $ => $.identifier,
rules: { rules: {
root: $ => repeat1($.item), root: $ => repeat1($.statement),
item: $ => prec.left(repeat1($.statement)),
statement: $ => prec.left(choice( statement: $ => prec.left(choice(
$.comment, repeat1($._statement_kind),
seq('{', $._statement_kind, '}'),
// ))
_statement_kind: $ => prec.left(choice(
$.assignment, $.assignment,
$.expression,
$.if_else,
$.insert,
$.select,
$.while,
$.async, $.async,
$.for, $.comment,
$.transform, $.expression,
$.filter, $.filter,
$.find, $.find,
$.for,
$.if_else,
$.insert,
$.match,
$.reduce,
$.remove, $.remove,
$.select,
$.transform,
$.while,
)), )),
comment: $ => seq(/[#]+.*/), comment: $ => seq(/[#]+.*/),
@ -32,13 +37,13 @@ module.exports = grammar({
), ),
_expression_kind: $ => choice( _expression_kind: $ => choice(
$.value, $.function_call,
$.identifier, $.identifier,
$.index, $.index,
$.math,
$.logic, $.logic,
$.function_call, $.math,
$.tool, $.tool,
$.value,
), ),
identifier: $ => /[_a-zA-Z]+[_a-zA-Z0-9]?/, identifier: $ => /[_a-zA-Z]+[_a-zA-Z0-9]?/,
@ -54,21 +59,19 @@ module.exports = grammar({
$.map, $.map,
), ),
_numeric: $ => token(repeat1( integer: $ => prec.left(token(seq(
optional('-'),
repeat1(
choice('1', '2', '3', '4', '5', '6', '7', '8', '9', '0') choice('1', '2', '3', '4', '5', '6', '7', '8', '9', '0')
)), ),
))),
integer: $ => prec.left(seq( float: $ => prec.left(token(seq(
optional(token.immediate('-')), optional('-'),
$._numeric, repeat1(choice('1', '2', '3', '4', '5', '6', '7', '8', '9', '0')),
)), '.',
repeat1(choice('1', '2', '3', '4', '5', '6', '7', '8', '9', '0')),
float: $ => prec.left(seq( ))),
optional(token.immediate('-')),
$._numeric,
token.immediate('.'),
$._numeric,
)),
string: $ => /("[^"]*?")|('[^']*?')|(`[^`]*?`)/, string: $ => /("[^"]*?")|('[^']*?')|(`[^`]*?`)/,
@ -85,7 +88,7 @@ module.exports = grammar({
map: $ => seq( map: $ => seq(
'{', '{',
repeat(seq($.identifier, "=", $.expression)), $.assignment,
'}', '}',
), ),
@ -103,7 +106,7 @@ module.exports = grammar({
'function', 'function',
optional(seq('<', repeat(seq($.identifier, optional(','))), '>')), optional(seq('<', repeat(seq($.identifier, optional(','))), '>')),
'{', '{',
$.item, $.statement,
'}', '}',
), ),
@ -192,11 +195,23 @@ module.exports = grammar({
')', ')',
)), )),
match: $ => seq(
'match',
$.expression,
'{',
repeat1(seq(
$.expression,
'=>',
$.statement,
)),
'}',
),
while: $ => seq( while: $ => seq(
'while', 'while',
$.expression, $.expression,
'{', '{',
$.item, $.statement,
'}', '}',
), ),
@ -206,7 +221,7 @@ module.exports = grammar({
'in', 'in',
$.expression, $.expression,
'{', '{',
$.item, $.statement,
'}', '}',
), ),
@ -216,17 +231,18 @@ module.exports = grammar({
'in', 'in',
$.expression, $.expression,
'{', '{',
$.item, $.statement,
'}', '}',
), ),
filter: $ => seq( filter: $ => seq(
'filter', 'filter',
$.identifier, field('count', optional($.expression)),
field('statement_id', $.identifier),
'in', 'in',
$.expression, field('collection', $.expression),
'{', '{',
$.item, field('predicate', $.statement),
'}', '}',
), ),
@ -236,17 +252,29 @@ module.exports = grammar({
'in', 'in',
$.expression, $.expression,
'{', '{',
$.item, $.statement,
'}', '}',
), ),
remove: $ => seq( remove: $ => seq(
'remove', 'remove',
$.identifier, $.identifier,
'from',
$.expression,
'{',
$.statement,
'}',
),
reduce: $ => seq(
'reduce',
$.identifier,
'to',
$.identifier,
'in', 'in',
$.expression, $.expression,
'{', '{',
$.item, $.statement,
'}', '}',
), ),
@ -257,7 +285,7 @@ module.exports = grammar({
'>', '>',
'from', 'from',
$.expression, $.expression,
optional(seq('{', $.item, '}')), optional(seq('{', $.statement, '}')),
)), )),
insert: $ => prec.right(seq( insert: $ => prec.right(seq(

View File

@ -3,22 +3,11 @@
"word": "identifier", "word": "identifier",
"rules": { "rules": {
"root": { "root": {
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "item"
}
},
"item": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "REPEAT1", "type": "REPEAT1",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "statement"
} }
}
}, },
"statement": { "statement": {
"type": "PREC_LEFT", "type": "PREC_LEFT",
@ -27,44 +16,53 @@
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "REPEAT1",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "comment" "name": "_statement_kind"
}
}, },
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "_statement_kind"
},
{
"type": "STRING",
"value": "}"
}
]
}
]
}
},
"_statement_kind": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "assignment" "name": "assignment"
}, },
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "if_else"
},
{
"type": "SYMBOL",
"name": "insert"
},
{
"type": "SYMBOL",
"name": "select"
},
{
"type": "SYMBOL",
"name": "while"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "async" "name": "async"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "for" "name": "comment"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "transform" "name": "expression"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -74,9 +72,41 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "find" "name": "find"
}, },
{
"type": "SYMBOL",
"name": "for"
},
{
"type": "SYMBOL",
"name": "if_else"
},
{
"type": "SYMBOL",
"name": "insert"
},
{
"type": "SYMBOL",
"name": "match"
},
{
"type": "SYMBOL",
"name": "reduce"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "remove" "name": "remove"
},
{
"type": "SYMBOL",
"name": "select"
},
{
"type": "SYMBOL",
"name": "transform"
},
{
"type": "SYMBOL",
"name": "while"
} }
] ]
} }
@ -121,7 +151,7 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "value" "name": "function_call"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -131,21 +161,21 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "index" "name": "index"
}, },
{
"type": "SYMBOL",
"name": "math"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "logic" "name": "logic"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "function_call" "name": "math"
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "tool" "name": "tool"
},
{
"type": "SYMBOL",
"name": "value"
} }
] ]
}, },
@ -190,9 +220,27 @@
} }
] ]
}, },
"_numeric": { "integer": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "TOKEN", "type": "TOKEN",
"content": { "content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "-"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1", "type": "REPEAT1",
"content": { "content": {
"type": "CHOICE", "type": "CHOICE",
@ -240,38 +288,15 @@
] ]
} }
} }
},
"integer": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "-"
}
},
{
"type": "BLANK"
}
] ]
},
{
"type": "SYMBOL",
"name": "_numeric"
} }
]
} }
}, },
"float": { "float": {
"type": "PREC_LEFT", "type": "PREC_LEFT",
"value": 0, "value": 0,
"content": {
"type": "TOKEN",
"content": { "content": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -279,11 +304,8 @@
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING", "type": "STRING",
"value": "-" "value": "-"
}
}, },
{ {
"type": "BLANK" "type": "BLANK"
@ -291,23 +313,109 @@
] ]
}, },
{ {
"type": "SYMBOL", "type": "REPEAT1",
"name": "_numeric"
},
{
"type": "IMMEDIATE_TOKEN",
"content": { "content": {
"type": "CHOICE",
"members": [
{
"type": "STRING", "type": "STRING",
"value": "." "value": "1"
}
}, },
{ {
"type": "SYMBOL", "type": "STRING",
"name": "_numeric" "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",
"value": "(\"[^\"]*?\")|('[^']*?')|(`[^`]*?`)" "value": "(\"[^\"]*?\")|('[^']*?')|(`[^`]*?`)"
@ -369,25 +477,9 @@
"type": "STRING", "type": "STRING",
"value": "{" "value": "{"
}, },
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "identifier" "name": "assignment"
},
{
"type": "STRING",
"value": "="
},
{
"type": "SYMBOL",
"name": "expression"
}
]
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -495,7 +587,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "item" "name": "statement"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -852,6 +944,47 @@
] ]
} }
}, },
"match": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "match"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT1",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "=>"
},
{
"type": "SYMBOL",
"name": "statement"
}
]
}
},
{
"type": "STRING",
"value": "}"
}
]
},
"while": { "while": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
@ -869,7 +1002,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "item" "name": "statement"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -902,7 +1035,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "item" "name": "statement"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -935,7 +1068,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "item" "name": "statement"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -951,24 +1084,52 @@
"value": "filter" "value": "filter"
}, },
{ {
"type": "FIELD",
"name": "count",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "FIELD",
"name": "statement_id",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "identifier" "name": "identifier"
}
}, },
{ {
"type": "STRING", "type": "STRING",
"value": "in" "value": "in"
}, },
{ {
"type": "FIELD",
"name": "collection",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "expression" "name": "expression"
}
}, },
{ {
"type": "STRING", "type": "STRING",
"value": "{" "value": "{"
}, },
{ {
"type": "FIELD",
"name": "predicate",
"content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "item" "name": "statement"
}
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1001,7 +1162,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "item" "name": "statement"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1020,6 +1181,47 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "identifier" "name": "identifier"
}, },
{
"type": "STRING",
"value": "from"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "statement"
},
{
"type": "STRING",
"value": "}"
}
]
},
"reduce": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "reduce"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "to"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{ {
"type": "STRING", "type": "STRING",
"value": "in" "value": "in"
@ -1034,7 +1236,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "item" "name": "statement"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1104,7 +1306,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "item" "name": "statement"
}, },
{ {
"type": "STRING", "type": "STRING",

View File

@ -128,24 +128,47 @@
{ {
"type": "filter", "type": "filter",
"named": true, "named": true,
"fields": {}, "fields": {
"children": { "collection": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "expression", "type": "expression",
"named": true "named": true
}
]
}, },
"count": {
"multiple": false,
"required": false,
"types": [
{ {
"type": "identifier", "type": "expression",
"named": true
},
{
"type": "item",
"named": true "named": true
} }
] ]
},
"predicate": {
"multiple": false,
"required": true,
"types": [
{
"type": "statement",
"named": true
}
]
},
"statement_id": {
"multiple": false,
"required": true,
"types": [
{
"type": "identifier",
"named": true
}
]
}
} }
}, },
{ {
@ -165,7 +188,7 @@
"named": true "named": true
}, },
{ {
"type": "item", "type": "statement",
"named": true "named": true
} }
] ]
@ -193,7 +216,7 @@
"named": true "named": true
}, },
{ {
"type": "item", "type": "statement",
"named": true "named": true
} }
] ]
@ -212,7 +235,7 @@
"named": true "named": true
}, },
{ {
"type": "item", "type": "statement",
"named": true "named": true
} }
] ]
@ -318,21 +341,6 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "item",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "statement",
"named": true
}
]
}
},
{ {
"type": "list", "type": "list",
"named": true, "named": true,
@ -376,16 +384,31 @@
"type": "map", "type": "map",
"named": true, "named": true,
"fields": {}, "fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "assignment",
"named": true
}
]
}
},
{
"type": "match",
"named": true,
"fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "expression", "type": "expression",
"named": true "named": true
}, },
{ {
"type": "identifier", "type": "statement",
"named": true "named": true
} }
] ]
@ -415,6 +438,29 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "reduce",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "expression",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "statement",
"named": true
}
]
}
},
{ {
"type": "remove", "type": "remove",
"named": true, "named": true,
@ -432,7 +478,7 @@
"named": true "named": true
}, },
{ {
"type": "item", "type": "statement",
"named": true "named": true
} }
] ]
@ -447,7 +493,7 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "item", "type": "statement",
"named": true "named": true
} }
] ]
@ -470,7 +516,7 @@
"named": true "named": true
}, },
{ {
"type": "item", "type": "statement",
"named": true "named": true
} }
] ]
@ -481,7 +527,7 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": false, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{ {
@ -520,6 +566,14 @@
"type": "insert", "type": "insert",
"named": true "named": true
}, },
{
"type": "match",
"named": true
},
{
"type": "reduce",
"named": true
},
{ {
"type": "remove", "type": "remove",
"named": true "named": true
@ -590,7 +644,7 @@
"named": true "named": true
}, },
{ {
"type": "item", "type": "statement",
"named": true "named": true
} }
] ]
@ -652,7 +706,7 @@
"named": true "named": true
}, },
{ {
"type": "item", "type": "statement",
"named": true "named": true
} }
] ]
@ -702,10 +756,6 @@
"type": "-=", "type": "-=",
"named": false "named": false
}, },
{
"type": ".",
"named": false
},
{ {
"type": "..", "type": "..",
"named": false "named": false
@ -734,6 +784,10 @@
"type": "==", "type": "==",
"named": false "named": false
}, },
{
"type": "=>",
"named": false
},
{ {
"type": ">", "type": ">",
"named": false "named": false
@ -846,6 +900,10 @@
"type": "length", "type": "length",
"named": false "named": false
}, },
{
"type": "match",
"named": false
},
{ {
"type": "metadata", "type": "metadata",
"named": false "named": false
@ -886,6 +944,10 @@
"type": "read", "type": "read",
"named": false "named": false
}, },
{
"type": "reduce",
"named": false
},
{ {
"type": "remove", "type": "remove",
"named": false "named": false
@ -914,6 +976,10 @@
"type": "table", "type": "table",
"named": false "named": false
}, },
{
"type": "to",
"named": false
},
{ {
"type": "to_float", "type": "to_float",
"named": false "named": false

File diff suppressed because it is too large Load Diff