Add statment_kind syntax node
This commit is contained in:
parent
1ce2178af5
commit
9f2b0461df
@ -6,39 +6,56 @@ use crate::{
|
||||
Match, SyntaxNode, Type, TypeDefinition, Value, While,
|
||||
};
|
||||
|
||||
/// Abstract representation of a statement.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub struct Statement {
|
||||
is_return: bool,
|
||||
statement_inner: StatementInner,
|
||||
statement_inner: StatementKind,
|
||||
}
|
||||
|
||||
impl AbstractTree for Statement {
|
||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Context) -> Result<Self, SyntaxError> {
|
||||
todo!()
|
||||
fn from_syntax(
|
||||
node: SyntaxNode,
|
||||
source: &str,
|
||||
_context: &Context,
|
||||
) -> Result<Self, SyntaxError> {
|
||||
SyntaxError::expect_syntax_node(source, "statement", node)?;
|
||||
|
||||
let first_child = node.child(0).unwrap();
|
||||
let is_return = first_child.kind() == "return";
|
||||
let child = if is_return {
|
||||
node.child(1).unwrap()
|
||||
} else {
|
||||
first_child
|
||||
};
|
||||
|
||||
Ok(Statement {
|
||||
is_return,
|
||||
statement_inner: StatementKind::from_syntax(child, source, _context)?,
|
||||
})
|
||||
}
|
||||
|
||||
fn expected_type(&self, context: &Context) -> Result<Type, ValidationError> {
|
||||
todo!()
|
||||
fn expected_type(&self, _context: &Context) -> Result<Type, ValidationError> {
|
||||
self.statement_inner.expected_type(_context)
|
||||
}
|
||||
|
||||
fn validate(&self, source: &str, context: &Context) -> Result<(), ValidationError> {
|
||||
todo!()
|
||||
fn validate(&self, _source: &str, _context: &Context) -> Result<(), ValidationError> {
|
||||
self.statement_inner.validate(_source, _context)
|
||||
}
|
||||
|
||||
fn run(&self, source: &str, context: &Context) -> Result<Value, RuntimeError> {
|
||||
todo!()
|
||||
fn run(&self, _source: &str, _context: &Context) -> Result<Value, RuntimeError> {
|
||||
self.statement_inner.run(_source, _context)
|
||||
}
|
||||
}
|
||||
|
||||
impl Format for Statement {
|
||||
fn format(&self, output: &mut String, indent_level: u8) {
|
||||
todo!()
|
||||
fn format(&self, _output: &mut String, _indent_level: u8) {
|
||||
self.statement_inner.format(_output, _indent_level)
|
||||
}
|
||||
}
|
||||
|
||||
/// Abstract representation of a statement.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||
pub enum StatementInner {
|
||||
enum StatementKind {
|
||||
Assignment(Box<Assignment>),
|
||||
Expression(Expression),
|
||||
IfElse(Box<IfElse>),
|
||||
@ -50,38 +67,38 @@ pub enum StatementInner {
|
||||
TypeDefinition(TypeDefinition),
|
||||
}
|
||||
|
||||
impl AbstractTree for StatementInner {
|
||||
impl AbstractTree for StatementKind {
|
||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Context) -> Result<Self, SyntaxError> {
|
||||
SyntaxError::expect_syntax_node(source, "statement", node)?;
|
||||
SyntaxError::expect_syntax_node(source, "statement_kind", node)?;
|
||||
|
||||
let child = node.child(0).unwrap();
|
||||
|
||||
match child.kind() {
|
||||
"assignment" => Ok(StatementInner::Assignment(Box::new(
|
||||
"assignment" => Ok(StatementKind::Assignment(Box::new(
|
||||
Assignment::from_syntax(child, source, context)?,
|
||||
))),
|
||||
"expression" => Ok(StatementInner::Expression(Expression::from_syntax(
|
||||
"expression" => Ok(StatementKind::Expression(Expression::from_syntax(
|
||||
child, source, context,
|
||||
)?)),
|
||||
"if_else" => Ok(StatementInner::IfElse(Box::new(IfElse::from_syntax(
|
||||
"if_else" => Ok(StatementKind::IfElse(Box::new(IfElse::from_syntax(
|
||||
child, source, context,
|
||||
)?))),
|
||||
"while" => Ok(StatementInner::While(Box::new(While::from_syntax(
|
||||
"while" => Ok(StatementKind::While(Box::new(While::from_syntax(
|
||||
child, source, context,
|
||||
)?))),
|
||||
"block" => Ok(StatementInner::Block(Box::new(Block::from_syntax(
|
||||
"block" => Ok(StatementKind::Block(Box::new(Block::from_syntax(
|
||||
child, source, context,
|
||||
)?))),
|
||||
"for" => Ok(StatementInner::For(Box::new(For::from_syntax(
|
||||
"for" => Ok(StatementKind::For(Box::new(For::from_syntax(
|
||||
child, source, context,
|
||||
)?))),
|
||||
"index_assignment" => Ok(StatementInner::IndexAssignment(Box::new(
|
||||
"index_assignment" => Ok(StatementKind::IndexAssignment(Box::new(
|
||||
IndexAssignment::from_syntax(child, source, context)?,
|
||||
))),
|
||||
"match" => Ok(StatementInner::Match(Match::from_syntax(
|
||||
"match" => Ok(StatementKind::Match(Match::from_syntax(
|
||||
child, source, context,
|
||||
)?)),
|
||||
"type_definition" => Ok(StatementInner::TypeDefinition(TypeDefinition::from_syntax(
|
||||
"type_definition" => Ok(StatementKind::TypeDefinition(TypeDefinition::from_syntax(
|
||||
child, source, context
|
||||
)?)),
|
||||
_ => Err(SyntaxError::UnexpectedSyntaxNode {
|
||||
@ -96,17 +113,17 @@ impl AbstractTree for StatementInner {
|
||||
|
||||
fn expected_type(&self, _context: &Context) -> Result<Type, ValidationError> {
|
||||
match self {
|
||||
StatementInner::Assignment(assignment) => assignment.expected_type(_context),
|
||||
StatementInner::Expression(expression) => expression.expected_type(_context),
|
||||
StatementInner::IfElse(if_else) => if_else.expected_type(_context),
|
||||
StatementInner::Match(r#match) => r#match.expected_type(_context),
|
||||
StatementInner::While(r#while) => r#while.expected_type(_context),
|
||||
StatementInner::Block(block) => block.expected_type(_context),
|
||||
StatementInner::For(r#for) => r#for.expected_type(_context),
|
||||
StatementInner::IndexAssignment(index_assignment) => {
|
||||
StatementKind::Assignment(assignment) => assignment.expected_type(_context),
|
||||
StatementKind::Expression(expression) => expression.expected_type(_context),
|
||||
StatementKind::IfElse(if_else) => if_else.expected_type(_context),
|
||||
StatementKind::Match(r#match) => r#match.expected_type(_context),
|
||||
StatementKind::While(r#while) => r#while.expected_type(_context),
|
||||
StatementKind::Block(block) => block.expected_type(_context),
|
||||
StatementKind::For(r#for) => r#for.expected_type(_context),
|
||||
StatementKind::IndexAssignment(index_assignment) => {
|
||||
index_assignment.expected_type(_context)
|
||||
}
|
||||
StatementInner::TypeDefinition(type_definition) => {
|
||||
StatementKind::TypeDefinition(type_definition) => {
|
||||
type_definition.expected_type(_context)
|
||||
}
|
||||
}
|
||||
@ -114,17 +131,17 @@ impl AbstractTree for StatementInner {
|
||||
|
||||
fn validate(&self, _source: &str, _context: &Context) -> Result<(), ValidationError> {
|
||||
match self {
|
||||
StatementInner::Assignment(assignment) => assignment.validate(_source, _context),
|
||||
StatementInner::Expression(expression) => expression.validate(_source, _context),
|
||||
StatementInner::IfElse(if_else) => if_else.validate(_source, _context),
|
||||
StatementInner::Match(r#match) => r#match.validate(_source, _context),
|
||||
StatementInner::While(r#while) => r#while.validate(_source, _context),
|
||||
StatementInner::Block(block) => block.validate(_source, _context),
|
||||
StatementInner::For(r#for) => r#for.validate(_source, _context),
|
||||
StatementInner::IndexAssignment(index_assignment) => {
|
||||
StatementKind::Assignment(assignment) => assignment.validate(_source, _context),
|
||||
StatementKind::Expression(expression) => expression.validate(_source, _context),
|
||||
StatementKind::IfElse(if_else) => if_else.validate(_source, _context),
|
||||
StatementKind::Match(r#match) => r#match.validate(_source, _context),
|
||||
StatementKind::While(r#while) => r#while.validate(_source, _context),
|
||||
StatementKind::Block(block) => block.validate(_source, _context),
|
||||
StatementKind::For(r#for) => r#for.validate(_source, _context),
|
||||
StatementKind::IndexAssignment(index_assignment) => {
|
||||
index_assignment.validate(_source, _context)
|
||||
}
|
||||
StatementInner::TypeDefinition(type_definition) => {
|
||||
StatementKind::TypeDefinition(type_definition) => {
|
||||
type_definition.validate(_source, _context)
|
||||
}
|
||||
}
|
||||
@ -132,39 +149,39 @@ impl AbstractTree for StatementInner {
|
||||
|
||||
fn run(&self, _source: &str, _context: &Context) -> Result<Value, RuntimeError> {
|
||||
match self {
|
||||
StatementInner::Assignment(assignment) => assignment.run(_source, _context),
|
||||
StatementInner::Expression(expression) => expression.run(_source, _context),
|
||||
StatementInner::IfElse(if_else) => if_else.run(_source, _context),
|
||||
StatementInner::Match(r#match) => r#match.run(_source, _context),
|
||||
StatementInner::While(r#while) => r#while.run(_source, _context),
|
||||
StatementInner::Block(block) => block.run(_source, _context),
|
||||
StatementInner::For(r#for) => r#for.run(_source, _context),
|
||||
StatementInner::IndexAssignment(index_assignment) => {
|
||||
StatementKind::Assignment(assignment) => assignment.run(_source, _context),
|
||||
StatementKind::Expression(expression) => expression.run(_source, _context),
|
||||
StatementKind::IfElse(if_else) => if_else.run(_source, _context),
|
||||
StatementKind::Match(r#match) => r#match.run(_source, _context),
|
||||
StatementKind::While(r#while) => r#while.run(_source, _context),
|
||||
StatementKind::Block(block) => block.run(_source, _context),
|
||||
StatementKind::For(r#for) => r#for.run(_source, _context),
|
||||
StatementKind::IndexAssignment(index_assignment) => {
|
||||
index_assignment.run(_source, _context)
|
||||
}
|
||||
StatementInner::TypeDefinition(type_definition) => {
|
||||
StatementKind::TypeDefinition(type_definition) => {
|
||||
type_definition.run(_source, _context)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Format for StatementInner {
|
||||
impl Format for StatementKind {
|
||||
fn format(&self, output: &mut String, indent_level: u8) {
|
||||
StatementInner::indent(output, indent_level);
|
||||
StatementKind::indent(output, indent_level);
|
||||
|
||||
match self {
|
||||
StatementInner::Assignment(assignment) => assignment.format(output, indent_level),
|
||||
StatementInner::Expression(expression) => expression.format(output, indent_level),
|
||||
StatementInner::IfElse(if_else) => if_else.format(output, indent_level),
|
||||
StatementInner::Match(r#match) => r#match.format(output, indent_level),
|
||||
StatementInner::While(r#while) => r#while.format(output, indent_level),
|
||||
StatementInner::Block(block) => block.format(output, indent_level),
|
||||
StatementInner::For(r#for) => r#for.format(output, indent_level),
|
||||
StatementInner::IndexAssignment(index_assignment) => {
|
||||
StatementKind::Assignment(assignment) => assignment.format(output, indent_level),
|
||||
StatementKind::Expression(expression) => expression.format(output, indent_level),
|
||||
StatementKind::IfElse(if_else) => if_else.format(output, indent_level),
|
||||
StatementKind::Match(r#match) => r#match.format(output, indent_level),
|
||||
StatementKind::While(r#while) => r#while.format(output, indent_level),
|
||||
StatementKind::Block(block) => block.format(output, indent_level),
|
||||
StatementKind::For(r#for) => r#for.format(output, indent_level),
|
||||
StatementKind::IndexAssignment(index_assignment) => {
|
||||
index_assignment.format(output, indent_level)
|
||||
}
|
||||
StatementInner::TypeDefinition(type_definition) => {
|
||||
StatementKind::TypeDefinition(type_definition) => {
|
||||
type_definition.format(output, indent_level)
|
||||
}
|
||||
}
|
||||
|
@ -149,14 +149,10 @@ impl Interpreter {
|
||||
|
||||
check_for_error(root, source, &mut cursor)?;
|
||||
|
||||
println!("abstracting...");
|
||||
|
||||
let abstract_tree = Root::from_syntax(syntax_tree.root_node(), source, &self.context)?;
|
||||
|
||||
abstract_tree.validate(source, &self.context)?;
|
||||
|
||||
println!("{abstract_tree:?}");
|
||||
|
||||
Ok(abstract_tree)
|
||||
}
|
||||
|
||||
|
@ -8,12 +8,13 @@ Simple As
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(as
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(type)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(as
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(type))))))
|
||||
|
||||
================================================================================
|
||||
As Function
|
||||
@ -25,13 +26,14 @@ foo as (int) -> int
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(as
|
||||
(expression
|
||||
(identifier))
|
||||
(type
|
||||
(type)
|
||||
(type))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(as
|
||||
(expression
|
||||
(identifier))
|
||||
(type
|
||||
(type)
|
||||
(type)))))))
|
||||
|
||||
================================================================================
|
||||
As List in For Loop
|
||||
@ -43,13 +45,14 @@ for i in foobar as [string] {}
|
||||
|
||||
(root
|
||||
(statement
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(as
|
||||
(expression
|
||||
(identifier))
|
||||
(type
|
||||
(statement_kind
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(as
|
||||
(expression
|
||||
(identifier))
|
||||
(type
|
||||
(identifier)))))
|
||||
(block))))
|
||||
(type
|
||||
(identifier)))))
|
||||
(block)))))
|
||||
|
@ -8,12 +8,14 @@ x = y
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier))))))))
|
||||
|
||||
================================================================================
|
||||
Simple Assignment with Type
|
||||
@ -25,14 +27,16 @@ x <int> = y
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier))))))))
|
||||
|
||||
================================================================================
|
||||
Map Item Assignment
|
||||
@ -44,17 +48,19 @@ x:y = 1
|
||||
|
||||
(root
|
||||
(statement
|
||||
(index_assignment
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(identifier)))
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(statement_kind
|
||||
(index_assignment
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(identifier)))
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
|
||||
================================================================================
|
||||
List Item Assignment
|
||||
@ -66,15 +72,17 @@ x:9 = 'foobar'
|
||||
|
||||
(root
|
||||
(statement
|
||||
(index_assignment
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(value
|
||||
(integer))))
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(statement_kind
|
||||
(index_assignment
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(value
|
||||
(integer))))
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
|
@ -8,15 +8,17 @@ async { output ('Whaddup') }
|
||||
|
||||
(root
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(statement_kind
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
|
||||
================================================================================
|
||||
Complex Async Statements
|
||||
@ -36,37 +38,42 @@ async {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(statement_kind
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(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)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
|
@ -10,15 +10,17 @@ Simple Block
|
||||
|
||||
(root
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(statement_kind
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
|
||||
================================================================================
|
||||
Block with Return
|
||||
@ -34,16 +36,20 @@ Block with Return
|
||||
|
||||
(root
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(statement_kind
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
|
@ -8,9 +8,10 @@ Simple Command
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text))))))
|
||||
|
||||
================================================================================
|
||||
Command Sequence
|
||||
@ -22,13 +23,15 @@ Command Sequence
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)))))
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text))))))
|
||||
|
||||
================================================================================
|
||||
Command with Arguments
|
||||
@ -40,11 +43,12 @@ Command with Arguments
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument))))))
|
||||
|
||||
================================================================================
|
||||
Command Sequence with Arguments
|
||||
@ -57,19 +61,21 @@ Command Sequence with Arguments
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument)
|
||||
(command_argument)
|
||||
(command_argument))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument)
|
||||
(command_argument)
|
||||
(command_argument)))))
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument))))))
|
||||
|
||||
================================================================================
|
||||
Command Sequence with Arguments
|
||||
@ -82,19 +88,21 @@ Command Sequence with Arguments
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument)
|
||||
(command_argument)
|
||||
(command_argument))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument)
|
||||
(command_argument)
|
||||
(command_argument)))))
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument))))))
|
||||
|
||||
================================================================================
|
||||
Command Assignment
|
||||
@ -107,24 +115,28 @@ cat_output = ^cat Cargo.toml;
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument))))))))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)))))))))
|
||||
|
||||
================================================================================
|
||||
Command with Semicolon
|
||||
@ -136,18 +148,21 @@ ls_output = ^ls --long -a; ls_output
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument))))))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
||||
================================================================================
|
||||
Command with Semicolon
|
||||
@ -159,18 +174,21 @@ ls_output = ^ls --long -a; ls_output
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument)
|
||||
(command_argument))))))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
||||
================================================================================
|
||||
Command with Quoted Semicolon
|
||||
@ -182,14 +200,17 @@ ls_output = ^echo ';'; ls_output
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(command
|
||||
(command_text)
|
||||
(command_argument))))))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
@ -9,8 +9,9 @@ not_a_comment
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
||||
================================================================================
|
||||
Partial Line Comments
|
||||
@ -22,8 +23,9 @@ not_a_comment # comment
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
||||
================================================================================
|
||||
Multiline Comments
|
||||
@ -37,9 +39,11 @@ not_a_comment #
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
|
@ -11,11 +11,12 @@ enum Foobar {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(type_definition
|
||||
(enum_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(identifier)))))
|
||||
(statement_kind
|
||||
(type_definition
|
||||
(enum_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(identifier))))))
|
||||
|
||||
================================================================================
|
||||
Nested Enum
|
||||
@ -33,17 +34,18 @@ enum Foobar {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(type_definition
|
||||
(enum_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(type)
|
||||
(identifier)
|
||||
(type_definition
|
||||
(enum_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(identifier)))))))
|
||||
(statement_kind
|
||||
(type_definition
|
||||
(enum_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(type)
|
||||
(identifier)
|
||||
(type_definition
|
||||
(enum_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(identifier))))))))
|
||||
|
||||
================================================================================
|
||||
Simple Enum Instance
|
||||
@ -55,11 +57,12 @@ Foobar::Foo
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(enum_instance
|
||||
(identifier)
|
||||
(identifier))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(enum_instance
|
||||
(identifier)
|
||||
(identifier)))))))
|
||||
|
||||
================================================================================
|
||||
Nested Enum Instance
|
||||
@ -71,16 +74,17 @@ FooBar::Bar(BazBuf::Baz(123))
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(enum_instance
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(enum_instance
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(enum_instance
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(enum_instance
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))
|
||||
|
@ -14,62 +14,67 @@ fib = (i <int>) <int> {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(identifier))
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(identifier))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(math_operator)
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(identifier))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))))))))))))
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(identifier))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))))))))))))))))
|
||||
|
@ -10,28 +10,30 @@ for i in [1, 2, 3] {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(statement_kind
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(identifier)))))))))
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier)))))))))))
|
||||
|
||||
================================================================================
|
||||
Nested For Loop
|
||||
@ -47,21 +49,24 @@ for list in list_of_lists {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(for
|
||||
(identifier)
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier))))))))))))
|
||||
(identifier))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier)))))))))))))))
|
||||
|
@ -8,16 +8,18 @@ Anonymous Function
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))
|
||||
|
||||
================================================================================
|
||||
Function Assignment
|
||||
@ -31,30 +33,33 @@ foobar = (x <int>, y <int>) <int> {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(identifier))
|
||||
(math_operator)
|
||||
(expression
|
||||
(identifier)))))))))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(identifier))
|
||||
(math_operator)
|
||||
(expression
|
||||
(identifier))))))))))))))))
|
||||
|
||||
================================================================================
|
||||
Identifier Function Call
|
||||
@ -66,13 +71,14 @@ foobar("Hiya")
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
|
||||
================================================================================
|
||||
Index Function Call
|
||||
@ -84,17 +90,18 @@ foo:bar("Hiya")
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(identifier))))
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(identifier))))
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
|
||||
================================================================================
|
||||
Double Function Call
|
||||
@ -106,15 +113,16 @@ foobar()("Hiya")
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))))
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))))
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
|
||||
================================================================================
|
||||
Anonymous Function Call
|
||||
@ -126,23 +134,25 @@ Anonymous Function Call
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(value
|
||||
(function
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))))))
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(value
|
||||
(function
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier))))))))
|
||||
(expression
|
||||
(value
|
||||
(string))))))))
|
||||
|
||||
================================================================================
|
||||
Complex Function Call
|
||||
@ -161,29 +171,32 @@ foobar(
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(identifier)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))))
|
||||
|
||||
================================================================================
|
||||
Callback Function Call
|
||||
@ -195,20 +208,22 @@ x(() <bool> { true })
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(function
|
||||
(type_specification
|
||||
(type))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))))))))
|
||||
|
||||
================================================================================
|
||||
Nested Function Call
|
||||
@ -220,14 +235,15 @@ from_json(read('file.json'))
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
|
@ -11,14 +11,18 @@ x123x
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
@ -8,16 +8,18 @@ if true { "True" }
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(statement_kind
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
|
||||
================================================================================
|
||||
Complex If
|
||||
@ -29,46 +31,48 @@ if 1 == 1 && 2 == 2 && 3 == 3 { "True" }
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(statement_kind
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(string)))))))))))
|
||||
|
||||
================================================================================
|
||||
Nested If
|
||||
@ -86,35 +90,39 @@ if true {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(statement_kind
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))))
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))))))
|
||||
|
||||
================================================================================
|
||||
If Else
|
||||
@ -126,22 +134,25 @@ if false { "True" } else { "False" }
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(statement_kind
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
|
||||
================================================================================
|
||||
If Else If
|
||||
@ -157,37 +168,40 @@ if 1 == 1 {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else_if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(statement_kind
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(else_if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
|
||||
================================================================================
|
||||
If Else Else If Else
|
||||
@ -207,49 +221,54 @@ if false {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else_if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else_if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(statement_kind
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(string)))))))
|
||||
(else_if
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
(string)))))))
|
||||
(else_if
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
|
@ -12,37 +12,40 @@ foobar:1:42
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))
|
||||
(index_expression
|
||||
(identifier)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))
|
||||
(index_expression
|
||||
(identifier))))))
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(identifier)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(identifier))))))
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))
|
||||
(index_expression
|
||||
(value
|
||||
(integer))))))))
|
||||
|
||||
================================================================================
|
||||
Nested Indexes
|
||||
@ -54,38 +57,39 @@ Nested Indexes
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))
|
||||
(index_expression
|
||||
(range))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))
|
||||
(index_expression
|
||||
(range)))))))
|
||||
|
||||
================================================================================
|
||||
Function Call Index
|
||||
@ -97,16 +101,17 @@ x:(y()):0
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))))))
|
||||
(index_expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(index
|
||||
(index_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))))))
|
||||
(index_expression
|
||||
(value
|
||||
(integer))))))))
|
||||
|
@ -8,15 +8,16 @@ List Declaration
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
|
||||
================================================================================
|
||||
List Nesting
|
||||
@ -28,21 +29,22 @@ List Nesting
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))))))
|
||||
|
@ -8,15 +8,16 @@ true && false
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))
|
||||
|
||||
================================================================================
|
||||
Logic Sequence
|
||||
@ -28,21 +29,22 @@ Logic Sequence
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))
|
||||
|
||||
================================================================================
|
||||
Complex Logic Sequence
|
||||
@ -56,45 +58,46 @@ Complex Logic Sequence
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(logic
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(identifier))))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))
|
||||
|
@ -8,14 +8,16 @@ Simple Map
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
|
||||
================================================================================
|
||||
Map with Types
|
||||
@ -30,30 +32,33 @@ Map with Types
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type
|
||||
(type)))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type
|
||||
(type)))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(list
|
||||
(expression
|
||||
(value
|
||||
(string)))
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))))
|
||||
|
||||
================================================================================
|
||||
Nested Maps
|
||||
@ -73,35 +78,42 @@ x = {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(identifier)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))
|
||||
(identifier)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))
|
||||
(string)))))
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))))))
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))))
|
||||
|
@ -13,25 +13,29 @@ match x {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(match
|
||||
(expression
|
||||
(identifier))
|
||||
(match_pattern
|
||||
(value
|
||||
(integer)))
|
||||
(statement
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(match
|
||||
(expression
|
||||
(identifier))
|
||||
(match_pattern
|
||||
(value
|
||||
(integer)))
|
||||
(statement
|
||||
(statement_kind
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))))
|
||||
(match_pattern
|
||||
(value
|
||||
(integer)))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))
|
||||
(match_pattern
|
||||
(value
|
||||
(integer)))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))))
|
||||
(boolean)))))))))
|
||||
|
||||
================================================================================
|
||||
Match Enum
|
||||
@ -46,22 +50,25 @@ match foobar {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(match
|
||||
(expression
|
||||
(identifier))
|
||||
(match_pattern
|
||||
(enum_pattern
|
||||
(identifier)
|
||||
(identifier)))
|
||||
(statement
|
||||
(statement_kind
|
||||
(match
|
||||
(expression
|
||||
(value
|
||||
(boolean))))
|
||||
(match_pattern
|
||||
(enum_pattern
|
||||
(identifier)
|
||||
(identifier)))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))))
|
||||
(identifier))
|
||||
(match_pattern
|
||||
(enum_pattern
|
||||
(identifier)
|
||||
(identifier)))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))
|
||||
(match_pattern
|
||||
(enum_pattern
|
||||
(identifier)
|
||||
(identifier)))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))))))
|
||||
|
@ -8,11 +8,12 @@ Simple Command Pipe
|
||||
|
||||
(root
|
||||
(statement
|
||||
(pipe
|
||||
(command
|
||||
(command_text))
|
||||
(command
|
||||
(command_text)))))
|
||||
(statement_kind
|
||||
(pipe
|
||||
(command
|
||||
(command_text))
|
||||
(command
|
||||
(command_text))))))
|
||||
|
||||
================================================================================
|
||||
Simple Function Pipe
|
||||
@ -24,17 +25,18 @@ fs:read('file.txt') | output()
|
||||
|
||||
(root
|
||||
(statement
|
||||
(pipe
|
||||
(function_call
|
||||
(function_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(identifier))))
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))))))
|
||||
(statement_kind
|
||||
(pipe
|
||||
(function_call
|
||||
(function_expression
|
||||
(index
|
||||
(index_expression
|
||||
(identifier))
|
||||
(index_expression
|
||||
(identifier))))
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier)))))))
|
||||
|
@ -8,6 +8,7 @@ Simple Range
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(range)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(range))))))
|
||||
|
@ -10,16 +10,19 @@ x
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
||||
================================================================================
|
||||
Simple Assignment
|
||||
@ -32,21 +35,25 @@ y = "one"
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))
|
||||
|
||||
================================================================================
|
||||
Complex Assignment
|
||||
@ -62,38 +69,42 @@ x = if 1 + 1 == 2 {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(if_else
|
||||
(if
|
||||
(expression
|
||||
(logic
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(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)))))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))))))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))))
|
||||
(else
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))))
|
||||
|
||||
================================================================================
|
||||
Expression Precedence
|
||||
@ -105,28 +116,30 @@ x = 3 == 1 + 2 + 2
|
||||
|
||||
(root
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(expression
|
||||
(math
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(math
|
||||
(expression
|
||||
(logic
|
||||
(math
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(logic
|
||||
(expression
|
||||
(value
|
||||
(integer)))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(math_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))
|
||||
(integer)))))))))))
|
||||
|
@ -11,15 +11,16 @@ struct Foo {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(type_definition
|
||||
(struct_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))))))
|
||||
(statement_kind
|
||||
(type_definition
|
||||
(struct_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type)))))))
|
||||
|
||||
================================================================================
|
||||
Nested Structure
|
||||
@ -38,31 +39,35 @@ struct Foo {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(type_definition
|
||||
(struct_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(float))))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type
|
||||
(identifier)))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(struct_instance
|
||||
(identifier)
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))))
|
||||
(statement_kind
|
||||
(type_definition
|
||||
(struct_definition
|
||||
(identifier)
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(float)))))
|
||||
(identifier)
|
||||
(type_specification
|
||||
(type
|
||||
(identifier)))
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(struct_instance
|
||||
(identifier)
|
||||
(map
|
||||
(identifier)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer))))))))))))))))
|
||||
|
@ -9,13 +9,15 @@ false
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))
|
||||
|
||||
================================================================================
|
||||
Integers
|
||||
@ -28,25 +30,30 @@ Integers
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
|
||||
================================================================================
|
||||
Floats
|
||||
@ -68,43 +75,53 @@ infinity_gauntlet
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(float))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(float)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(float))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(float)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(float))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(float)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(float))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(float)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(float))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(float)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(float))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(float)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(float))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(float)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(float))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(float)))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier)))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement
|
||||
(expression
|
||||
(identifier))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(identifier)))))
|
||||
|
||||
================================================================================
|
||||
Strings
|
||||
@ -116,22 +133,27 @@ Strings
|
||||
|
||||
(root
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
||||
|
@ -10,19 +10,21 @@ while true {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(while
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(expression
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(statement_kind
|
||||
(while
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))
|
||||
(function_call
|
||||
(function_expression
|
||||
(identifier))
|
||||
(expression
|
||||
(value
|
||||
(string))))))))))))
|
||||
|
||||
================================================================================
|
||||
Nested While Loop
|
||||
@ -38,27 +40,31 @@ while true {
|
||||
|
||||
(root
|
||||
(statement
|
||||
(while
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(while
|
||||
(expression
|
||||
(logic
|
||||
(statement_kind
|
||||
(while
|
||||
(expression
|
||||
(value
|
||||
(boolean)))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(while
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(logic
|
||||
(expression
|
||||
(identifier))
|
||||
(logic_operator)
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))))
|
||||
(integer)))))
|
||||
(block
|
||||
(statement
|
||||
(statement_kind
|
||||
(assignment
|
||||
(identifier)
|
||||
(assignment_operator)
|
||||
(statement
|
||||
(statement_kind
|
||||
(expression
|
||||
(value
|
||||
(integer)))))))))))))))))
|
||||
|
@ -15,22 +15,27 @@ module.exports = grammar({
|
||||
prec.left(
|
||||
seq(
|
||||
optional('return'),
|
||||
choice(
|
||||
$.assignment,
|
||||
$.block,
|
||||
$.expression,
|
||||
$.for,
|
||||
$.if_else,
|
||||
$.index_assignment,
|
||||
$.match,
|
||||
$.pipe,
|
||||
$.while,
|
||||
$.type_definition,
|
||||
),
|
||||
$.statement_kind,
|
||||
optional(';'),
|
||||
),
|
||||
),
|
||||
|
||||
statement_kind: $ =>
|
||||
prec.left(
|
||||
choice(
|
||||
$.assignment,
|
||||
$.block,
|
||||
$.expression,
|
||||
$.for,
|
||||
$.if_else,
|
||||
$.index_assignment,
|
||||
$.match,
|
||||
$.pipe,
|
||||
$.while,
|
||||
$.type_definition,
|
||||
),
|
||||
),
|
||||
|
||||
expression: $ =>
|
||||
choice(
|
||||
$._expression_kind,
|
||||
|
@ -36,49 +36,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "assignment"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "block"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "for"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "if_else"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "index_assignment"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "match"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "pipe"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "while"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "type_definition"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "statement_kind"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
@ -95,6 +54,55 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"statement_kind": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "assignment"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "block"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "for"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "if_else"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "index_assignment"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "match"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "pipe"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "while"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "type_definition"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
@ -606,6 +606,21 @@
|
||||
"type": "statement",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "statement_kind",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "statement_kind",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user