1
0

Continue syntax revision

This commit is contained in:
Jeff 2023-10-31 09:31:10 -04:00
parent 02cded4af4
commit e582f3cad3
43 changed files with 15958 additions and 14195 deletions

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 from card_list { # removed = remove card from card_list {
card == opponent_card card == opponent_card
} }
} }

View File

@ -1,6 +1,6 @@
list = [1 2 1 3] list = [1 2 1 3]
removed = remove i in list { removed = remove i from list {
i == 3 i == 3
} }

View File

@ -1,9 +1,7 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tree_sitter::Node; use tree_sitter::Node;
use crate::{AbstractTree, Error, Map, Result, Value}; use crate::{AbstractTree, Error, Identifier, Map, Result, Statement, Value};
use super::{identifier::Identifier, statement::Statement};
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Assignment { pub struct Assignment {

View File

@ -2,14 +2,14 @@ use rayon::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tree_sitter::Node; 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)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Filter { pub struct Filter {
count: Option<Expression>, count: Option<Expression>,
item_id: Identifier, item_id: Identifier,
collection: Expression, collection: Expression,
predicate: Item, predicate: Statement,
} }
impl AbstractTree for Filter { impl AbstractTree for Filter {
@ -26,7 +26,7 @@ impl AbstractTree for Filter {
let collection = Expression::from_syntax_node(source, collection_node)?; let collection = Expression::from_syntax_node(source, collection_node)?;
let predicate_node = node.child(5).unwrap(); 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 { Ok(Filter {
count, count,

View File

@ -1,13 +1,13 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tree_sitter::Node; 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)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Find { pub struct Find {
identifier: Identifier, identifier: Identifier,
expression: Expression, expression: Expression,
item: Item, item: Statement,
} }
impl AbstractTree for Find { impl AbstractTree for Find {
@ -19,7 +19,7 @@ impl AbstractTree for Find {
let expression = Expression::from_syntax_node(source, expression_node)?; let expression = Expression::from_syntax_node(source, expression_node)?;
let item_node = node.child(5).unwrap(); 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 { Ok(Find {
identifier, identifier,

View File

@ -2,14 +2,14 @@ use rayon::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tree_sitter::Node; 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)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct For { pub struct For {
is_async: bool, is_async: bool,
identifier: Identifier, identifier: Identifier,
expression: Expression, expression: Expression,
item: Item, item: Statement,
} }
impl AbstractTree for For { impl AbstractTree for For {
@ -34,7 +34,7 @@ impl AbstractTree for For {
let expression = Expression::from_syntax_node(source, expression_node)?; let expression = Expression::from_syntax_node(source, expression_node)?;
let item_node = node.child(5).unwrap(); 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 { Ok(For {
is_async, is_async,

View File

@ -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
}
}

View File

@ -17,7 +17,6 @@ pub mod identifier;
pub mod if_else; pub mod if_else;
pub mod index; pub mod index;
pub mod insert; pub mod insert;
pub mod item;
pub mod logic; pub mod logic;
pub mod r#match; pub mod r#match;
pub mod math; pub mod math;
@ -32,7 +31,7 @@ pub mod r#while;
pub use { pub use {
assignment::*, expression::*, filter::*, find::*, function_call::*, identifier::*, if_else::*, 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::*, remove::*, select::*, statement::*, sublist::*, tool::*, transform::*, value_node::*,
}; };

View File

@ -1,13 +1,13 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tree_sitter::Node; 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)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Remove { pub struct Remove {
identifier: Identifier, identifier: Identifier,
expression: Expression, expression: Expression,
item: Item, item: Statement,
} }
impl AbstractTree for Remove { impl AbstractTree for Remove {
@ -19,7 +19,7 @@ impl AbstractTree for Remove {
let expression = Expression::from_syntax_node(source, expression_node)?; let expression = Expression::from_syntax_node(source, expression_node)?;
let item_node = node.child(5).unwrap(); 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 { Ok(Remove {
identifier, identifier,

View File

@ -1,13 +1,13 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tree_sitter::Node; 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)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Select { pub struct Select {
identifiers: Vec<Identifier>, identifiers: Vec<Identifier>,
expression: Expression, expression: Expression,
item: Option<Item>, item: Option<Statement>,
} }
impl AbstractTree for Select { impl AbstractTree for Select {
@ -33,7 +33,7 @@ impl AbstractTree for Select {
let item = if final_node.kind() == "}" { let item = if final_node.kind() == "}" {
let item_node = node.child(child_count - 2).unwrap(); 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 { } else {
None None
}; };

View File

@ -12,7 +12,6 @@ use crate::{
/// Expression, it will always return a non-empty value when run. /// Expression, it will always return a non-empty value when run.
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub enum Statement { pub enum Statement {
Comment(String),
Assignment(Box<Assignment>), Assignment(Box<Assignment>),
Expression(Expression), Expression(Expression),
IfElse(Box<IfElse>), IfElse(Box<IfElse>),
@ -35,12 +34,6 @@ impl AbstractTree for Statement {
let child = node.child(0).unwrap(); let child = node.child(0).unwrap();
match child.kind() { 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" => Ok(Statement::Assignment(Box::new(
Assignment::from_syntax_node(source, child)?, Assignment::from_syntax_node(source, child)?,
))), ))),
@ -81,7 +74,7 @@ impl AbstractTree for Statement {
source, child, source, child,
)?))), )?))),
_ => Err(Error::UnexpectedSyntaxNode { _ => 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(), actual: child.kind(),
location: child.start_position(), location: child.start_position(),
relevant_source: source[child.byte_range()].to_string(), 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> { fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
match self { match self {
Statement::Comment(comment) => Ok(Value::String(comment.clone())),
Statement::Assignment(assignment) => assignment.run(source, context), Statement::Assignment(assignment) => assignment.run(source, context),
Statement::Expression(expression) => expression.run(source, context), Statement::Expression(expression) => expression.run(source, context),
Statement::IfElse(if_else) => if_else.run(source, context), Statement::IfElse(if_else) => if_else.run(source, context),

View File

@ -71,7 +71,7 @@ impl AbstractTree for Tool {
for index in 2..node.child_count() - 1 { for index in 2..node.child_count() - 1 {
let child_node = node.child(index).unwrap(); 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)?; let expression = Expression::from_syntax_node(source, child_node)?;
expressions.push(expression); expressions.push(expression);

View File

@ -2,13 +2,13 @@ use rayon::prelude::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tree_sitter::Node; 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)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Transform { pub struct Transform {
identifier: Identifier, identifier: Identifier,
expression: Expression, expression: Expression,
item: Item, item: Statement,
} }
impl AbstractTree for Transform { impl AbstractTree for Transform {
@ -20,7 +20,7 @@ impl AbstractTree for Transform {
let expression = Expression::from_syntax_node(source, expression_node)?; let expression = Expression::from_syntax_node(source, expression_node)?;
let item_node = node.child(5).unwrap(); 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 { Ok(Transform {
identifier, identifier,

View File

@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
use tree_sitter::Node; use tree_sitter::Node;
use crate::{ use crate::{
AbstractTree, Error, Expression, Function, Identifier, Item, List, Map, Result, Table, Value, AbstractTree, Error, Expression, Function, Identifier, List, Map, Result, Statement, Table,
ValueType, Value, ValueType,
}; };
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
@ -102,7 +102,7 @@ impl AbstractTree for ValueNode {
let mut identifiers = Vec::new(); let mut identifiers = Vec::new();
let item_node = child.child(child.child_count() - 2).unwrap(); 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 { for index in 1..child.child_count() - 3 {
let child_node = child.child(index).unwrap(); let child_node = child.child(index).unwrap();

View File

@ -1,12 +1,12 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tree_sitter::Node; 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)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct While { pub struct While {
expression: Expression, expression: Expression,
items: Vec<Item>, statement: Statement,
} }
impl AbstractTree for While { impl AbstractTree for While {
@ -16,27 +16,21 @@ impl AbstractTree for While {
let expression_node = node.child(1).unwrap(); let expression_node = node.child(1).unwrap();
let expression = Expression::from_syntax_node(source, expression_node)?; let expression = Expression::from_syntax_node(source, expression_node)?;
let child_count = node.child_count(); let statement_node = node.child(3).unwrap();
let mut items = Vec::with_capacity(child_count); let statement = Statement::from_syntax_node(source, statement_node)?;
for index in 3..child_count - 1 { Ok(While {
let item_node = node.child(index).unwrap(); expression,
let item = Item::from_syntax_node(source, item_node)?; statement,
})
items.push(item);
}
Ok(While { expression, items })
} }
fn run(&self, source: &str, context: &mut Map) -> Result<Value> { fn run(&self, source: &str, context: &mut Map) -> Result<Value> {
while self.expression.run(source, context)?.as_boolean()? { while self.expression.run(source, context)?.as_boolean()? {
for item in &self.items { self.statement.run(source, context)?;
item.run(source, context)?;
}
} }
Ok(crate::Value::Empty) Ok(Value::Empty)
} }
} }

View File

@ -6,7 +6,7 @@ use std::fmt::{self, Debug, Formatter};
use tree_sitter::{Parser, Tree as TSTree}; 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. /// Evaluate the given source code.
/// ///
@ -86,7 +86,7 @@ impl<'context, 'code> Evaluator<'context, 'code> {
let mut prev_result = Ok(Value::Empty); let mut prev_result = Ok(Value::Empty);
for item_node in root_node.children(&mut cursor) { 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); prev_result = item.run(self.source, self.context);
} }

View File

@ -1,5 +1,5 @@
//! Command line interface for the dust programming language. //! 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 clap::Parser;
use rustyline::{ use rustyline::{
completion::FilenameCompleter, completion::FilenameCompleter,

View File

@ -2,19 +2,19 @@ use std::fmt::{self, Display, Formatter};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{Identifier, Item}; use crate::{Identifier, Statement};
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)] #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Function { pub struct Function {
parameters: Vec<Identifier>, parameters: Vec<Identifier>,
body: Item, body: Box<Statement>,
} }
impl Function { impl Function {
pub fn new(identifiers: Vec<Identifier>, items: Item) -> Self { pub fn new(identifiers: Vec<Identifier>, items: Statement) -> Self {
Function { Function {
parameters: identifiers, parameters: identifiers,
body: items, body: Box::new(items),
} }
} }
@ -22,7 +22,7 @@ impl Function {
&self.parameters &self.parameters
} }
pub fn body(&self) -> &Item { pub fn body(&self) -> &Statement {
&self.body &self.body
} }
} }

View File

@ -7,14 +7,16 @@ async { (output 'Whaddup') }
--- ---
(root (root
(statement (block
(async (statement
(statement (async
(expression (block
(tool (statement
(expression (expression
(value (tool
(string))))))))) (expression
(value
(string)))))))))))
================== ==================
Complex Async Statements Complex Async Statements
@ -33,35 +35,40 @@ async {
--- ---
(root (root
(statement (block
(async (statement
(statement (async
(if_else (block
(if (statement
(expression (if_else
(logic (if
(expression (expression
(math (logic
(expression (expression
(value (math
(integer))) (expression
(math_operator) (value
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression (expression
(value (value
(integer))))) (integer)))))
(logic_operator) (block
(expression (statement
(value (expression
(integer))))) (value
(statement (boolean))))))
(expression (else
(value (block
(boolean))))) (statement
(else (expression
(statement (value
(expression (boolean))))))))
(value (statement
(boolean)))))) (expression
(expression (value
(value (string)))))))))
(string)))))))

View File

@ -8,9 +8,10 @@ not_a_comment
--- ---
(root (root
(statement (block
(expression (statement
(identifier))) (expression
(identifier))))
(comment)) (comment))
================== ==================
@ -22,10 +23,11 @@ not_a_comment # comment
--- ---
(root (root
(statement (block
(expression (statement
(identifier))) (expression
(comment)) (identifier))))
(comment))
================== ==================
Multiline Comments Multiline Comments
@ -39,12 +41,13 @@ not_a_comment #
(root (root
(comment) (comment)
(statement (block
(expression (statement
(identifier))) (expression
(comment) (identifier)))
(comment) (comment)
(statement (comment)
(expression (statement
(value (expression
(string))))) (value
(string))))))

View File

@ -9,30 +9,32 @@ filter i in [1, 2, 3] {
--- ---
(root (root
(statement (block
(filter (statement
(identifier) (filter
(expression (identifier)
(value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(statement
(expression (expression
(logic (value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(block
(statement
(expression (expression
(identifier)) (logic
(logic_operator) (expression
(expression (identifier))
(value (logic_operator)
(integer))))))))) (expression
(value
(integer)))))))))))
================== ==================
Nested Filter Loop Nested Filter Loop
@ -47,22 +49,25 @@ filter i in big_list {
--- ---
(root (root
(statement (block
(filter (statement
(identifier) (filter
(expression (identifier)
(identifier)) (expression
(statement (identifier))
(filter (block
(identifier)
(expression
(identifier))
(statement (statement
(expression (filter
(logic (identifier)
(expression (expression
(identifier)) (identifier))
(logic_operator) (block
(expression (statement
(value (expression
(integer))))))))))) (logic
(expression
(identifier))
(logic_operator)
(expression
(value
(integer))))))))))))))

View File

@ -9,30 +9,32 @@ find i in [1, 2, 3] {
--- ---
(root (root
(statement (block
(find (statement
(identifier) (find
(expression (identifier)
(value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(statement
(expression (expression
(logic (value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(block
(statement
(expression (expression
(identifier)) (logic
(logic_operator) (expression
(expression (identifier))
(value (logic_operator)
(integer))))))))) (expression
(value
(integer)))))))))))
================== ==================
Nested Find Loop Nested Find Loop
@ -54,57 +56,63 @@ find i in ["one", "two", "three"] {
--- ---
(root (root
(statement (block
(find (statement
(identifier) (find
(expression (identifier)
(value (expression
(list (value
(expression (list
(value
(string)))
(expression
(value
(string)))
(expression
(value
(string))))))
(statement
(assignment
(identifier)
(assignment_operator)
(statement
(find
(identifier)
(expression (expression
(identifier)) (value
(string)))
(expression
(value
(string)))
(expression
(value
(string))))))
(block
(statement
(assignment
(identifier)
(assignment_operator)
(statement (statement
(find
(identifier)
(expression
(identifier))
(block
(statement
(expression
(logic
(expression
(identifier))
(logic_operator)
(expression
(value
(string)))))))))))
(statement
(if_else
(if
(expression (expression
(logic (logic
(expression (expression
(identifier)) (tool
(expression
(identifier))))
(logic_operator) (logic_operator)
(expression (expression
(value (value
(string))))))))) (string)))))
(if_else (block
(if (statement
(expression
(logic
(expression
(tool
(expression (expression
(identifier)))) (value
(logic_operator) (boolean))))))
(expression (else
(value (block
(string))))) (statement
(statement (expression
(expression (value
(value (boolean)))))))))))))
(boolean)))))
(else
(statement
(expression
(value
(boolean))))))))))

View File

@ -9,26 +9,28 @@ for i in [1, 2, 3] {
--- ---
(root (root
(statement (block
(for (statement
(identifier) (for
(expression (identifier)
(value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(statement
(expression (expression
(tool (value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(block
(statement
(expression (expression
(identifier)))))))) (tool
(expression
(identifier))))))))))
================== ==================
Nested For Loop Nested For Loop
@ -43,18 +45,21 @@ for list in list_of_lists {
--- ---
(root (root
(statement (block
(for (statement
(identifier) (for
(expression (identifier)
(identifier)) (expression
(statement (identifier))
(for (block
(identifier)
(expression
(identifier))
(statement (statement
(expression (for
(tool (identifier)
(expression (expression
(identifier)))))))))) (identifier))
(block
(statement
(expression
(tool
(expression
(identifier)))))))))))))

View File

@ -7,15 +7,17 @@ function { "Hiya" }
--- ---
(root (root
(statement (block
(expression (statement
(value (expression
(function (value
(statement (function
(expression (block
(value (statement
(string))))))))) (expression
(value
(string)))))))))))
================== ==================
Function Call Function Call
================== ==================
@ -25,13 +27,14 @@ Function Call
--- ---
(root (root
(statement (block
(expression (statement
(function_call (expression
(identifier) (function_call
(expression (identifier)
(value (expression
(string))))))) (value
(string))))))))
================== ==================
Complex Function Complex Function
@ -45,21 +48,24 @@ function <message number> {
--- ---
(root (root
(statement (block
(expression (statement
(value (expression
(function (value
(identifier) (function
(identifier) (identifier)
(statement (identifier)
(expression (block
(tool (statement
(expression (expression
(identifier)))) (tool
(expression (expression
(tool (identifier)))))
(statement
(expression (expression
(identifier)))))))))) (tool
(expression
(identifier))))))))))))
================== ==================
Complex Function Call Complex Function Call
@ -77,24 +83,25 @@ Complex Function Call
--- ---
(root (root
(statement (block
(expression (statement
(function_call (expression
(identifier) (function_call
(expression (identifier)
(value (expression
(string))) (value
(expression (string)))
(value (expression
(integer))) (value
(expression (integer)))
(value (expression
(map (value
(identifier) (map
(expression (identifier)
(value (expression
(integer))) (value
(identifier) (integer)))
(expression (identifier)
(value (expression
(integer)))))))))) (value
(integer)))))))))))

View File

@ -9,12 +9,13 @@ __xyz__
--- ---
(root (root
(statement (block
(expression (statement
(identifier))) (expression
(statement (identifier)))
(expression (statement
(identifier))) (expression
(statement (identifier)))
(expression (statement
(identifier)))) (expression
(identifier)))))

View File

@ -7,16 +7,18 @@ if true { "True" }
--- ---
(root (root
(statement (block
(if_else (statement
(if (if_else
(expression (if
(value
(boolean)))
(statement
(expression (expression
(value (value
(string)))))))) (boolean)))
(block
(statement
(expression
(value
(string))))))))))
================== ==================
Complex If Complex If
@ -27,46 +29,48 @@ if 1 == 1 && 2 == 2 && 3 == 3 { "True" }
--- ---
(root (root
(statement (block
(if_else (statement
(if (if_else
(expression (if
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))))))))))
(statement
(expression (expression
(value (logic
(string)))))))) (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 Nested If
@ -83,33 +87,37 @@ if true {
--- ---
(root (root
(statement (block
(if_else (statement
(if (if_else
(expression (if
(value (expression
(boolean))) (value
(statement (boolean)))
(if_else (block
(if (statement
(expression (if_else
(logic (if
(expression (expression
(value (logic
(integer))) (expression
(logic_operator) (value
(expression (integer)))
(value (logic_operator)
(integer))))) (expression
(statement (value
(expression (integer)))))
(value (block
(string))))) (statement
(else (expression
(statement (value
(expression (string))))))
(value (else
(string))))))))))) (block
(statement
(expression
(value
(string))))))))))))))
================== ==================
If Else If Else
@ -120,21 +128,24 @@ if false { "True" } else { "False" }
--- ---
(root (root
(statement (block
(if_else (statement
(if (if_else
(expression (if
(value
(boolean)))
(statement
(expression (expression
(value (value
(string))))) (boolean)))
(else (block
(statement (statement
(expression (expression
(value (value
(string)))))))) (string))))))
(else
(block
(statement
(expression
(value
(string))))))))))
================== ==================
If Else If If Else If
@ -149,36 +160,39 @@ if 1 == 1 {
--- ---
(root (root
(statement (block
(if_else (statement
(if (if_else
(expression (if
(logic
(expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression (expression
(value (logic
(string))))) (expression
(else_if (value
(expression (integer)))
(logic (logic_operator)
(expression (expression
(value (value
(integer))) (integer)))))
(logic_operator) (block
(expression (statement
(value (expression
(integer))))) (value
(statement (string))))))
(else_if
(expression (expression
(value (logic
(string)))))))) (expression
(value
(integer)))
(logic_operator)
(expression
(value
(integer)))))
(block
(statement
(expression
(value
(string))))))))))
================== ==================
If Else Else If Else If Else Else If Else
@ -197,46 +211,51 @@ if false {
--- ---
(root (root
(statement (block
(if_else (statement
(if (if_else
(expression (if
(value
(boolean)))
(statement
(expression (expression
(value (value
(string))))) (boolean)))
(else_if (block
(expression (statement
(value (expression
(boolean))) (value
(statement (string))))))
(else_if
(expression (expression
(value (value
(string))))) (boolean)))
(else_if (block
(expression (statement
(logic (expression
(expression (value
(math (string))))))
(expression (else_if
(value
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression (expression
(value (logic
(string))))) (expression
(else (math
(statement (expression
(expression (value
(value (integer)))
(string)))))))) (math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(block
(statement
(expression
(value
(string))))))
(else
(block
(statement
(expression
(value
(string))))))))))

View File

@ -11,38 +11,39 @@ foobar:1:42
--- ---
(root (root
(statement (block
(expression (statement
(index (expression
(index
(expression
(index
(expression
(identifier))
(expression
(value
(integer)))))
(expression
(identifier)))))
(statement
(expression
(index
(expression
(identifier))
(expression
(identifier)))))
(statement
(expression (expression
(index (index
(expression (expression
(identifier)) (index
(expression
(identifier))
(expression
(value
(integer)))))
(expression (expression
(value (value
(integer))))) (integer))))))))
(expression
(identifier)))))
(statement
(expression
(index
(expression
(identifier))
(expression
(identifier)))))
(statement
(expression
(index
(expression
(index
(expression
(identifier))
(expression
(value
(integer)))))
(expression
(value
(integer)))))))
================== ==================
Nested Indexes Nested Indexes
@ -53,40 +54,41 @@ Nested Indexes
--- ---
(root (root
(statement (block
(expression (statement
(index
(expression (expression
(index (index
(expression (expression
(index (index
(expression (expression
(value (index
(list (expression
(expression (value
(value (list
(list (expression
(expression (value
(value (list
(string))) (expression
(expression (value
(value (string)))
(string)))))) (expression
(expression (value
(value (string))))))
(integer))) (expression
(expression (value
(value (integer)))
(integer)))))) (expression
(value
(integer))))))
(expression
(value
(integer)))))
(expression (expression
(value (value
(integer))))) (integer)))))
(expression (expression
(value (value
(integer))))) (integer)))
(expression (expression
(value (value
(integer))) (integer))))))))
(expression
(value
(integer)))))))

View File

@ -7,16 +7,17 @@ List Declaration
--- ---
(root (root
(statement (block
(expression (statement
(value (expression
(list (value
(expression (list
(value (expression
(string))) (value
(expression (string)))
(value (expression
(integer)))))))) (value
(integer)))))))))
================== ==================
List Nesting List Nesting
@ -27,22 +28,23 @@ List Nesting
--- ---
(root (root
(statement (block
(expression (statement
(value (expression
(list (value
(expression (list
(value (expression
(string))) (value
(expression (string)))
(value (expression
(list (value
(expression (list
(value (expression
(integer))) (value
(expression (integer)))
(value (expression
(list (value
(expression (list
(value (expression
(integer)))))))))))))) (value
(integer)))))))))))))))

View File

@ -7,14 +7,15 @@ Simple Map
--- ---
(root (root
(statement (block
(expression (statement
(value (expression
(map (value
(identifier) (map
(expression (identifier)
(value (expression
(integer)))))))) (value
(integer)))))))))
================== ==================
Nested Maps Nested Maps
@ -33,31 +34,32 @@ x = {
--- ---
(root (root
(statement (block
(assignment (statement
(identifier) (assignment
(assignment_operator) (identifier)
(statement (assignment_operator)
(expression (statement
(value (expression
(map (value
(identifier) (map
(expression (identifier)
(value (expression
(map (value
(identifier) (map
(expression (identifier)
(value (expression
(string))) (value
(identifier) (string)))
(expression (identifier)
(value (expression
(map (value
(identifier) (map
(expression (identifier)
(value (expression
(string))))))))) (value
(identifier) (string)))))))))
(expression (identifier)
(value (expression
(integer)))))))))) (value
(integer)))))))))))

View File

@ -1,5 +1,5 @@
================== ==================
Equality \==
================== ==================
3 == 1 + 1 + 1 3 == 1 + 1 + 1
@ -7,28 +7,29 @@ Equality
--- ---
(root (root
(statement (block
(expression (statement
(logic (expression
(expression (logic
(value (expression
(integer))) (value
(logic_operator) (integer)))
(expression (logic_operator)
(math (expression
(expression (math
(math (expression
(expression (math
(value (expression
(integer))) (value
(math_operator) (integer)))
(expression (math_operator)
(value (expression
(integer))))) (value
(math_operator) (integer)))))
(expression (math_operator)
(value (expression
(integer))))))))) (value
(integer))))))))))
================== ==================
&& &&
@ -39,28 +40,29 @@ Equality
--- ---
(root (root
(statement (block
(expression (statement
(logic (expression
(expression (logic
(math (expression
(expression (math
(value (expression
(integer))) (value
(math_operator) (integer)))
(expression (math_operator)
(value (expression
(integer))))) (value
(logic_operator) (integer)))))
(expression (logic_operator)
(logic (expression
(expression (logic
(value (expression
(integer))) (value
(logic_operator) (integer)))
(expression (logic_operator)
(value (expression
(boolean))))))))) (value
(boolean))))))))))
================== ==================
\|| \||
@ -71,25 +73,26 @@ Equality
--- ---
(root (root
(statement (block
(expression (statement
(logic (expression
(expression (logic
(math (expression
(expression (math
(value (expression
(integer))) (value
(math_operator) (integer)))
(expression (math_operator)
(value (expression
(integer))))) (value
(logic_operator) (integer)))))
(expression (logic_operator)
(logic (expression
(expression (logic
(value (expression
(integer))) (value
(logic_operator) (integer)))
(expression (logic_operator)
(value (expression
(boolean))))))))) (value
(boolean))))))))))

View File

@ -9,29 +9,31 @@ reduce i to acc in [1, 2, 3] {
--- ---
(root (root
(statement (block
(reduce (statement
(identifier) (reduce
(identifier) (identifier)
(expression (identifier)
(value (expression
(list (value
(expression (list
(value (expression
(integer))) (value
(expression (integer)))
(value (expression
(integer))) (value
(expression (integer)))
(value (expression
(integer)))))) (value
(statement (integer))))))
(assignment (block
(identifier)
(assignment_operator)
(statement (statement
(expression (assignment
(identifier)))))))) (identifier)
(assignment_operator)
(statement
(expression
(identifier))))))))))
================== ==================
Nested Reduce Loop Nested Reduce Loop
@ -44,26 +46,28 @@ reduce i to acc in ["one", "two", "three"] {
--- ---
(root (root
(statement (block
(reduce (statement
(identifier) (reduce
(identifier) (identifier)
(expression (identifier)
(value (expression
(list (value
(expression (list
(value (expression
(string))) (value
(expression (string)))
(value (expression
(string))) (value
(expression (string)))
(value (expression
(string)))))) (value
(statement (string))))))
(assignment (block
(identifier)
(assignment_operator)
(statement (statement
(expression (assignment
(identifier)))))))) (identifier)
(assignment_operator)
(statement
(expression
(identifier))))))))))

View File

@ -9,30 +9,32 @@ remove i from [1, 2, 3] {
--- ---
(root (root
(statement (block
(remove (statement
(identifier) (remove
(expression (identifier)
(value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(statement
(expression (expression
(logic (value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(block
(statement
(expression (expression
(identifier)) (logic
(logic_operator) (expression
(expression (identifier))
(value (logic_operator)
(integer))))))))) (expression
(value
(integer)))))))))))
================== ==================
Nested Remove Nested Remove
@ -47,26 +49,29 @@ removed = remove i from big_list {
--- ---
(root (root
(statement (block
(assignment (statement
(identifier) (assignment
(assignment_operator) (identifier)
(statement (assignment_operator)
(remove (statement
(identifier) (remove
(expression (identifier)
(identifier)) (expression
(statement (identifier))
(remove (block
(identifier)
(expression
(identifier))
(statement (statement
(expression (remove
(logic (identifier)
(expression (expression
(identifier)) (identifier))
(logic_operator) (block
(expression (statement
(value (expression
(integer))))))))))))) (logic
(expression
(identifier))
(logic_operator)
(expression
(value
(integer))))))))))))))))

View File

@ -9,17 +9,18 @@ x
--- ---
(root (root
(statement (block
(expression (statement
(value (expression
(integer)))) (value
(statement (integer))))
(expression (statement
(value (expression
(string)))) (value
(statement (string))))
(expression (statement
(identifier)))) (expression
(identifier)))))
================== ==================
Simple Assignment Simple Assignment
@ -31,22 +32,23 @@ y = "one"
--- ---
(root (root
(statement (block
(assignment (statement
(identifier) (assignment
(assignment_operator) (identifier)
(statement (assignment_operator)
(expression (statement
(value (expression
(integer)))))) (value
(statement (integer))))))
(assignment (statement
(identifier) (assignment
(assignment_operator) (identifier)
(statement (assignment_operator)
(expression (statement
(value (expression
(string))))))) (value
(string))))))))
================== ==================
Complex Assignment Complex Assignment
@ -61,37 +63,40 @@ x = if 1 + 1 == 2 {
--- ---
(root (root
(statement (block
(assignment (statement
(identifier) (assignment
(assignment_operator) (identifier)
(statement (assignment_operator)
(if_else (statement
(if (if_else
(expression (if
(logic
(expression
(math
(expression
(value
(integer)))
(math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(statement
(expression (expression
(value (logic
(string))))) (expression
(else (math
(statement (expression
(expression (value
(value (integer)))
(string)))))))))) (math_operator)
(expression
(value
(integer)))))
(logic_operator)
(expression
(value
(integer)))))
(block
(statement
(expression
(value
(string))))))
(else
(block
(statement
(expression
(value
(string))))))))))))
================== ==================
Expression Precedence Expression Precedence
@ -102,29 +107,30 @@ x = 3 == 1 + 2 + 2
--- ---
(root (root
(statement (block
(assignment (statement
(identifier) (assignment
(assignment_operator) (identifier)
(statement (assignment_operator)
(expression (statement
(logic (expression
(expression (logic
(value (expression
(integer))) (value
(logic_operator) (integer)))
(expression (logic_operator)
(math (expression
(expression (math
(math (expression
(expression (math
(value (expression
(integer))) (value
(math_operator) (integer)))
(expression (math_operator)
(value (expression
(integer))))) (value
(math_operator) (integer)))))
(expression (math_operator)
(value (expression
(integer))))))))))) (value
(integer))))))))))))

View File

@ -11,42 +11,44 @@ table <messages, numbers> [
--- ---
(root (root
(statement (block
(expression (statement
(value (expression
(table (value
(identifier) (table
(identifier) (identifier)
(expression (identifier)
(value (expression
(list (value
(expression (list
(value (expression
(list (value
(expression (list
(value (expression
(string))) (value
(expression (string)))
(value (expression
(integer)))))) (value
(expression (integer))))))
(value (expression
(list (value
(expression (list
(value (expression
(string))) (value
(expression (string)))
(value (expression
(integer)))))) (value
(expression (integer))))))
(value (expression
(list (value
(expression (list
(value (expression
(string))) (value
(expression (string)))
(value (expression
(float)))))))))))))) (value
(float)))))))))))))))
================== ==================
Table Access Table Access
================== ==================
@ -58,20 +60,22 @@ select <number> from foobar {
--- ---
(root (root
(statement (block
(select (statement
(identifier) (select
(expression (identifier)
(identifier))
(statement
(expression (expression
(logic (identifier))
(block
(statement
(expression (expression
(identifier)) (logic
(logic_operator) (expression
(expression (identifier))
(value (logic_operator)
(string))))))))) (expression
(value
(string)))))))))))
================== ==================
Table Insert Table Insert
@ -84,18 +88,19 @@ insert into foobar [
--- ---
(root (root
(statement (block
(insert (statement
(identifier) (insert
(expression (identifier)
(value (expression
(list (value
(expression (list
(value (expression
(list (value
(expression (list
(value (expression
(string))) (value
(expression (string)))
(value (expression
(integer)))))))))))) (value
(integer)))))))))))))

View 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))))))))

View File

@ -9,26 +9,28 @@ transform i in [1, 2, 3] {
--- ---
(root (root
(statement (block
(transform (statement
(identifier) (transform
(expression (identifier)
(value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(statement
(expression (expression
(tool (value
(list
(expression
(value
(integer)))
(expression
(value
(integer)))
(expression
(value
(integer))))))
(block
(statement
(expression (expression
(identifier)))))))) (tool
(expression
(identifier))))))))))
================== ==================
Nested Transform Loop Nested Transform Loop
@ -43,40 +45,43 @@ transform i in [['one'] ['two'] ['three']] {
--- ---
(root (root
(statement (block
(transform (statement
(identifier) (transform
(expression (identifier)
(value (expression
(list (value
(expression (list
(value (expression
(list (value
(expression (list
(value (expression
(string)))))) (value
(expression (string))))))
(value (expression
(list (value
(expression (list
(value (expression
(string)))))) (value
(expression (string))))))
(value (expression
(list (value
(expression (list
(value (expression
(string))))))))) (value
(statement (string)))))))))
(transform (block
(identifier)
(expression
(identifier))
(statement (statement
(assignment (transform
(identifier) (identifier)
(assignment_operator) (expression
(statement (identifier))
(expression (block
(value (statement
(string))))))))))) (assignment
(identifier)
(assignment_operator)
(statement
(expression
(value
(string))))))))))))))

View File

@ -8,14 +8,15 @@ false
--- ---
(root (root
(statement (block
(expression (statement
(value (expression
(boolean)))) (value
(statement (boolean))))
(expression (statement
(value (expression
(boolean))))) (value
(boolean))))))
================== ==================
Integers Integers
@ -27,26 +28,27 @@ Integers
--- ---
(root (root
(statement (block
(expression (statement
(value (expression
(integer)))) (value
(statement (integer))))
(expression (statement
(value (expression
(integer)))) (value
(statement (integer))))
(expression (statement
(value (expression
(integer)))) (value
(statement (integer))))
(expression (statement
(value (expression
(integer)))) (value
(statement (integer))))
(expression (statement
(value (expression
(integer))))) (value
(integer))))))
================== ==================
Strings Strings
@ -57,6 +59,7 @@ Strings
--- ---
(root (root
(block
(statement (statement
(expression (expression
(value (value
@ -76,4 +79,4 @@ Strings
(statement (statement
(expression (expression
(value (value
(string))))) (string))))))

View File

@ -9,25 +9,26 @@ while true {
--- ---
(root (root
(statement (block
(while (statement
(expression (while
(value
(boolean)))
(statement
(expression (expression
(tool (value
(boolean)))
(block
(statement
(expression (expression
(value (tool
(string))))))))) (expression
(value
(string)))))))))))
================== ==================
Nested While Loop Nested While Loop
================== ==================
while true { while (true) {
x = 4 while (x > 0) {
while x > 0 {
x -= 1 x -= 1
} }
} }
@ -35,33 +36,29 @@ while true {
--- ---
(root (root
(statement (block
(while (statement
(expression (while
(value (expression
(boolean))) (value
(statement (boolean)))
(assignment (block
(identifier)
(assignment_operator)
(statement (statement
(expression (while
(value
(integer)))))
(while
(expression
(logic
(expression (expression
(identifier)) (logic
(logic_operator) (expression
(expression (identifier))
(value (logic_operator)
(integer))))) (expression
(statement (value
(assignment (integer)))))
(identifier) (block
(assignment_operator) (statement
(statement (assignment
(expression (identifier)
(value (assignment_operator)
(integer))))))))))) (statement
(expression
(value
(integer))))))))))))))

View File

@ -6,16 +6,16 @@ module.exports = grammar({
extras: $ => [ /\s/, $.comment ], extras: $ => [ /\s/, $.comment ],
rules: { rules: {
root: $ => repeat1($.statement), root: $ => repeat1($.block),
comment: $ => /[#][^#\n]*[#|\n]/, comment: $ => /[#][^#\n]*[#|\n]/,
statement: $ => prec.left(choice( block: $ => prec.right(choice(
repeat1($._statement_kind), repeat1($.statement),
seq('{', repeat1($._statement_kind), '}'), seq('{', repeat1($.statement), '}'),
)), )),
_statement_kind: $ => prec.left(choice( statement: $ => prec.left(choice(
$.assignment, $.assignment,
$.async, $.async,
$.expression, $.expression,
@ -37,7 +37,7 @@ module.exports = grammar({
seq('(', $._expression_kind, ')'), seq('(', $._expression_kind, ')'),
), ),
_expression_kind: $ => prec.right(choice( _expression_kind: $ => prec.left(choice(
$.function_call, $.function_call,
$.identifier, $.identifier,
$.index, $.index,
@ -89,12 +89,12 @@ module.exports = grammar({
map: $ => seq( map: $ => seq(
'{', '{',
repeat(seq( repeat(prec(1, seq(
$.identifier, $.identifier,
'=', '=',
$.expression, $.expression,
optional(',') optional(',')
)), ))),
'}', '}',
), ),
@ -111,9 +111,7 @@ module.exports = grammar({
function: $ => seq( function: $ => seq(
'function', 'function',
optional(seq('<', repeat(seq($.identifier, optional(','))), '>')), optional(seq('<', repeat(seq($.identifier, optional(','))), '>')),
'{', $.block,
$.statement,
'}',
), ),
table: $ => prec.left(seq( table: $ => prec.left(seq(
@ -128,13 +126,13 @@ module.exports = grammar({
$.expression, $.expression,
)), )),
math_operator: $ => token(choice( math_operator: $ => choice(
'+', '+',
'-', '-',
'*', '*',
'/', '/',
'%', '%',
)), ),
logic: $ => prec.right(seq( logic: $ => prec.right(seq(
$.expression, $.expression,
@ -142,7 +140,7 @@ module.exports = grammar({
$.expression, $.expression,
)), )),
logic_operator: $ => token(choice( logic_operator: $ => choice(
'==', '==',
'!=', '!=',
'&&', '&&',
@ -151,19 +149,19 @@ module.exports = grammar({
'<', '<',
">=", ">=",
"<=", "<=",
)), ),
assignment: $ => prec.right(seq( assignment: $ => seq(
$.identifier, $.identifier,
$.assignment_operator, $.assignment_operator,
$.statement, $.statement,
)), ),
assignment_operator: $ => token(choice( assignment_operator: $ => choice(
"=", "=",
"+=", "+=",
"-=", "-=",
)), ),
if_else: $ => prec.left(seq( if_else: $ => prec.left(seq(
$.if, $.if,
@ -175,7 +173,7 @@ module.exports = grammar({
'if', 'if',
$.expression, $.expression,
'{', '{',
$.statement, $.block,
'}', '}',
), ),
@ -183,14 +181,14 @@ module.exports = grammar({
'else if', 'else if',
$.expression, $.expression,
'{', '{',
$.statement, $.block,
'}', '}',
), ),
else: $ => seq( else: $ => seq(
'else', 'else',
'{', '{',
$.statement, $.block,
'}', '}',
), ),
@ -208,7 +206,7 @@ module.exports = grammar({
repeat1(seq( repeat1(seq(
$.expression, $.expression,
'=>', '=>',
$.statement, $.block,
)), )),
'}', '}',
), ),
@ -216,9 +214,7 @@ module.exports = grammar({
while: $ => seq( while: $ => seq(
'while', 'while',
$.expression, $.expression,
'{', $.block,
$.statement,
'}',
), ),
for: $ => seq( for: $ => seq(
@ -226,9 +222,7 @@ module.exports = grammar({
$.identifier, $.identifier,
'in', 'in',
$.expression, $.expression,
'{', $.block,
$.statement,
'}',
), ),
transform: $ => seq( transform: $ => seq(
@ -236,9 +230,7 @@ module.exports = grammar({
$.identifier, $.identifier,
'in', 'in',
$.expression, $.expression,
'{', $.block,
$.statement,
'}',
), ),
filter: $ => seq( filter: $ => seq(
@ -247,9 +239,7 @@ module.exports = grammar({
field('statement_id', $.identifier), field('statement_id', $.identifier),
'in', 'in',
field('collection', $.expression), field('collection', $.expression),
'{', field('predicate', $.block),
field('predicate', $.statement),
'}',
), ),
find: $ => seq( find: $ => seq(
@ -257,9 +247,7 @@ module.exports = grammar({
$.identifier, $.identifier,
'in', 'in',
$.expression, $.expression,
'{', $.block,
$.statement,
'}',
), ),
remove: $ => seq( remove: $ => seq(
@ -267,9 +255,7 @@ module.exports = grammar({
$.identifier, $.identifier,
'from', 'from',
$.expression, $.expression,
'{', $.block,
$.statement,
'}',
), ),
reduce: $ => seq( reduce: $ => seq(
@ -279,9 +265,7 @@ module.exports = grammar({
$.identifier, $.identifier,
'in', 'in',
$.expression, $.expression,
'{', $.block,
$.statement,
'}',
), ),
select: $ => prec.right(seq( select: $ => prec.right(seq(
@ -291,7 +275,7 @@ module.exports = grammar({
'>', '>',
'from', 'from',
$.expression, $.expression,
optional(seq('{', $.statement, '}')), optional($.block),
)), )),
insert: $ => prec.right(seq( insert: $ => prec.right(seq(
@ -303,15 +287,15 @@ module.exports = grammar({
async: $ => seq( async: $ => seq(
'async', 'async',
'{', $.block,
$.statement,
'}'
), ),
tool: $ => prec.right(seq( tool: $ => seq(
'(',
$._tool_kind, $._tool_kind,
repeat(prec.left(seq($.expression, optional(',')))), repeat(seq($.expression, optional(','))),
)), ')',
),
_tool_kind: $ => choice( _tool_kind: $ => choice(
// General // General

View File

@ -6,15 +6,15 @@
"type": "REPEAT1", "type": "REPEAT1",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
} }
}, },
"comment": { "comment": {
"type": "PATTERN", "type": "PATTERN",
"value": "[#][^#\\n]*[#|\\n]" "value": "[#][^#\\n]*[#|\\n]"
}, },
"statement": { "block": {
"type": "PREC_LEFT", "type": "PREC_RIGHT",
"value": 0, "value": 0,
"content": { "content": {
"type": "CHOICE", "type": "CHOICE",
@ -23,7 +23,7 @@
"type": "REPEAT1", "type": "REPEAT1",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_statement_kind" "name": "statement"
} }
}, },
{ {
@ -37,7 +37,7 @@
"type": "REPEAT1", "type": "REPEAT1",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_statement_kind" "name": "statement"
} }
}, },
{ {
@ -49,7 +49,7 @@
] ]
} }
}, },
"_statement_kind": { "statement": {
"type": "PREC_LEFT", "type": "PREC_LEFT",
"value": 0, "value": 0,
"content": { "content": {
@ -141,7 +141,7 @@
] ]
}, },
"_expression_kind": { "_expression_kind": {
"type": "PREC_RIGHT", "type": "PREC_LEFT",
"value": 0, "value": 0,
"content": { "content": {
"type": "CHOICE", "type": "CHOICE",
@ -482,33 +482,37 @@
{ {
"type": "REPEAT", "type": "REPEAT",
"content": { "content": {
"type": "SEQ", "type": "PREC",
"members": [ "value": 1,
{ "content": {
"type": "SYMBOL", "type": "SEQ",
"name": "identifier" "members": [
}, {
{ "type": "SYMBOL",
"type": "STRING", "name": "identifier"
"value": "=" },
}, {
{ "type": "STRING",
"type": "SYMBOL", "value": "="
"name": "expression" },
}, {
{ "type": "SYMBOL",
"type": "CHOICE", "name": "expression"
"members": [ },
{ {
"type": "STRING", "type": "CHOICE",
"value": "," "members": [
}, {
{ "type": "STRING",
"type": "BLANK" "value": ","
} },
] {
} "type": "BLANK"
] }
]
}
]
}
} }
}, },
{ {
@ -611,17 +615,9 @@
} }
] ]
}, },
{
"type": "STRING",
"value": "{"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
},
{
"type": "STRING",
"value": "}"
} }
] ]
}, },
@ -701,32 +697,29 @@
} }
}, },
"math_operator": { "math_operator": {
"type": "TOKEN", "type": "CHOICE",
"content": { "members": [
"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": "STRING",
{ "value": "%"
"type": "STRING", }
"value": "%" ]
}
]
}
}, },
"logic": { "logic": {
"type": "PREC_RIGHT", "type": "PREC_RIGHT",
@ -750,85 +743,75 @@
} }
}, },
"logic_operator": { "logic_operator": {
"type": "TOKEN", "type": "CHOICE",
"content": { "members": [
"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": "STRING",
{ "value": ">"
"type": "STRING", },
"value": ">" {
}, "type": "STRING",
{ "value": "<"
"type": "STRING", },
"value": "<" {
}, "type": "STRING",
{ "value": ">="
"type": "STRING", },
"value": ">=" {
}, "type": "STRING",
{ "value": "<="
"type": "STRING", }
"value": "<=" ]
}
]
}
}, },
"assignment": { "assignment": {
"type": "PREC_RIGHT", "type": "SEQ",
"value": 0, "members": [
"content": { {
"type": "SEQ", "type": "SYMBOL",
"members": [ "name": "identifier"
{ },
"type": "SYMBOL", {
"name": "identifier" "type": "SYMBOL",
}, "name": "assignment_operator"
{ },
"type": "SYMBOL", {
"name": "assignment_operator" "type": "SYMBOL",
}, "name": "statement"
{ }
"type": "SYMBOL", ]
"name": "statement"
}
]
}
}, },
"assignment_operator": { "assignment_operator": {
"type": "TOKEN", "type": "CHOICE",
"content": { "members": [
"type": "CHOICE", {
"members": [ "type": "STRING",
{ "value": "="
"type": "STRING", },
"value": "=" {
}, "type": "STRING",
{ "value": "+="
"type": "STRING", },
"value": "+=" {
}, "type": "STRING",
{ "value": "-="
"type": "STRING", }
"value": "-=" ]
}
]
}
}, },
"if_else": { "if_else": {
"type": "PREC_LEFT", "type": "PREC_LEFT",
@ -884,7 +867,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -909,7 +892,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -930,7 +913,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
}, },
{ {
"type": "STRING", "type": "STRING",
@ -1013,7 +996,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
} }
] ]
} }
@ -1035,17 +1018,9 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "expression" "name": "expression"
}, },
{
"type": "STRING",
"value": "{"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
},
{
"type": "STRING",
"value": "}"
} }
] ]
}, },
@ -1068,17 +1043,9 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "expression" "name": "expression"
}, },
{
"type": "STRING",
"value": "{"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
},
{
"type": "STRING",
"value": "}"
} }
] ]
}, },
@ -1101,17 +1068,9 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "expression" "name": "expression"
}, },
{
"type": "STRING",
"value": "{"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
},
{
"type": "STRING",
"value": "}"
} }
] ]
}, },
@ -1158,21 +1117,13 @@
"name": "expression" "name": "expression"
} }
}, },
{
"type": "STRING",
"value": "{"
},
{ {
"type": "FIELD", "type": "FIELD",
"name": "predicate", "name": "predicate",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
} }
},
{
"type": "STRING",
"value": "}"
} }
] ]
}, },
@ -1195,17 +1146,9 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "expression" "name": "expression"
}, },
{
"type": "STRING",
"value": "{"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
},
{
"type": "STRING",
"value": "}"
} }
] ]
}, },
@ -1228,17 +1171,9 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "expression" "name": "expression"
}, },
{
"type": "STRING",
"value": "{"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
},
{
"type": "STRING",
"value": "}"
} }
] ]
}, },
@ -1269,17 +1204,9 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "expression" "name": "expression"
}, },
{
"type": "STRING",
"value": "{"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
},
{
"type": "STRING",
"value": "}"
} }
] ]
}, },
@ -1337,21 +1264,8 @@
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "SEQ", "type": "SYMBOL",
"members": [ "name": "block"
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "statement"
},
{
"type": "STRING",
"value": "}"
}
]
}, },
{ {
"type": "BLANK" "type": "BLANK"
@ -1393,60 +1307,52 @@
"type": "STRING", "type": "STRING",
"value": "async" "value": "async"
}, },
{
"type": "STRING",
"value": "{"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "statement" "name": "block"
},
{
"type": "STRING",
"value": "}"
} }
] ]
}, },
"tool": { "tool": {
"type": "PREC_RIGHT", "type": "SEQ",
"value": 0, "members": [
"content": { {
"type": "SEQ", "type": "STRING",
"members": [ "value": "("
{ },
"type": "SYMBOL", {
"name": "_tool_kind" "type": "SYMBOL",
}, "name": "_tool_kind"
{ },
"type": "REPEAT", {
"content": { "type": "REPEAT",
"type": "PREC_LEFT", "content": {
"value": 0, "type": "SEQ",
"content": { "members": [
"type": "SEQ", {
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "STRING",
"name": "expression" "value": ","
}, },
{ {
"type": "CHOICE", "type": "BLANK"
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
} }
] ]
} }
} ]
} }
] },
} {
"type": "STRING",
"value": ")"
}
]
}, },
"_tool_kind": { "_tool_kind": {
"type": "CHOICE", "type": "CHOICE",

View File

@ -22,6 +22,11 @@
] ]
} }
}, },
{
"type": "assignment_operator",
"named": true,
"fields": {}
},
{ {
"type": "async", "type": "async",
"named": true, "named": true,
@ -29,6 +34,21 @@
"children": { "children": {
"multiple": false, "multiple": false,
"required": true, "required": true,
"types": [
{
"type": "block",
"named": true
}
]
}
},
{
"type": "block",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [ "types": [
{ {
"type": "statement", "type": "statement",
@ -51,7 +71,7 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "statement", "type": "block",
"named": true "named": true
} }
] ]
@ -66,11 +86,11 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "expression", "type": "block",
"named": true "named": true
}, },
{ {
"type": "statement", "type": "expression",
"named": true "named": true
} }
] ]
@ -144,7 +164,7 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "statement", "type": "block",
"named": true "named": true
} }
] ]
@ -169,6 +189,10 @@
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{
"type": "block",
"named": true
},
{ {
"type": "expression", "type": "expression",
"named": true "named": true
@ -176,10 +200,6 @@
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
},
{
"type": "statement",
"named": true
} }
] ]
} }
@ -197,6 +217,10 @@
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{
"type": "block",
"named": true
},
{ {
"type": "expression", "type": "expression",
"named": true "named": true
@ -204,10 +228,6 @@
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
},
{
"type": "statement",
"named": true
} }
] ]
} }
@ -221,11 +241,11 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "identifier", "type": "block",
"named": true "named": true
}, },
{ {
"type": "statement", "type": "identifier",
"named": true "named": true
} }
] ]
@ -259,11 +279,11 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "expression", "type": "block",
"named": true "named": true
}, },
{ {
"type": "statement", "type": "expression",
"named": true "named": true
} }
] ]
@ -365,6 +385,11 @@
] ]
} }
}, },
{
"type": "logic_operator",
"named": true,
"fields": {}
},
{ {
"type": "map", "type": "map",
"named": true, "named": true,
@ -393,11 +418,11 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "expression", "type": "block",
"named": true "named": true
}, },
{ {
"type": "statement", "type": "expression",
"named": true "named": true
} }
] ]
@ -422,6 +447,11 @@
] ]
} }
}, },
{
"type": "math_operator",
"named": true,
"fields": {}
},
{ {
"type": "reduce", "type": "reduce",
"named": true, "named": true,
@ -430,6 +460,10 @@
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{
"type": "block",
"named": true
},
{ {
"type": "expression", "type": "expression",
"named": true "named": true
@ -437,10 +471,6 @@
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
},
{
"type": "statement",
"named": true
} }
] ]
} }
@ -453,6 +483,10 @@
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{
"type": "block",
"named": true
},
{ {
"type": "expression", "type": "expression",
"named": true "named": true
@ -460,10 +494,6 @@
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
},
{
"type": "statement",
"named": true
} }
] ]
} }
@ -477,7 +507,7 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "statement", "type": "block",
"named": true "named": true
} }
] ]
@ -491,6 +521,10 @@
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{
"type": "block",
"named": true
},
{ {
"type": "expression", "type": "expression",
"named": true "named": true
@ -498,10 +532,6 @@
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
},
{
"type": "statement",
"named": true
} }
] ]
} }
@ -511,7 +541,7 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
@ -615,6 +645,10 @@
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{
"type": "block",
"named": true
},
{ {
"type": "expression", "type": "expression",
"named": true "named": true
@ -622,10 +656,6 @@
{ {
"type": "identifier", "type": "identifier",
"named": true "named": true
},
{
"type": "statement",
"named": true
} }
] ]
} }
@ -682,16 +712,28 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "expression", "type": "block",
"named": true "named": true
}, },
{ {
"type": "statement", "type": "expression",
"named": true "named": true
} }
] ]
} }
}, },
{
"type": "!=",
"named": false
},
{
"type": "%",
"named": false
},
{
"type": "&&",
"named": false
},
{ {
"type": "(", "type": "(",
"named": false "named": false
@ -700,14 +742,38 @@
"type": ")", "type": ")",
"named": false "named": false
}, },
{
"type": "*",
"named": false
},
{
"type": "+",
"named": false
},
{
"type": "+=",
"named": false
},
{ {
"type": ",", "type": ",",
"named": false "named": false
}, },
{
"type": "-",
"named": false
},
{
"type": "-=",
"named": false
},
{ {
"type": "..", "type": "..",
"named": false "named": false
}, },
{
"type": "/",
"named": false
},
{ {
"type": ":", "type": ":",
"named": false "named": false
@ -716,10 +782,18 @@
"type": "<", "type": "<",
"named": false "named": false
}, },
{
"type": "<=",
"named": false
},
{ {
"type": "=", "type": "=",
"named": false "named": false
}, },
{
"type": "==",
"named": false
},
{ {
"type": "=>", "type": "=>",
"named": false "named": false
@ -728,6 +802,10 @@
"type": ">", "type": ">",
"named": false "named": false
}, },
{
"type": ">=",
"named": false
},
{ {
"type": "[", "type": "[",
"named": false "named": false
@ -748,10 +826,6 @@
"type": "assert_equal", "type": "assert_equal",
"named": false "named": false
}, },
{
"type": "assignment_operator",
"named": true
},
{ {
"type": "async", "type": "async",
"named": false "named": false
@ -840,18 +914,10 @@
"type": "length", "type": "length",
"named": false "named": false
}, },
{
"type": "logic_operator",
"named": true
},
{ {
"type": "match", "type": "match",
"named": false "named": false
}, },
{
"type": "math_operator",
"named": true
},
{ {
"type": "metadata", "type": "metadata",
"named": false "named": false
@ -972,6 +1038,10 @@
"type": "{", "type": "{",
"named": false "named": false
}, },
{
"type": "||",
"named": false
},
{ {
"type": "}", "type": "}",
"named": false "named": false

File diff suppressed because it is too large Load Diff

View 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 |