Continue syntax revision
This commit is contained in:
parent
02cded4af4
commit
e582f3cad3
@ -10,7 +10,7 @@ take_turn = function <current_room opponent_card> {
|
||||
|
||||
remove_card = function <opponent_card> {
|
||||
for card_list in cards {
|
||||
removed = remove card from card_list {
|
||||
# removed = remove card from card_list {
|
||||
card == opponent_card
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
list = [1 2 1 3]
|
||||
|
||||
removed = remove i in list {
|
||||
removed = remove i from list {
|
||||
i == 3
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{AbstractTree, Error, Map, Result, Value};
|
||||
|
||||
use super::{identifier::Identifier, statement::Statement};
|
||||
use crate::{AbstractTree, Error, Identifier, Map, Result, Statement, Value};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct Assignment {
|
||||
|
@ -2,14 +2,14 @@ use rayon::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{AbstractTree, Error, Expression, Identifier, Item, List, Map, Result, Value};
|
||||
use crate::{AbstractTree, Error, Expression, Identifier, List, Map, Result, Statement, Value};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct Filter {
|
||||
count: Option<Expression>,
|
||||
item_id: Identifier,
|
||||
collection: Expression,
|
||||
predicate: Item,
|
||||
predicate: Statement,
|
||||
}
|
||||
|
||||
impl AbstractTree for Filter {
|
||||
@ -26,7 +26,7 @@ impl AbstractTree for Filter {
|
||||
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)?;
|
||||
let predicate = Statement::from_syntax_node(source, predicate_node)?;
|
||||
|
||||
Ok(Filter {
|
||||
count,
|
||||
|
@ -1,13 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{AbstractTree, Expression, Identifier, Item, Map, Result, Value};
|
||||
use crate::{AbstractTree, Expression, Identifier, Map, Result, Statement, Value};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct Find {
|
||||
identifier: Identifier,
|
||||
expression: Expression,
|
||||
item: Item,
|
||||
item: Statement,
|
||||
}
|
||||
|
||||
impl AbstractTree for Find {
|
||||
@ -19,7 +19,7 @@ impl AbstractTree for Find {
|
||||
let expression = Expression::from_syntax_node(source, expression_node)?;
|
||||
|
||||
let item_node = node.child(5).unwrap();
|
||||
let item = Item::from_syntax_node(source, item_node)?;
|
||||
let item = Statement::from_syntax_node(source, item_node)?;
|
||||
|
||||
Ok(Find {
|
||||
identifier,
|
||||
|
@ -2,14 +2,14 @@ use rayon::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{AbstractTree, Error, Expression, Identifier, Item, Map, Result, Value};
|
||||
use crate::{AbstractTree, Error, Expression, Identifier, Map, Result, Statement, Value};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct For {
|
||||
is_async: bool,
|
||||
identifier: Identifier,
|
||||
expression: Expression,
|
||||
item: Item,
|
||||
item: Statement,
|
||||
}
|
||||
|
||||
impl AbstractTree for For {
|
||||
@ -34,7 +34,7 @@ impl AbstractTree for For {
|
||||
let expression = Expression::from_syntax_node(source, expression_node)?;
|
||||
|
||||
let item_node = node.child(5).unwrap();
|
||||
let item = Item::from_syntax_node(source, item_node)?;
|
||||
let item = Statement::from_syntax_node(source, item_node)?;
|
||||
|
||||
Ok(For {
|
||||
is_async,
|
||||
|
@ -1,76 +0,0 @@
|
||||
//! Top-level unit of Dust code.
|
||||
|
||||
use rayon::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{AbstractTree, Error, Map, Result, Statement, Value};
|
||||
|
||||
/// An abstractiton of an independent unit of source code, or a comment.
|
||||
///
|
||||
/// Items are either comments, which do nothing, or statements, which can be run
|
||||
/// to produce a single value or interact with a context by creating or
|
||||
/// referencing variables.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct Item {
|
||||
statements: Vec<Statement>,
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn new(statements: Vec<Statement>) -> Self {
|
||||
Self { statements }
|
||||
}
|
||||
|
||||
pub fn run_parallel(&self, source: &str, context: &mut Map) -> Result<Value> {
|
||||
let statements = &self.statements;
|
||||
let run_result = statements.into_par_iter().try_for_each(|statement| {
|
||||
let mut context = context.clone();
|
||||
statement.run(source, &mut context).map(|_| ())
|
||||
});
|
||||
|
||||
match run_result {
|
||||
Ok(()) => Ok(Value::Empty),
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AbstractTree for Item {
|
||||
fn from_syntax_node(source: &str, node: Node) -> Result<Self> {
|
||||
debug_assert_eq!("item", node.kind());
|
||||
|
||||
let child_count = node.child_count();
|
||||
let mut statements = Vec::with_capacity(child_count);
|
||||
|
||||
for index in 0..child_count {
|
||||
let child = node.child(index).unwrap();
|
||||
|
||||
let statement = match child.kind() {
|
||||
"statement" => Statement::from_syntax_node(source, child)?,
|
||||
_ => {
|
||||
return Err(Error::UnexpectedSyntaxNode {
|
||||
expected: "comment or statement",
|
||||
actual: child.kind(),
|
||||
location: child.start_position(),
|
||||
relevant_source: source[child.byte_range()].to_string(),
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
statements.push(statement);
|
||||
}
|
||||
|
||||
Ok(Item { statements })
|
||||
}
|
||||
|
||||
fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
|
||||
let mut prev_result = Ok(Value::Empty);
|
||||
|
||||
for statement in &self.statements {
|
||||
prev_result?;
|
||||
prev_result = statement.run(source, context);
|
||||
}
|
||||
|
||||
prev_result
|
||||
}
|
||||
}
|
@ -17,7 +17,6 @@ pub mod identifier;
|
||||
pub mod if_else;
|
||||
pub mod index;
|
||||
pub mod insert;
|
||||
pub mod item;
|
||||
pub mod logic;
|
||||
pub mod r#match;
|
||||
pub mod math;
|
||||
@ -32,7 +31,7 @@ pub mod r#while;
|
||||
|
||||
pub use {
|
||||
assignment::*, expression::*, filter::*, find::*, function_call::*, identifier::*, if_else::*,
|
||||
index::*, insert::*, item::*, logic::*, math::*, r#async::*, r#for::*, r#match::*, r#while::*,
|
||||
index::*, insert::*, logic::*, math::*, r#async::*, r#for::*, r#match::*, r#while::*,
|
||||
remove::*, select::*, statement::*, sublist::*, tool::*, transform::*, value_node::*,
|
||||
};
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{AbstractTree, Expression, Identifier, Item, Map, Result, Value};
|
||||
use crate::{AbstractTree, Expression, Identifier, Map, Result, Statement, Value};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct Remove {
|
||||
identifier: Identifier,
|
||||
expression: Expression,
|
||||
item: Item,
|
||||
item: Statement,
|
||||
}
|
||||
|
||||
impl AbstractTree for Remove {
|
||||
@ -19,7 +19,7 @@ impl AbstractTree for Remove {
|
||||
let expression = Expression::from_syntax_node(source, expression_node)?;
|
||||
|
||||
let item_node = node.child(5).unwrap();
|
||||
let item = Item::from_syntax_node(source, item_node)?;
|
||||
let item = Statement::from_syntax_node(source, item_node)?;
|
||||
|
||||
Ok(Remove {
|
||||
identifier,
|
||||
|
@ -1,13 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{AbstractTree, Expression, Identifier, Item, Map, Result, Table, Value};
|
||||
use crate::{AbstractTree, Expression, Identifier, Map, Result, Statement, Table, Value};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct Select {
|
||||
identifiers: Vec<Identifier>,
|
||||
expression: Expression,
|
||||
item: Option<Item>,
|
||||
item: Option<Statement>,
|
||||
}
|
||||
|
||||
impl AbstractTree for Select {
|
||||
@ -33,7 +33,7 @@ impl AbstractTree for Select {
|
||||
let item = if final_node.kind() == "}" {
|
||||
let item_node = node.child(child_count - 2).unwrap();
|
||||
|
||||
Some(Item::from_syntax_node(source, item_node)?)
|
||||
Some(Statement::from_syntax_node(source, item_node)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -12,7 +12,6 @@ use crate::{
|
||||
/// Expression, it will always return a non-empty value when run.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub enum Statement {
|
||||
Comment(String),
|
||||
Assignment(Box<Assignment>),
|
||||
Expression(Expression),
|
||||
IfElse(Box<IfElse>),
|
||||
@ -35,12 +34,6 @@ impl AbstractTree for Statement {
|
||||
let child = node.child(0).unwrap();
|
||||
|
||||
match child.kind() {
|
||||
"comment" => {
|
||||
let comment_node = node.child(0).unwrap();
|
||||
let text = &source[comment_node.byte_range()];
|
||||
|
||||
Ok(Statement::Comment(text.to_string()))
|
||||
}
|
||||
"assignment" => Ok(Statement::Assignment(Box::new(
|
||||
Assignment::from_syntax_node(source, child)?,
|
||||
))),
|
||||
@ -81,7 +74,7 @@ impl AbstractTree for Statement {
|
||||
source, child,
|
||||
)?))),
|
||||
_ => Err(Error::UnexpectedSyntaxNode {
|
||||
expected: "comment, assignment, expression, if...else, while, for, transform, filter, tool, async, find, remove, select or insert",
|
||||
expected: "assignment, expression, if...else, while, for, transform, filter, tool, async, find, remove, select or insert",
|
||||
actual: child.kind(),
|
||||
location: child.start_position(),
|
||||
relevant_source: source[child.byte_range()].to_string(),
|
||||
@ -91,7 +84,6 @@ impl AbstractTree for Statement {
|
||||
|
||||
fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
|
||||
match self {
|
||||
Statement::Comment(comment) => Ok(Value::String(comment.clone())),
|
||||
Statement::Assignment(assignment) => assignment.run(source, context),
|
||||
Statement::Expression(expression) => expression.run(source, context),
|
||||
Statement::IfElse(if_else) => if_else.run(source, context),
|
||||
|
@ -71,7 +71,7 @@ impl AbstractTree for Tool {
|
||||
for index in 2..node.child_count() - 1 {
|
||||
let child_node = node.child(index).unwrap();
|
||||
|
||||
if child_node.is_named() {
|
||||
if child_node.kind() == "expression" {
|
||||
let expression = Expression::from_syntax_node(source, child_node)?;
|
||||
|
||||
expressions.push(expression);
|
||||
|
@ -2,13 +2,13 @@ use rayon::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{AbstractTree, Expression, Identifier, Item, List, Map, Result, Value};
|
||||
use crate::{AbstractTree, Expression, Identifier, List, Map, Result, Statement, Value};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct Transform {
|
||||
identifier: Identifier,
|
||||
expression: Expression,
|
||||
item: Item,
|
||||
item: Statement,
|
||||
}
|
||||
|
||||
impl AbstractTree for Transform {
|
||||
@ -20,7 +20,7 @@ impl AbstractTree for Transform {
|
||||
let expression = Expression::from_syntax_node(source, expression_node)?;
|
||||
|
||||
let item_node = node.child(5).unwrap();
|
||||
let item = Item::from_syntax_node(source, item_node)?;
|
||||
let item = Statement::from_syntax_node(source, item_node)?;
|
||||
|
||||
Ok(Transform {
|
||||
identifier,
|
||||
|
@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{
|
||||
AbstractTree, Error, Expression, Function, Identifier, Item, List, Map, Result, Table, Value,
|
||||
ValueType,
|
||||
AbstractTree, Error, Expression, Function, Identifier, List, Map, Result, Statement, Table,
|
||||
Value, ValueType,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
@ -102,7 +102,7 @@ impl AbstractTree for ValueNode {
|
||||
let mut identifiers = Vec::new();
|
||||
|
||||
let item_node = child.child(child.child_count() - 2).unwrap();
|
||||
let item = Item::from_syntax_node(source, item_node)?;
|
||||
let item = Statement::from_syntax_node(source, item_node)?;
|
||||
|
||||
for index in 1..child.child_count() - 3 {
|
||||
let child_node = child.child(index).unwrap();
|
||||
|
@ -1,12 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tree_sitter::Node;
|
||||
|
||||
use crate::{AbstractTree, Expression, Item, Map, Result, Value};
|
||||
use crate::{AbstractTree, Expression, Map, Result, Statement, Value};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct While {
|
||||
expression: Expression,
|
||||
items: Vec<Item>,
|
||||
statement: Statement,
|
||||
}
|
||||
|
||||
impl AbstractTree for While {
|
||||
@ -16,27 +16,21 @@ impl AbstractTree for While {
|
||||
let expression_node = node.child(1).unwrap();
|
||||
let expression = Expression::from_syntax_node(source, expression_node)?;
|
||||
|
||||
let child_count = node.child_count();
|
||||
let mut items = Vec::with_capacity(child_count);
|
||||
let statement_node = node.child(3).unwrap();
|
||||
let statement = Statement::from_syntax_node(source, statement_node)?;
|
||||
|
||||
for index in 3..child_count - 1 {
|
||||
let item_node = node.child(index).unwrap();
|
||||
let item = Item::from_syntax_node(source, item_node)?;
|
||||
|
||||
items.push(item);
|
||||
}
|
||||
|
||||
Ok(While { expression, items })
|
||||
Ok(While {
|
||||
expression,
|
||||
statement,
|
||||
})
|
||||
}
|
||||
|
||||
fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
|
||||
while self.expression.run(source, context)?.as_boolean()? {
|
||||
for item in &self.items {
|
||||
item.run(source, context)?;
|
||||
}
|
||||
self.statement.run(source, context)?;
|
||||
}
|
||||
|
||||
Ok(crate::Value::Empty)
|
||||
Ok(Value::Empty)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ use std::fmt::{self, Debug, Formatter};
|
||||
|
||||
use tree_sitter::{Parser, Tree as TSTree};
|
||||
|
||||
use crate::{abstract_tree::item::Item, language, AbstractTree, Map, Result, Value};
|
||||
use crate::{language, AbstractTree, Map, Result, Statement, Value};
|
||||
|
||||
/// Evaluate the given source code.
|
||||
///
|
||||
@ -86,7 +86,7 @@ impl<'context, 'code> Evaluator<'context, 'code> {
|
||||
let mut prev_result = Ok(Value::Empty);
|
||||
|
||||
for item_node in root_node.children(&mut cursor) {
|
||||
let item = Item::from_syntax_node(self.source, item_node)?;
|
||||
let item = Statement::from_syntax_node(self.source, item_node)?;
|
||||
prev_result = item.run(self.source, self.context);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//! Command line interface for the dust programming language.
|
||||
use async_std::{fs::read_to_string, prelude::*};
|
||||
use async_std::fs::read_to_string;
|
||||
use clap::Parser;
|
||||
use rustyline::{
|
||||
completion::FilenameCompleter,
|
||||
|
@ -2,19 +2,19 @@ use std::fmt::{self, Display, Formatter};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{Identifier, Item};
|
||||
use crate::{Identifier, Statement};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct Function {
|
||||
parameters: Vec<Identifier>,
|
||||
body: Item,
|
||||
body: Box<Statement>,
|
||||
}
|
||||
|
||||
impl Function {
|
||||
pub fn new(identifiers: Vec<Identifier>, items: Item) -> Self {
|
||||
pub fn new(identifiers: Vec<Identifier>, items: Statement) -> Self {
|
||||
Function {
|
||||
parameters: identifiers,
|
||||
body: items,
|
||||
body: Box::new(items),
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ impl Function {
|
||||
&self.parameters
|
||||
}
|
||||
|
||||
pub fn body(&self) -> &Item {
|
||||
pub fn body(&self) -> &Statement {
|
||||
&self.body
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,16 @@ async { (output 'Whaddup') }
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(async
|
||||
(statement
|
||||
(expression
|
||||
(tool
|
||||
(block
|
||||
(statement
|
||||
(async
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(tool
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
|
||||
==================
|
||||
Complex Async Statements
|
||||
@ -33,35 +35,40 @@ async {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(async
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(block
|
||||
(statement
|
||||
(async
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(math
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))
|
||||
(else
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
|
@ -8,9 +8,10 @@ not_a_comment
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(comment))
|
||||
|
||||
==================
|
||||
@ -22,10 +23,11 @@ not_a_comment # comment
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(comment))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(comment))
|
||||
|
||||
==================
|
||||
Multiline Comments
|
||||
@ -39,12 +41,13 @@ not_a_comment #
|
||||
|
||||
(root
|
||||
(comment)
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(comment)
|
||||
(comment)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(comment)
|
||||
(comment)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
|
@ -9,30 +9,32 @@ filter i in [1, 2, 3] {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(filter
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(filter
|
||||
(identifier)
|
||||
(expression
|
||||
(logic
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
|
||||
==================
|
||||
Nested Filter Loop
|
||||
@ -47,22 +49,25 @@ filter i in big_list {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(filter
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(statement
|
||||
(filter
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(filter
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
(filter
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))))
|
||||
|
@ -9,30 +9,32 @@ find i in [1, 2, 3] {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(find
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(find
|
||||
(identifier)
|
||||
(expression
|
||||
(logic
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
|
||||
==================
|
||||
Nested Find Loop
|
||||
@ -54,57 +56,63 @@ find i in ["one", "two", "three"] {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(find
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(find
|
||||
(identifier)
|
||||
(block
|
||||
(statement
|
||||
(find
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(identifier))
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(find
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(tool
|
||||
(expression
|
||||
(identifier))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(tool
|
||||
(string)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))
|
||||
(else
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))))
|
||||
(value
|
||||
(boolean))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))))))))))
|
||||
|
@ -9,26 +9,28 @@ for i in [1, 2, 3] {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(tool
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))))))
|
||||
(tool
|
||||
(expression
|
||||
(identifier))))))))))
|
||||
|
||||
==================
|
||||
Nested For Loop
|
||||
@ -43,18 +45,21 @@ for list in list_of_lists {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(statement
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(tool
|
||||
(expression
|
||||
(identifier))))))))))
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(tool
|
||||
(expression
|
||||
(identifier)))))))))))))
|
||||
|
@ -7,15 +7,17 @@ function { "Hiya" }
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
|
||||
==================
|
||||
Function Call
|
||||
==================
|
||||
@ -25,13 +27,14 @@ Function Call
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
|
||||
==================
|
||||
Complex Function
|
||||
@ -45,21 +48,24 @@ function <message number> {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(identifier)
|
||||
(identifier)
|
||||
(statement
|
||||
(expression
|
||||
(tool
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(identifier)
|
||||
(identifier)
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(expression
|
||||
(tool
|
||||
(tool
|
||||
(expression
|
||||
(identifier)))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))))))))
|
||||
(tool
|
||||
(expression
|
||||
(identifier))))))))))))
|
||||
|
||||
==================
|
||||
Complex Function Call
|
||||
@ -77,24 +83,25 @@ Complex Function Call
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
|
@ -9,12 +9,13 @@ __xyz__
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
@ -7,16 +7,18 @@ if true { "True" }
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
|
||||
==================
|
||||
Complex If
|
||||
@ -27,46 +29,48 @@ 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
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
(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)))))))))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
|
||||
==================
|
||||
Nested If
|
||||
@ -83,33 +87,37 @@ if true {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(else
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))))
|
||||
|
||||
==================
|
||||
If Else
|
||||
@ -120,21 +128,24 @@ if false { "True" } else { "False" }
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(else
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
|
||||
==================
|
||||
If Else If
|
||||
@ -149,36 +160,39 @@ if 1 == 1 {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(else_if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else_if
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
|
||||
==================
|
||||
If Else Else If Else
|
||||
@ -197,46 +211,51 @@ if false {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(else_if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(statement
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else_if
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(else_if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else_if
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(else
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
|
@ -11,38 +11,39 @@ foobar:1:42
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(expression
|
||||
(index
|
||||
(expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(expression
|
||||
(identifier)))))
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier)))))
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(expression
|
||||
(identifier))
|
||||
(index
|
||||
(expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(expression
|
||||
(identifier)))))
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier)))))
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(expression
|
||||
(index
|
||||
(expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(integer))))))))
|
||||
|
||||
==================
|
||||
Nested Indexes
|
||||
@ -53,40 +54,41 @@ Nested Indexes
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(expression
|
||||
(index
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(index
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))
|
@ -7,16 +7,17 @@ List Declaration
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
|
||||
==================
|
||||
List Nesting
|
||||
@ -27,22 +28,23 @@ List Nesting
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))))))
|
||||
|
@ -7,14 +7,15 @@ Simple Map
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
|
||||
==================
|
||||
Nested Maps
|
||||
@ -33,31 +34,32 @@ x = {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
|
@ -1,5 +1,5 @@
|
||||
==================
|
||||
Equality
|
||||
\==
|
||||
==================
|
||||
|
||||
3 == 1 + 1 + 1
|
||||
@ -7,28 +7,29 @@ Equality
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))
|
||||
|
||||
==================
|
||||
&&
|
||||
@ -39,28 +40,29 @@ Equality
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))))
|
||||
|
||||
==================
|
||||
\||
|
||||
@ -71,25 +73,26 @@ Equality
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))))
|
||||
|
@ -9,29 +9,31 @@ reduce i to acc in [1, 2, 3] {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(reduce
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(block
|
||||
(statement
|
||||
(reduce
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))))))
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))))))))
|
||||
|
||||
==================
|
||||
Nested Reduce Loop
|
||||
@ -44,26 +46,28 @@ reduce i to acc in ["one", "two", "three"] {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(reduce
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(block
|
||||
(statement
|
||||
(reduce
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))))))
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))))))))
|
||||
|
@ -9,30 +9,32 @@ remove i from [1, 2, 3] {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(remove
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(remove
|
||||
(identifier)
|
||||
(expression
|
||||
(logic
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
|
||||
==================
|
||||
Nested Remove
|
||||
@ -47,26 +49,29 @@ removed = remove i from big_list {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(remove
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(statement
|
||||
(remove
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(remove
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))))
|
||||
(remove
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))))))
|
||||
|
@ -9,17 +9,18 @@ x
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
||||
==================
|
||||
Simple Assignment
|
||||
@ -31,22 +32,23 @@ y = "one"
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
|
||||
==================
|
||||
Complex Assignment
|
||||
@ -61,37 +63,40 @@ x = if 1 + 1 == 2 {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(else
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))
|
||||
|
||||
==================
|
||||
Expression Precedence
|
||||
@ -102,29 +107,30 @@ x = 3 == 1 + 2 + 2
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))
|
||||
|
@ -11,42 +11,44 @@ table <messages, numbers> [
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(table
|
||||
(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))))))))))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(table
|
||||
(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 Access
|
||||
==================
|
||||
@ -58,20 +60,22 @@ select <number> from foobar {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(select
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(select
|
||||
(identifier)
|
||||
(expression
|
||||
(logic
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
|
||||
==================
|
||||
Table Insert
|
||||
@ -84,18 +88,19 @@ insert into foobar [
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(insert
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))
|
||||
(block
|
||||
(statement
|
||||
(insert
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))))
|
||||
|
35
tree-sitter-dust/corpus/tool.txt
Normal file
35
tree-sitter-dust/corpus/tool.txt
Normal file
@ -0,0 +1,35 @@
|
||||
==================
|
||||
Simple Tool Call
|
||||
==================
|
||||
|
||||
(output 'hi')
|
||||
|
||||
---
|
||||
|
||||
(root
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(tool
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
|
||||
==================
|
||||
Nested Tool Call
|
||||
==================
|
||||
|
||||
(assert_equal random_integer, 4)
|
||||
|
||||
---
|
||||
|
||||
(root
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(tool
|
||||
(expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))
|
@ -9,26 +9,28 @@ transform i in [1, 2, 3] {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(transform
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(transform
|
||||
(identifier)
|
||||
(expression
|
||||
(tool
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))))))
|
||||
(tool
|
||||
(expression
|
||||
(identifier))))))))))
|
||||
|
||||
==================
|
||||
Nested Transform Loop
|
||||
@ -43,40 +45,43 @@ transform i in [['one'] ['two'] ['three']] {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(transform
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(statement
|
||||
(transform
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(transform
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(transform
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))))
|
||||
|
@ -8,14 +8,15 @@ false
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))
|
||||
|
||||
==================
|
||||
Integers
|
||||
@ -27,26 +28,27 @@ Integers
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
|
||||
==================
|
||||
Strings
|
||||
@ -57,6 +59,7 @@ Strings
|
||||
---
|
||||
|
||||
(root
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
@ -76,4 +79,4 @@ Strings
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(string))))))
|
@ -9,25 +9,26 @@ while true {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(while
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(while
|
||||
(expression
|
||||
(tool
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(tool
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
|
||||
==================
|
||||
Nested While Loop
|
||||
==================
|
||||
|
||||
while true {
|
||||
x = 4
|
||||
while x > 0 {
|
||||
while (true) {
|
||||
while (x > 0) {
|
||||
x -= 1
|
||||
}
|
||||
}
|
||||
@ -35,33 +36,29 @@ while true {
|
||||
---
|
||||
|
||||
(root
|
||||
(statement
|
||||
(while
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(block
|
||||
(statement
|
||||
(while
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(while
|
||||
(expression
|
||||
(logic
|
||||
(while
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))))
|
@ -6,16 +6,16 @@ module.exports = grammar({
|
||||
extras: $ => [ /\s/, $.comment ],
|
||||
|
||||
rules: {
|
||||
root: $ => repeat1($.statement),
|
||||
root: $ => repeat1($.block),
|
||||
|
||||
comment: $ => /[#][^#\n]*[#|\n]/,
|
||||
|
||||
statement: $ => prec.left(choice(
|
||||
repeat1($._statement_kind),
|
||||
seq('{', repeat1($._statement_kind), '}'),
|
||||
block: $ => prec.right(choice(
|
||||
repeat1($.statement),
|
||||
seq('{', repeat1($.statement), '}'),
|
||||
)),
|
||||
|
||||
_statement_kind: $ => prec.left(choice(
|
||||
statement: $ => prec.left(choice(
|
||||
$.assignment,
|
||||
$.async,
|
||||
$.expression,
|
||||
@ -37,7 +37,7 @@ module.exports = grammar({
|
||||
seq('(', $._expression_kind, ')'),
|
||||
),
|
||||
|
||||
_expression_kind: $ => prec.right(choice(
|
||||
_expression_kind: $ => prec.left(choice(
|
||||
$.function_call,
|
||||
$.identifier,
|
||||
$.index,
|
||||
@ -89,12 +89,12 @@ module.exports = grammar({
|
||||
|
||||
map: $ => seq(
|
||||
'{',
|
||||
repeat(seq(
|
||||
repeat(prec(1, seq(
|
||||
$.identifier,
|
||||
'=',
|
||||
$.expression,
|
||||
optional(',')
|
||||
)),
|
||||
))),
|
||||
'}',
|
||||
),
|
||||
|
||||
@ -111,9 +111,7 @@ module.exports = grammar({
|
||||
function: $ => seq(
|
||||
'function',
|
||||
optional(seq('<', repeat(seq($.identifier, optional(','))), '>')),
|
||||
'{',
|
||||
$.statement,
|
||||
'}',
|
||||
$.block,
|
||||
),
|
||||
|
||||
table: $ => prec.left(seq(
|
||||
@ -128,13 +126,13 @@ module.exports = grammar({
|
||||
$.expression,
|
||||
)),
|
||||
|
||||
math_operator: $ => token(choice(
|
||||
math_operator: $ => choice(
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'%',
|
||||
)),
|
||||
),
|
||||
|
||||
logic: $ => prec.right(seq(
|
||||
$.expression,
|
||||
@ -142,7 +140,7 @@ module.exports = grammar({
|
||||
$.expression,
|
||||
)),
|
||||
|
||||
logic_operator: $ => token(choice(
|
||||
logic_operator: $ => choice(
|
||||
'==',
|
||||
'!=',
|
||||
'&&',
|
||||
@ -151,19 +149,19 @@ module.exports = grammar({
|
||||
'<',
|
||||
">=",
|
||||
"<=",
|
||||
)),
|
||||
),
|
||||
|
||||
assignment: $ => prec.right(seq(
|
||||
assignment: $ => seq(
|
||||
$.identifier,
|
||||
$.assignment_operator,
|
||||
$.statement,
|
||||
)),
|
||||
),
|
||||
|
||||
assignment_operator: $ => token(choice(
|
||||
assignment_operator: $ => choice(
|
||||
"=",
|
||||
"+=",
|
||||
"-=",
|
||||
)),
|
||||
),
|
||||
|
||||
if_else: $ => prec.left(seq(
|
||||
$.if,
|
||||
@ -175,7 +173,7 @@ module.exports = grammar({
|
||||
'if',
|
||||
$.expression,
|
||||
'{',
|
||||
$.statement,
|
||||
$.block,
|
||||
'}',
|
||||
),
|
||||
|
||||
@ -183,14 +181,14 @@ module.exports = grammar({
|
||||
'else if',
|
||||
$.expression,
|
||||
'{',
|
||||
$.statement,
|
||||
$.block,
|
||||
'}',
|
||||
),
|
||||
|
||||
else: $ => seq(
|
||||
'else',
|
||||
'{',
|
||||
$.statement,
|
||||
$.block,
|
||||
'}',
|
||||
),
|
||||
|
||||
@ -208,7 +206,7 @@ module.exports = grammar({
|
||||
repeat1(seq(
|
||||
$.expression,
|
||||
'=>',
|
||||
$.statement,
|
||||
$.block,
|
||||
)),
|
||||
'}',
|
||||
),
|
||||
@ -216,9 +214,7 @@ module.exports = grammar({
|
||||
while: $ => seq(
|
||||
'while',
|
||||
$.expression,
|
||||
'{',
|
||||
$.statement,
|
||||
'}',
|
||||
$.block,
|
||||
),
|
||||
|
||||
for: $ => seq(
|
||||
@ -226,9 +222,7 @@ module.exports = grammar({
|
||||
$.identifier,
|
||||
'in',
|
||||
$.expression,
|
||||
'{',
|
||||
$.statement,
|
||||
'}',
|
||||
$.block,
|
||||
),
|
||||
|
||||
transform: $ => seq(
|
||||
@ -236,9 +230,7 @@ module.exports = grammar({
|
||||
$.identifier,
|
||||
'in',
|
||||
$.expression,
|
||||
'{',
|
||||
$.statement,
|
||||
'}',
|
||||
$.block,
|
||||
),
|
||||
|
||||
filter: $ => seq(
|
||||
@ -247,9 +239,7 @@ module.exports = grammar({
|
||||
field('statement_id', $.identifier),
|
||||
'in',
|
||||
field('collection', $.expression),
|
||||
'{',
|
||||
field('predicate', $.statement),
|
||||
'}',
|
||||
field('predicate', $.block),
|
||||
),
|
||||
|
||||
find: $ => seq(
|
||||
@ -257,9 +247,7 @@ module.exports = grammar({
|
||||
$.identifier,
|
||||
'in',
|
||||
$.expression,
|
||||
'{',
|
||||
$.statement,
|
||||
'}',
|
||||
$.block,
|
||||
),
|
||||
|
||||
remove: $ => seq(
|
||||
@ -267,9 +255,7 @@ module.exports = grammar({
|
||||
$.identifier,
|
||||
'from',
|
||||
$.expression,
|
||||
'{',
|
||||
$.statement,
|
||||
'}',
|
||||
$.block,
|
||||
),
|
||||
|
||||
reduce: $ => seq(
|
||||
@ -279,9 +265,7 @@ module.exports = grammar({
|
||||
$.identifier,
|
||||
'in',
|
||||
$.expression,
|
||||
'{',
|
||||
$.statement,
|
||||
'}',
|
||||
$.block,
|
||||
),
|
||||
|
||||
select: $ => prec.right(seq(
|
||||
@ -291,7 +275,7 @@ module.exports = grammar({
|
||||
'>',
|
||||
'from',
|
||||
$.expression,
|
||||
optional(seq('{', $.statement, '}')),
|
||||
optional($.block),
|
||||
)),
|
||||
|
||||
insert: $ => prec.right(seq(
|
||||
@ -303,15 +287,15 @@ module.exports = grammar({
|
||||
|
||||
async: $ => seq(
|
||||
'async',
|
||||
'{',
|
||||
$.statement,
|
||||
'}'
|
||||
$.block,
|
||||
),
|
||||
|
||||
tool: $ => prec.right(seq(
|
||||
tool: $ => seq(
|
||||
'(',
|
||||
$._tool_kind,
|
||||
repeat(prec.left(seq($.expression, optional(',')))),
|
||||
)),
|
||||
repeat(seq($.expression, optional(','))),
|
||||
')',
|
||||
),
|
||||
|
||||
_tool_kind: $ => choice(
|
||||
// General
|
||||
|
@ -6,15 +6,15 @@
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
"name": "block"
|
||||
}
|
||||
},
|
||||
"comment": {
|
||||
"type": "PATTERN",
|
||||
"value": "[#][^#\\n]*[#|\\n]"
|
||||
},
|
||||
"statement": {
|
||||
"type": "PREC_LEFT",
|
||||
"block": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
@ -23,7 +23,7 @@
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_statement_kind"
|
||||
"name": "statement"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -37,7 +37,7 @@
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_statement_kind"
|
||||
"name": "statement"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -49,7 +49,7 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"_statement_kind": {
|
||||
"statement": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
@ -141,7 +141,7 @@
|
||||
]
|
||||
},
|
||||
"_expression_kind": {
|
||||
"type": "PREC_RIGHT",
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
@ -482,33 +482,37 @@
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"type": "PREC",
|
||||
"value": 1,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -611,17 +615,9 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -701,32 +697,29 @@
|
||||
}
|
||||
},
|
||||
"math_operator": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "+"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "-"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "*"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "/"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "%"
|
||||
}
|
||||
]
|
||||
}
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "+"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "-"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "*"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "/"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "%"
|
||||
}
|
||||
]
|
||||
},
|
||||
"logic": {
|
||||
"type": "PREC_RIGHT",
|
||||
@ -750,85 +743,75 @@
|
||||
}
|
||||
},
|
||||
"logic_operator": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"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": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"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": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "assignment_operator"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
}
|
||||
]
|
||||
}
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "assignment_operator"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
}
|
||||
]
|
||||
},
|
||||
"assignment_operator": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "+="
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "-="
|
||||
}
|
||||
]
|
||||
}
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "="
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "+="
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "-="
|
||||
}
|
||||
]
|
||||
},
|
||||
"if_else": {
|
||||
"type": "PREC_LEFT",
|
||||
@ -884,7 +867,7 @@
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
"name": "block"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
@ -909,7 +892,7 @@
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
"name": "block"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
@ -930,7 +913,7 @@
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
"name": "block"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
@ -1013,7 +996,7 @@
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1035,17 +1018,9 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1068,17 +1043,9 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1101,17 +1068,9 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1158,21 +1117,13 @@
|
||||
"name": "expression"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "predicate",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
"name": "block"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1195,17 +1146,9 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1228,17 +1171,9 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1269,17 +1204,9 @@
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1337,21 +1264,8 @@
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "block"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
@ -1393,60 +1307,52 @@
|
||||
"type": "STRING",
|
||||
"value": "async"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
"name": "block"
|
||||
}
|
||||
]
|
||||
},
|
||||
"tool": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_tool_kind"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_tool_kind"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_tool_kind": {
|
||||
"type": "CHOICE",
|
||||
|
@ -22,6 +22,11 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "assignment_operator",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "async",
|
||||
"named": true,
|
||||
@ -29,6 +34,21 @@
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "block",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "statement",
|
||||
@ -51,7 +71,7 @@
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "statement",
|
||||
"type": "block",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
@ -66,11 +86,11 @@
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"type": "expression",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
@ -144,7 +164,7 @@
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "statement",
|
||||
"type": "block",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
@ -169,6 +189,10 @@
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
@ -176,10 +200,6 @@
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -197,6 +217,10 @@
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
@ -204,10 +228,6 @@
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -221,11 +241,11 @@
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
@ -259,11 +279,11 @@
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"type": "expression",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
@ -365,6 +385,11 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "logic_operator",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "map",
|
||||
"named": true,
|
||||
@ -393,11 +418,11 @@
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"type": "expression",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
@ -422,6 +447,11 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "math_operator",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "reduce",
|
||||
"named": true,
|
||||
@ -430,6 +460,10 @@
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
@ -437,10 +471,6 @@
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -453,6 +483,10 @@
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
@ -460,10 +494,6 @@
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -477,7 +507,7 @@
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "statement",
|
||||
"type": "block",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
@ -491,6 +521,10 @@
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
@ -498,10 +532,6 @@
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -511,7 +541,7 @@
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
@ -615,6 +645,10 @@
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
@ -622,10 +656,6 @@
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -682,16 +712,28 @@
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"type": "block",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "statement",
|
||||
"type": "expression",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "!=",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "%",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "&&",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "(",
|
||||
"named": false
|
||||
@ -700,14 +742,38 @@
|
||||
"type": ")",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "*",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "+",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "+=",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ",",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "-",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "-=",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "..",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "/",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ":",
|
||||
"named": false
|
||||
@ -716,10 +782,18 @@
|
||||
"type": "<",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "<=",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "=",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "==",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "=>",
|
||||
"named": false
|
||||
@ -728,6 +802,10 @@
|
||||
"type": ">",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": ">=",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "[",
|
||||
"named": false
|
||||
@ -748,10 +826,6 @@
|
||||
"type": "assert_equal",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "assignment_operator",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "async",
|
||||
"named": false
|
||||
@ -840,18 +914,10 @@
|
||||
"type": "length",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "logic_operator",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "match",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "math_operator",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "metadata",
|
||||
"named": false
|
||||
@ -972,6 +1038,10 @@
|
||||
"type": "{",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "||",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "}",
|
||||
"named": false
|
||||
|
File diff suppressed because it is too large
Load Diff
14
tree-sitter-dust/test_output.md
Normal file
14
tree-sitter-dust/test_output.md
Normal file
@ -0,0 +1,14 @@
|
||||
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|
||||
|:---|---:|---:|---:|---:|
|
||||
| `dust -c '(length (from_json input))' -p seaCreatures.json` | 2.9 ± 0.4 | 2.5 | 6.7 | 1.00 |
|
||||
| `jq 'length' seaCreatures.json` | 36.7 ± 4.4 | 34.7 | 65.0 | 12.59 ± 2.14 |
|
||||
| `node --eval "require('node:fs').readFile('seaCreatures.json', (err, data)=>{console.log(JSON.parse(data).length)})"` | 241.2 ± 13.3 | 227.7 | 273.2 | 82.63 ± 11.00 |
|
||||
| `nu -c 'open seaCreatures.json \| length'` | 54.0 ± 3.3 | 50.3 | 69.2 | 18.49 ± 2.51 |
|
||||
| `dust -c '(length (from_json input))' -p jq_data.json` | 7.9 ± 0.8 | 6.6 | 12.5 | 2.70 ± 0.43 |
|
||||
| `jq 'length' jq_data.json` | 44.8 ± 0.6 | 43.5 | 47.3 | 15.36 ± 1.87 |
|
||||
| `node --eval "require('node:fs').readFile('jq_data.json', (err, data)=>{console.log(JSON.parse(data).length)})"` | 245.2 ± 7.1 | 235.4 | 259.7 | 84.00 ± 10.46 |
|
||||
| `nu -c 'open jq_data.json \| length'` | 65.9 ± 5.0 | 62.0 | 90.5 | 22.57 ± 3.22 |
|
||||
| `dust -c '(length (from_json input))' -p dielectron.json` | 1079.5 ± 22.7 | 1043.8 | 1121.5 | 369.86 ± 45.46 |
|
||||
| `jq 'length' dielectron.json` | 1365.0 ± 20.3 | 1318.5 | 1400.1 | 467.67 ± 57.07 |
|
||||
| `node --eval "require('node:fs').readFile('dielectron.json', (err, data)=>{console.log(JSON.parse(data).length)})"` | 1910.8 ± 47.9 | 1855.9 | 1985.7 | 654.66 ± 80.97 |
|
||||
| `nu -c 'open dielectron.json \| length'` | 2001.2 ± 65.1 | 1923.2 | 2112.7 | 685.65 ± 85.98 |
|
Loading…
Reference in New Issue
Block a user