diff --git a/src/xml/ast/nodes.rs b/src/xml/ast/nodes.rs index 73acb48..8185192 100644 --- a/src/xml/ast/nodes.rs +++ b/src/xml/ast/nodes.rs @@ -20,6 +20,16 @@ pub enum Statement { iterable: Expression, body: Vec, }, + DebugVar { + name: String, + }, + Open { + filename: String, + }, + Call { + name: String, + args: Vec, + }, ExprStmt { expression: Expression, }, @@ -80,6 +90,8 @@ pub enum BinaryOpKind { Gt, Lte, Gte, + And, + Or, } #[derive(Clone, Copy, Debug, PartialEq)] diff --git a/src/xml/codegen/java.rs b/src/xml/codegen/java.rs index 2092d99..da0a771 100644 --- a/src/xml/codegen/java.rs +++ b/src/xml/codegen/java.rs @@ -66,6 +66,8 @@ impl CodeGen for JavaCodeGen { BinaryOpKind::Gt => ">", BinaryOpKind::Lte => "<=", BinaryOpKind::Gte => ">=", + BinaryOpKind::And => "&&", + BinaryOpKind::Or => "||", }; format!("({} {} {})", left, op_str, right) } @@ -141,4 +143,20 @@ impl CodeGen for JavaCodeGen { fn generate_string_concat(&self, parts: &[String]) -> String { parts.join(" + ") } + + fn generate_debug_var(&self, name: &str) -> String { + format!("{}System.out.println(\"{} = \" + {});", self.indent_str(), name, name) + } + + fn generate_open(&self, filename: &str) -> String { + format!("{}// open(\"{}\")", self.indent_str(), filename) + } + + fn generate_call(&self, name: &str, args: &[String]) -> String { + format!("{}{}({});", self.indent_str(), name, args.join(", ")) + } + + fn generate_expr_stmt(&self, expr: &str) -> String { + format!("{}{};", self.indent_str(), expr) + } } \ No newline at end of file diff --git a/src/xml/codegen/javascript.rs b/src/xml/codegen/javascript.rs index b649d9a..b7e79f2 100644 --- a/src/xml/codegen/javascript.rs +++ b/src/xml/codegen/javascript.rs @@ -55,6 +55,8 @@ impl CodeGen for JavaScriptCodeGen { BinaryOpKind::Gt => ">", BinaryOpKind::Lte => "<=", BinaryOpKind::Gte => ">=", + BinaryOpKind::And => "&&", + BinaryOpKind::Or => "||", }; format!("({} {} {})", left, op_str, right) } @@ -130,4 +132,20 @@ impl CodeGen for JavaScriptCodeGen { fn generate_string_concat(&self, parts: &[String]) -> String { parts.join(" + ") } + + fn generate_debug_var(&self, name: &str) -> String { + format!("{}console.log(\"{} =\", {});", self.indent_str(), name, name) + } + + fn generate_open(&self, filename: &str) -> String { + format!("{}// open(\"{}\")", self.indent_str(), filename) + } + + fn generate_call(&self, name: &str, args: &[String]) -> String { + format!("{}{}({});", self.indent_str(), name, args.join(", ")) + } + + fn generate_expr_stmt(&self, expr: &str) -> String { + format!("{}{};", self.indent_str(), expr) + } } \ No newline at end of file diff --git a/src/xml/codegen/mod.rs b/src/xml/codegen/mod.rs index a2ee2b2..8439c8e 100644 --- a/src/xml/codegen/mod.rs +++ b/src/xml/codegen/mod.rs @@ -23,6 +23,10 @@ pub trait CodeGen { fn generate_if_stmt(&self, condition: &str, then_body: &[String], else_body: &[String]) -> String; fn generate_for_stmt(&self, variable: &str, iterable: &str, body: &[String]) -> String; fn generate_string_concat(&self, parts: &[String]) -> String; + fn generate_debug_var(&self, name: &str) -> String; + fn generate_open(&self, filename: &str) -> String; + fn generate_call(&self, name: &str, args: &[String]) -> String; + fn generate_expr_stmt(&self, expr: &str) -> String; } fn walk_expression(codegen: &dyn CodeGen, expr: &Expression) -> String { @@ -81,7 +85,13 @@ fn walk_statement(codegen: &dyn CodeGen, stmt: &Statement) -> String { } Statement::ExprStmt { expression } => { let e = codegen.generate_expression(expression); - codegen.generate_var_decl("_", Some(&e), AssignmentType::Equals) + codegen.generate_expr_stmt(&e) + } + Statement::DebugVar { name } => codegen.generate_debug_var(name), + Statement::Open { filename } => codegen.generate_open(filename), + Statement::Call { name, args } => { + let rendered_args: Vec = args.iter().map(|a| codegen.generate_expression(a)).collect(); + codegen.generate_call(name, &rendered_args) } } } \ No newline at end of file diff --git a/src/xml/codegen/python.rs b/src/xml/codegen/python.rs index b82bf0b..131e095 100644 --- a/src/xml/codegen/python.rs +++ b/src/xml/codegen/python.rs @@ -55,6 +55,8 @@ impl CodeGen for PythonCodeGen { BinaryOpKind::Gt => ">", BinaryOpKind::Lte => "<=", BinaryOpKind::Gte => ">=", + BinaryOpKind::And => "and", + BinaryOpKind::Or => "or", }; format!("({} {} {})", left, op_str, right) } @@ -134,4 +136,20 @@ impl CodeGen for PythonCodeGen { fn generate_string_concat(&self, parts: &[String]) -> String { parts.join(" + ") } + + fn generate_debug_var(&self, name: &str) -> String { + format!("{}print(\"{} =\", {})", self.indent_str(), name, name) + } + + fn generate_open(&self, filename: &str) -> String { + format!("{}# open(\"{}\")", self.indent_str(), filename) + } + + fn generate_call(&self, name: &str, args: &[String]) -> String { + format!("{}{}({})", self.indent_str(), name, args.join(", ")) + } + + fn generate_expr_stmt(&self, expr: &str) -> String { + format!("{}{}", self.indent_str(), expr) + } } \ No newline at end of file diff --git a/src/xml/codegen/rust.rs b/src/xml/codegen/rust.rs index 78a6dcd..6fbfb1b 100644 --- a/src/xml/codegen/rust.rs +++ b/src/xml/codegen/rust.rs @@ -59,6 +59,8 @@ impl CodeGen for RustCodeGen { BinaryOpKind::Gt => ">", BinaryOpKind::Lte => "<=", BinaryOpKind::Gte => ">=", + BinaryOpKind::And => "&&", + BinaryOpKind::Or => "||", }; format!("({} {} {})", left, op_str, right) } @@ -134,4 +136,20 @@ impl CodeGen for RustCodeGen { fn generate_string_concat(&self, parts: &[String]) -> String { parts.join(" + ") } + + fn generate_debug_var(&self, name: &str) -> String { + format!("{}println!(\"{} = {{}}\", {});", self.indent_str(), name, name) + } + + fn generate_open(&self, filename: &str) -> String { + format!("{}// open(\"{}\")", self.indent_str(), filename) + } + + fn generate_call(&self, name: &str, args: &[String]) -> String { + format!("{}{}({});", self.indent_str(), name, args.join(", ")) + } + + fn generate_expr_stmt(&self, expr: &str) -> String { + format!("{}{};", self.indent_str(), expr) + } } \ No newline at end of file diff --git a/src/xml/parser/grammar.lalrpop b/src/xml/parser/grammar.lalrpop index bd6cbfd..da1babc 100644 --- a/src/xml/parser/grammar.lalrpop +++ b/src/xml/parser/grammar.lalrpop @@ -32,6 +32,8 @@ Stmt: Statement = { iterable: iter, body, }, + "DEBUGVAR" => Statement::DebugVar { name }, + "Open" => Statement::Open { filename }, }; Expr: Expression = { @@ -42,7 +44,7 @@ OrExpr: Expression = { AndExpr, "||" => Expression::BinaryOp { left: Box::new(left), - op: BinaryOpKind::Add, + op: BinaryOpKind::Or, right: Box::new(right), }, }; @@ -51,15 +53,14 @@ AndExpr: Expression = { CmpExpr, "&&" => Expression::BinaryOp { left: Box::new(left), - op: BinaryOpKind::Add, + op: BinaryOpKind::And, right: Box::new(right), }, }; CmpExpr: Expression = { AddExpr, - "==" => Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Eq, right: Box::new(right) }, - "!=" => Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Neq, right: Box::new(right) }, + "=" => Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Eq, right: Box::new(right) }, "<=" => Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Lte, right: Box::new(right) }, ">=" => Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Gte, right: Box::new(right) }, "<" => Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Lt, right: Box::new(right) }, @@ -133,8 +134,8 @@ match { "EndFor", "True", "False", - "==", - "!=", + "DEBUGVAR", + "Open", "<=", ">=", "&&", diff --git a/src/xml/parser/grammar.rs b/src/xml/parser/grammar.rs deleted file mode 100644 index 72f64df..0000000 --- a/src/xml/parser/grammar.rs +++ /dev/null @@ -1,3487 +0,0 @@ -// auto-generated: "lalrpop 0.23.1" -// sha3: d5a4b6662094bf1eda39b3740e0d893d7038b0f7f33e762bdd01b0fb777990c3 -use crate::xml::ast::nodes::{AssignmentType, BinaryOpKind, Expression, LiteralValue, Program, Statement, UnaryOpKind}; -#[allow(unused_extern_crates)] -extern crate lalrpop_util as __lalrpop_util; -#[allow(unused_imports)] -use self::__lalrpop_util::state_machine as __state_machine; -#[allow(unused_extern_crates)] -extern crate alloc; - -#[rustfmt::skip] -#[allow(explicit_outlives_requirements, non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports, unused_parens, clippy::needless_lifetimes, clippy::type_complexity, clippy::needless_return, clippy::too_many_arguments, clippy::match_single_binding, clippy::clone_on_copy, clippy::unit_arg)] -mod __parse__Program { - - use crate::xml::ast::nodes::{AssignmentType, BinaryOpKind, Expression, LiteralValue, Program, Statement, UnaryOpKind}; - #[allow(unused_extern_crates)] - extern crate lalrpop_util as __lalrpop_util; - #[allow(unused_imports)] - use self::__lalrpop_util::state_machine as __state_machine; - #[allow(unused_extern_crates)] - extern crate alloc; - use self::__lalrpop_util::lexer::Token; - #[allow(dead_code)] - pub(crate) enum __Symbol<'input> - { - Variant0(&'input str), - Variant1(Expression), - Variant2(alloc::vec::Vec), - Variant3(Vec), - Variant4(Option>), - Variant5(String), - Variant6(f64), - Variant7(Program), - Variant8(Statement), - Variant9(alloc::vec::Vec), - Variant10(Vec), - } - const __ACTION: &[i8] = &[ - // State 0 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 5, 0, 0, - // State 1 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 5, 0, 0, - // State 2 - 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 3 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 4 - 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 5 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 6 - 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 7 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 8 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 9 - 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 10 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 11 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 12 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 13 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 14 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 15 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 16 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 17 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 18 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 19 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 20 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 5, 0, 0, - // State 21 - 50, 51, 36, 6, 0, 7, 0, 8, 71, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 22 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 23 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 24 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 25 - 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 26 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 27 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 5, 0, 0, - // State 28 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -53, -53, -53, 0, 3, 4, 0, 0, 0, 5, 0, 0, - // State 29 - 50, 51, 36, 6, 0, 7, 0, 8, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 48, 0, 0, 0, 0, 49, 0, 0, 0, - // State 30 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 0, 0, 5, 0, 0, - // State 31 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 32 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -51, -51, -51, 0, -51, -51, 0, 0, 0, -51, 0, 0, - // State 33 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -52, -52, -52, 0, -52, -52, 0, 0, 0, -52, 0, 0, - // State 34 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, - // State 35 - 0, 0, 0, -34, -34, 0, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, 0, -34, -34, -34, 0, -34, -34, -34, -34, 0, -34, 0, -34, - // State 36 - 0, 0, 0, 0, -22, 0, -22, 0, -22, 0, 12, -22, 13, 0, -22, -22, 0, -22, -22, -22, 0, -22, -22, -22, 0, -22, -22, 0, -22, 0, -22, 0, -22, - // State 37 - 0, 0, 0, 0, 0, 0, 14, 0, -39, 0, 0, -39, 0, 0, 0, 0, 0, 0, 0, 0, 0, -39, -39, -39, 0, -39, -39, 0, -39, 0, -39, 0, -39, - // State 38 - 0, 0, 0, 0, -54, 0, -54, 0, -54, -54, -54, -54, -54, -54, -54, -54, 0, -54, -54, -54, 0, -54, -54, -54, 0, -54, -54, 0, -54, 0, -54, 0, -54, - // State 39 - 0, 0, 0, 0, 15, 0, -9, 0, -9, 0, 0, -9, 0, 0, 16, 17, 0, 18, 19, 20, 0, -9, -9, -9, 0, -9, -9, 0, -9, 0, -9, 0, -9, - // State 40 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, - // State 41 - 0, 0, 0, 0, -20, 0, -20, 22, -20, -20, -20, -20, -20, -20, -20, -20, 0, -20, -20, -20, 0, -20, -20, -20, 0, -20, -20, 0, -20, 0, -20, 0, -20, - // State 42 - 0, 0, 0, 0, -6, 0, -6, 0, -6, 23, -6, -6, -6, 24, -6, -6, 0, -6, -6, -6, 0, -6, -6, -6, 0, -6, -6, 0, -6, 0, -6, 0, -6, - // State 43 - 0, 0, 0, 0, -12, 0, -12, 0, -12, -12, -12, -12, -12, -12, -12, -12, 0, -12, -12, -12, 0, -12, -12, -12, 0, -12, -12, 0, -12, 0, -12, 0, -12, - // State 44 - 0, 0, 0, 0, 0, 0, 0, 0, -33, 0, 0, -33, 0, 0, 0, 0, 0, 0, 0, 0, 0, -33, -33, -33, 0, -33, -33, 0, -33, 0, -33, 0, 25, - // State 45 - 0, 0, 0, 0, -11, 0, -11, 0, -11, -11, -11, -11, -11, -11, -11, -11, 0, -11, -11, -11, 0, -11, -11, -11, 0, -11, -11, 0, -11, 0, -11, 0, -11, - // State 46 - 0, 0, 0, 0, -35, 0, -35, 0, -35, -35, -35, -35, -35, -35, -35, -35, 0, -35, -35, -35, 0, -35, -35, -35, 0, -35, -35, 0, -35, 0, -35, 0, -35, - // State 47 - 0, 0, 0, 0, -14, 0, -14, 0, -14, -14, -14, -14, -14, -14, -14, -14, 0, -14, -14, -14, 0, -14, -14, -14, 0, -14, -14, 0, -14, 0, -14, 0, -14, - // State 48 - 0, 0, 0, 0, -13, 0, -13, 0, -13, -13, -13, -13, -13, -13, -13, -13, 0, -13, -13, -13, 0, -13, -13, -13, 0, -13, -13, 0, -13, 0, -13, 0, -13, - // State 49 - 0, 0, 0, 0, -43, 0, -43, 0, -43, -43, -43, -43, -43, -43, -43, -43, 0, -43, -43, -43, 0, -43, -43, -43, 0, -43, -43, 0, -43, 0, -43, 0, -43, - // State 50 - 0, 0, 0, 0, -38, 0, -38, 0, -38, -38, -38, -38, -38, -38, -38, -38, 0, -38, -38, -38, 0, -38, -38, -38, 0, -38, -38, 0, -38, 0, -38, 0, -38, - // State 51 - 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 52 - 0, 0, 0, 0, -55, 0, -55, 0, -55, -55, -55, -55, -55, -55, -55, -55, 0, -55, -55, -55, 0, -55, -55, -55, 0, -55, -55, 0, -55, 0, -55, 0, -55, - // State 53 - 0, 0, 0, 0, -17, 0, -17, 0, -17, -17, -17, -17, -17, -17, -17, -17, 0, -17, -17, -17, 0, -17, -17, -17, 0, -17, -17, 0, -17, 0, -17, 0, -17, - // State 54 - 0, 0, 0, 0, 0, 0, 0, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 55 - 0, 0, 0, 0, -56, 0, -56, 0, -56, -56, -56, -56, -56, -56, -56, -56, 0, -56, -56, -56, 0, -56, -56, -56, 0, -56, -56, 0, -56, 0, -56, 0, -56, - // State 56 - 0, 0, 0, 0, -19, 0, -19, 0, -19, -19, -19, -19, -19, -19, -19, -19, 0, -19, -19, -19, 0, -19, -19, -19, 0, -19, -19, 0, -19, 0, -19, 0, -19, - // State 57 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 0, - // State 58 - 0, 0, 0, 0, -7, 0, -7, 0, -7, 23, -7, -7, -7, 24, -7, -7, 0, -7, -7, -7, 0, -7, -7, -7, 0, -7, -7, 0, -7, 0, -7, 0, -7, - // State 59 - 0, 0, 0, 0, -8, 0, -8, 0, -8, 23, -8, -8, -8, 24, -8, -8, 0, -8, -8, -8, 0, -8, -8, -8, 0, -8, -8, 0, -8, 0, -8, 0, -8, - // State 60 - 0, 0, 0, 0, 15, 0, -10, 0, -10, 0, 0, -10, 0, 0, 16, 17, 0, 18, 19, 20, 0, -10, -10, -10, 0, -10, -10, 0, -10, 0, -10, 0, -10, - // State 61 - 0, 0, 0, 0, -24, 0, -24, 0, -24, 0, 12, -24, 13, 0, -24, -24, 0, -24, -24, -24, 0, -24, -24, -24, 0, -24, -24, 0, -24, 0, -24, 0, -24, - // State 62 - 0, 0, 0, 0, -27, 0, -27, 0, -27, 0, 12, -27, 13, 0, -27, -27, 0, -27, -27, -27, 0, -27, -27, -27, 0, -27, -27, 0, -27, 0, -27, 0, -27, - // State 63 - 0, 0, 0, 0, -25, 0, -25, 0, -25, 0, 12, -25, 13, 0, -25, -25, 0, -25, -25, -25, 0, -25, -25, -25, 0, -25, -25, 0, -25, 0, -25, 0, -25, - // State 64 - 0, 0, 0, 0, -23, 0, -23, 0, -23, 0, 12, -23, 13, 0, -23, -23, 0, -23, -23, -23, 0, -23, -23, -23, 0, -23, -23, 0, -23, 0, -23, 0, -23, - // State 65 - 0, 0, 0, 0, -28, 0, -28, 0, -28, 0, 12, -28, 13, 0, -28, -28, 0, -28, -28, -28, 0, -28, -28, -28, 0, -28, -28, 0, -28, 0, -28, 0, -28, - // State 66 - 0, 0, 0, 0, -26, 0, -26, 0, -26, 0, 12, -26, 13, 0, -26, -26, 0, -26, -26, -26, 0, -26, -26, -26, 0, -26, -26, 0, -26, 0, -26, 0, -26, - // State 67 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 68 - 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 69 - 0, 0, 0, 0, 0, 0, 0, 0, -29, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 70 - 0, 0, 0, 0, -16, 0, -16, 0, -16, -16, -16, -16, -16, -16, -16, -16, 0, -16, -16, -16, 0, -16, -16, -16, 0, -16, -16, 0, -16, 0, -16, 0, -16, - // State 71 - 0, 0, 0, 0, -36, 0, -36, 0, -36, -36, -36, -36, -36, -36, -36, -36, 0, -36, -36, -36, 0, -36, -36, -36, 0, -36, -36, 0, -36, 0, -36, 0, -36, - // State 72 - 0, 0, 0, 0, -37, 0, -37, 0, -37, -37, -37, -37, -37, -37, -37, -37, 0, -37, -37, -37, 0, -37, -37, -37, 0, -37, -37, 0, -37, 0, -37, 0, -37, - // State 73 - 0, 0, 0, 0, 0, 0, 14, 0, -40, 0, 0, -40, 0, 0, 0, 0, 0, 0, 0, 0, 0, -40, -40, -40, 0, -40, -40, 0, -40, 0, -40, 0, -40, - // State 74 - 0, 0, 0, 0, -18, 0, -18, 0, -18, -18, -18, -18, -18, -18, -18, -18, 0, -18, -18, -18, 0, -18, -18, -18, 0, -18, -18, 0, -18, 0, -18, 0, -18, - // State 75 - 0, 0, 0, 0, -21, 0, -21, 0, -21, -21, -21, -21, -21, -21, -21, -21, 0, -21, -21, -21, 0, -21, -21, -21, 0, -21, -21, 0, -21, 0, -21, 0, -21, - // State 76 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -45, -45, -45, 0, -45, -45, 0, 0, 0, -45, 0, 0, - // State 77 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -44, -44, -44, 0, -44, -44, 0, 0, 0, -44, 0, 0, - // State 78 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 79 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -46, -46, -46, 0, -46, -46, 0, 0, 0, -46, 0, 0, - // State 80 - 0, 0, 0, 0, 0, 0, 0, 0, -30, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 81 - 0, 0, 0, 0, -15, 0, -15, 0, -15, -15, -15, -15, -15, -15, -15, -15, 0, -15, -15, -15, 0, -15, -15, -15, 0, -15, -15, 0, -15, 0, -15, 0, -15, - // State 82 - -4, -4, -4, -4, 0, -4, 0, -4, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, -4, 0, 0, 0, 0, -4, 0, 0, 0, - // State 83 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -48, -48, -48, 0, -48, -48, 0, 0, 0, -48, 0, 0, - // State 84 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, - // State 85 - -5, -5, -5, -5, 0, -5, 0, -5, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, -5, 0, 0, 0, 0, -5, 0, 0, 0, - // State 86 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -47, -47, -47, 0, -47, -47, 0, 0, 0, -47, 0, 0, - ]; - fn __action(state: i8, integer: usize) -> i8 { - __ACTION[(state as usize) * 33 + integer] - } - const __EOF_ACTION: &[i8] = &[ - // State 0 - -41, - // State 1 - -42, - // State 2 - 0, - // State 3 - 0, - // State 4 - 0, - // State 5 - 0, - // State 6 - 0, - // State 7 - 0, - // State 8 - 0, - // State 9 - 0, - // State 10 - 0, - // State 11 - 0, - // State 12 - 0, - // State 13 - 0, - // State 14 - 0, - // State 15 - 0, - // State 16 - 0, - // State 17 - 0, - // State 18 - 0, - // State 19 - 0, - // State 20 - 0, - // State 21 - 0, - // State 22 - 0, - // State 23 - 0, - // State 24 - 0, - // State 25 - 0, - // State 26 - 0, - // State 27 - 0, - // State 28 - 0, - // State 29 - 0, - // State 30 - 0, - // State 31 - -57, - // State 32 - -51, - // State 33 - -52, - // State 34 - 0, - // State 35 - -34, - // State 36 - -22, - // State 37 - -39, - // State 38 - -54, - // State 39 - -9, - // State 40 - 0, - // State 41 - -20, - // State 42 - -6, - // State 43 - -12, - // State 44 - -33, - // State 45 - -11, - // State 46 - -35, - // State 47 - -14, - // State 48 - -13, - // State 49 - -43, - // State 50 - -38, - // State 51 - 0, - // State 52 - -55, - // State 53 - -17, - // State 54 - 0, - // State 55 - -56, - // State 56 - -19, - // State 57 - 0, - // State 58 - -7, - // State 59 - -8, - // State 60 - -10, - // State 61 - -24, - // State 62 - -27, - // State 63 - -25, - // State 64 - -23, - // State 65 - -28, - // State 66 - -26, - // State 67 - 0, - // State 68 - 0, - // State 69 - 0, - // State 70 - -16, - // State 71 - -36, - // State 72 - -37, - // State 73 - -40, - // State 74 - -18, - // State 75 - -21, - // State 76 - -45, - // State 77 - -44, - // State 78 - 0, - // State 79 - -46, - // State 80 - 0, - // State 81 - -15, - // State 82 - 0, - // State 83 - -48, - // State 84 - 0, - // State 85 - 0, - // State 86 - -47, - ]; - fn __goto(state: i8, nt: usize) -> i8 { - match nt { - 2 => 29, - 3 => match state { - 14 => 61, - 15 => 62, - 16 => 63, - 17 => 64, - 18 => 65, - 19 => 66, - _ => 36, - }, - 4 => match state { - 24 => 73, - _ => 37, - }, - 5 => 38, - 6 => match state { - 13 => 60, - _ => 39, - }, - 7 => 68, - 9 => match state { - 3 => 40, - 7 => 54, - 21 => 69, - 26 => 77, - 29 => 80, - _ => 27, - }, - 10 => match state { - 2 => 34, - 4 => 51, - 6 => 53, - 9 => 56, - 25 => 74, - _ => 41, - }, - 11 => match state { - 11 => 58, - 12 => 59, - _ => 42, - }, - 12 => 43, - 13 => 44, - 14 => 31, - 15 => 45, - 16 => match state { - 1 | 28 => 33, - _ => 32, - }, - 18 => match state { - 0 => 1, - _ => 28, - }, - 19 => match state { - 27 => 78, - 30 => 84, - _ => 67, - }, - 20 => match state { - 5 => 52, - 8 => 55, - 22 => 71, - 23 => 72, - _ => 46, - }, - _ => 0, - } - } - #[allow(clippy::needless_raw_string_hashes)] - const __TERMINAL: &[&str] = &[ - r###"r#"\"[^\"]*\""#"###, - r###"r#"[0-9]+(\\.[0-9]+)?"#"###, - r###"r#"[a-zA-Z_][a-zA-Z0-9_]*"#"###, - r###""!""###, - r###""!=""###, - r###""$""###, - r###""&&""###, - r###""(""###, - r###"")""###, - r###""*""###, - r###""+""###, - r###"",""###, - r###""-""###, - r###""/""###, - r###""<""###, - r###""<=""###, - r###""=""###, - r###""==""###, - r###"">""###, - r###"">=""###, - r###""@""###, - r###""Else""###, - r###""EndFor""###, - r###""EndIf""###, - r###""False""###, - r###""For""###, - r###""If""###, - r###""In""###, - r###""Then""###, - r###""True""###, - r###""Var""###, - r###""assigned""###, - r###""||""###, - ]; - fn __expected_tokens(__state: i8) -> alloc::vec::Vec { - __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| { - let next_state = __action(__state, index); - if next_state == 0 { - None - } else { - Some(alloc::string::ToString::to_string(terminal)) - } - }).collect() - } - fn __expected_tokens_from_states< - 'input, - >( - __states: &[i8], - _: core::marker::PhantomData<(&'input ())>, - ) -> alloc::vec::Vec - { - __TERMINAL.iter().enumerate().filter_map(|(index, terminal)| { - if __accepts(None, __states, Some(index), core::marker::PhantomData::<(&())>) { - Some(alloc::string::ToString::to_string(terminal)) - } else { - None - } - }).collect() - } - struct __StateMachine<'input> - where - { - input: &'input str, - __phantom: core::marker::PhantomData<(&'input ())>, - } - impl<'input> __state_machine::ParserDefinition for __StateMachine<'input> - where - { - type Location = usize; - type Error = &'static str; - type Token = Token<'input>; - type TokenIndex = usize; - type Symbol = __Symbol<'input>; - type Success = Program; - type StateIndex = i8; - type Action = i8; - type ReduceIndex = i8; - type NonterminalIndex = usize; - - #[inline] - fn start_location(&self) -> Self::Location { - Default::default() - } - - #[inline] - fn start_state(&self) -> Self::StateIndex { - 0 - } - - #[inline] - fn token_to_index(&self, token: &Self::Token) -> Option { - __token_to_integer(token, core::marker::PhantomData::<(&())>) - } - - #[inline] - fn action(&self, state: i8, integer: usize) -> i8 { - __action(state, integer) - } - - #[inline] - fn error_action(&self, state: i8) -> i8 { - __action(state, 33 - 1) - } - - #[inline] - fn eof_action(&self, state: i8) -> i8 { - __EOF_ACTION[state as usize] - } - - #[inline] - fn goto(&self, state: i8, nt: usize) -> i8 { - __goto(state, nt) - } - - fn token_to_symbol(&self, token_index: usize, token: Self::Token) -> Self::Symbol { - __token_to_symbol(token_index, token, core::marker::PhantomData::<(&())>) - } - - fn expected_tokens(&self, state: i8) -> alloc::vec::Vec { - __expected_tokens(state) - } - - fn expected_tokens_from_states(&self, states: &[i8]) -> alloc::vec::Vec { - __expected_tokens_from_states(states, core::marker::PhantomData::<(&())>) - } - - #[inline] - fn uses_error_recovery(&self) -> bool { - false - } - - #[inline] - fn error_recovery_symbol( - &self, - recovery: __state_machine::ErrorRecovery, - ) -> Self::Symbol { - panic!("error recovery not enabled for this grammar") - } - - fn reduce( - &mut self, - action: i8, - start_location: Option<&Self::Location>, - states: &mut alloc::vec::Vec, - symbols: &mut alloc::vec::Vec<__state_machine::SymbolTriple>, - ) -> Option<__state_machine::ParseResult> { - __reduce( - self.input, - action, - start_location, - states, - symbols, - core::marker::PhantomData::<(&())>, - ) - } - - fn simulate_reduce(&self, action: i8) -> __state_machine::SimulatedReduce { - __simulate_reduce(action, core::marker::PhantomData::<(&())>) - } - } - fn __token_to_integer< - 'input, - >( - __token: &Token<'input>, - _: core::marker::PhantomData<(&'input ())>, - ) -> Option - { - #[warn(unused_variables)] - match __token { - Token(0, _) if true => Some(0), - Token(1, _) if true => Some(1), - Token(2, _) if true => Some(2), - Token(4, _) if true => Some(3), - Token(5, _) if true => Some(4), - Token(6, _) if true => Some(5), - Token(7, _) if true => Some(6), - Token(8, _) if true => Some(7), - Token(9, _) if true => Some(8), - Token(10, _) if true => Some(9), - Token(11, _) if true => Some(10), - Token(12, _) if true => Some(11), - Token(13, _) if true => Some(12), - Token(14, _) if true => Some(13), - Token(15, _) if true => Some(14), - Token(16, _) if true => Some(15), - Token(17, _) if true => Some(16), - Token(18, _) if true => Some(17), - Token(19, _) if true => Some(18), - Token(20, _) if true => Some(19), - Token(21, _) if true => Some(20), - Token(22, _) if true => Some(21), - Token(23, _) if true => Some(22), - Token(24, _) if true => Some(23), - Token(25, _) if true => Some(24), - Token(26, _) if true => Some(25), - Token(27, _) if true => Some(26), - Token(28, _) if true => Some(27), - Token(29, _) if true => Some(28), - Token(30, _) if true => Some(29), - Token(31, _) if true => Some(30), - Token(32, _) if true => Some(31), - Token(33, _) if true => Some(32), - _ => None, - } - } - fn __token_to_symbol< - 'input, - >( - __token_index: usize, - __token: Token<'input>, - _: core::marker::PhantomData<(&'input ())>, - ) -> __Symbol<'input> - { - #[allow(clippy::manual_range_patterns)]match __token_index { - 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 => match __token { - Token(0, __tok0) | Token(1, __tok0) | Token(2, __tok0) | Token(4, __tok0) | Token(5, __tok0) | Token(6, __tok0) | Token(7, __tok0) | Token(8, __tok0) | Token(9, __tok0) | Token(10, __tok0) | Token(11, __tok0) | Token(12, __tok0) | Token(13, __tok0) | Token(14, __tok0) | Token(15, __tok0) | Token(16, __tok0) | Token(17, __tok0) | Token(18, __tok0) | Token(19, __tok0) | Token(20, __tok0) | Token(21, __tok0) | Token(22, __tok0) | Token(23, __tok0) | Token(24, __tok0) | Token(25, __tok0) | Token(26, __tok0) | Token(27, __tok0) | Token(28, __tok0) | Token(29, __tok0) | Token(30, __tok0) | Token(31, __tok0) | Token(32, __tok0) | Token(33, __tok0) if true => __Symbol::Variant0(__tok0), - _ => unreachable!(), - }, - _ => unreachable!(), - } - } - fn __simulate_reduce< - 'input, - >( - __reduce_index: i8, - _: core::marker::PhantomData<(&'input ())>, - ) -> __state_machine::SimulatedReduce<__StateMachine<'input>> - { - match __reduce_index { - 0 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 0, - } - } - 1 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 0, - nonterminal_produced: 1, - } - } - 2 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 1, - } - } - 3 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 2, - } - } - 4 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 2, - } - } - 5 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 3, - } - } - 6 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 3, - } - } - 7 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 3, - } - } - 8 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 4, - } - } - 9 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 4, - } - } - 10 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 5, - } - } - 11 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 5, - } - } - 12 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 5, - } - } - 13 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 5, - } - } - 14 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 4, - nonterminal_produced: 5, - } - } - 15 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 5, - } - } - 16 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 5, - } - } - 17 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 5, - } - } - 18 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 5, - } - } - 19 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 5, - } - } - 20 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 5, - } - } - 21 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 6, - } - } - 22 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 6, - } - } - 23 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 6, - } - } - 24 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 6, - } - } - 25 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 6, - } - } - 26 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 6, - } - } - 27 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 6, - } - } - 28 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 7, - } - } - 29 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 7, - } - } - 30 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 8, - } - } - 31 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 0, - nonterminal_produced: 8, - } - } - 32 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 9, - } - } - 33 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 10, - } - } - 34 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 11, - } - } - 35 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 11, - } - } - 36 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 11, - } - } - 37 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 12, - } - } - 38 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 13, - } - } - 39 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 3, - nonterminal_produced: 13, - } - } - 40 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 0, - nonterminal_produced: 14, - } - } - 41 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 14, - } - } - 42 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 15, - } - } - 43 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 4, - nonterminal_produced: 16, - } - } - 44 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 4, - nonterminal_produced: 16, - } - } - 45 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 5, - nonterminal_produced: 16, - } - } - 46 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 7, - nonterminal_produced: 16, - } - } - 47 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 6, - nonterminal_produced: 16, - } - } - 48 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 0, - nonterminal_produced: 17, - } - } - 49 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 17, - } - } - 50 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 18, - } - } - 51 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 18, - } - } - 52 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 19, - } - } - 53 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 1, - nonterminal_produced: 20, - } - } - 54 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 20, - } - } - 55 => { - __state_machine::SimulatedReduce::Reduce { - states_to_pop: 2, - nonterminal_produced: 20, - } - } - 56 => __state_machine::SimulatedReduce::Accept, - _ => panic!("invalid reduction index {__reduce_index}") - } - } - pub struct ProgramParser { - builder: __lalrpop_util::lexer::MatcherBuilder, - _priv: (), - } - - impl Default for ProgramParser { fn default() -> Self { Self::new() } } - impl ProgramParser { - pub fn new() -> ProgramParser { - let __builder = super::__intern_token::new_builder(); - ProgramParser { - builder: __builder, - _priv: (), - } - } - - #[allow(dead_code)] - pub fn parse< - 'input, - >( - &self, - input: &'input str, - ) -> Result, &'static str>> - { - let mut __tokens = self.builder.matcher(input); - __state_machine::Parser::drive( - __StateMachine { - input, - __phantom: core::marker::PhantomData::<(&())>, - }, - __tokens, - ) - } - } - fn __accepts< - 'input, - >( - __error_state: Option, - __states: &[i8], - __opt_integer: Option, - _: core::marker::PhantomData<(&'input ())>, - ) -> bool - { - let mut __states = __states.to_vec(); - __states.extend(__error_state); - loop { - let mut __states_len = __states.len(); - let __top = __states[__states_len - 1]; - let __action = match __opt_integer { - None => __EOF_ACTION[__top as usize], - Some(__integer) => __action(__top, __integer), - }; - if __action == 0 { return false; } - if __action > 0 { return true; } - let (__to_pop, __nt) = match __simulate_reduce(-(__action + 1), core::marker::PhantomData::<(&())>) { - __state_machine::SimulatedReduce::Reduce { - states_to_pop, nonterminal_produced - } => (states_to_pop, nonterminal_produced), - __state_machine::SimulatedReduce::Accept => return true, - }; - __states_len -= __to_pop; - __states.truncate(__states_len); - let __top = __states[__states_len - 1]; - let __next_state = __goto(__top, __nt); - __states.push(__next_state); - } - } - fn __reduce< - 'input, - >( - input: &'input str, - __action: i8, - __lookahead_start: Option<&usize>, - __states: &mut alloc::vec::Vec, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> Option, &'static str>>> - { - let (__pop_states, __nonterminal) = match __action { - 0 => { - __reduce0(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 1 => { - __reduce1(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 2 => { - __reduce2(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 3 => { - __reduce3(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 4 => { - __reduce4(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 5 => { - __reduce5(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 6 => { - __reduce6(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 7 => { - __reduce7(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 8 => { - __reduce8(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 9 => { - __reduce9(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 10 => { - __reduce10(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 11 => { - __reduce11(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 12 => { - __reduce12(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 13 => { - __reduce13(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 14 => { - __reduce14(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 15 => { - __reduce15(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 16 => { - __reduce16(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 17 => { - __reduce17(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 18 => { - __reduce18(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 19 => { - __reduce19(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 20 => { - __reduce20(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 21 => { - __reduce21(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 22 => { - __reduce22(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 23 => { - __reduce23(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 24 => { - __reduce24(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 25 => { - __reduce25(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 26 => { - __reduce26(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 27 => { - __reduce27(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 28 => { - __reduce28(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 29 => { - __reduce29(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 30 => { - __reduce30(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 31 => { - __reduce31(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 32 => { - __reduce32(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 33 => { - __reduce33(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 34 => { - __reduce34(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 35 => { - __reduce35(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 36 => { - __reduce36(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 37 => { - __reduce37(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 38 => { - __reduce38(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 39 => { - __reduce39(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 40 => { - __reduce40(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 41 => { - __reduce41(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 42 => { - __reduce42(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 43 => { - __reduce43(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 44 => { - __reduce44(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 45 => { - __reduce45(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 46 => { - __reduce46(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 47 => { - __reduce47(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 48 => { - __reduce48(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 49 => { - __reduce49(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 50 => { - __reduce50(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 51 => { - __reduce51(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 52 => { - __reduce52(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 53 => { - __reduce53(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 54 => { - __reduce54(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 55 => { - __reduce55(input, __lookahead_start, __symbols, core::marker::PhantomData::<(&())>) - } - 56 => { - // __Program = Program => ActionFn(0); - let __sym0 = __pop_Variant7(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action0::<>(input, __sym0); - return Some(Ok(__nt)); - } - _ => panic!("invalid action code {__action}") - }; - let __states_len = __states.len(); - __states.truncate(__states_len - __pop_states); - let __state = *__states.last().unwrap(); - let __next_state = __goto(__state, __nonterminal); - __states.push(__next_state); - None - } - #[inline(never)] - fn __symbol_type_mismatch() -> ! { - panic!("symbol type mismatch") - } - fn __pop_Variant1< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, Expression, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant1(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant4< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, Option>, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant4(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant7< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, Program, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant7(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant8< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, Statement, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant8(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant5< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, String, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant5(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant3< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, Vec, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant3(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant10< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, Vec, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant10(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant2< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, alloc::vec::Vec, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant2(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant9< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, alloc::vec::Vec, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant9(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant6< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, f64, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant6(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __pop_Variant0< - 'input, - >( - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)> - ) -> (usize, &'input str, usize) - { - match __symbols.pop() { - Some((__l, __Symbol::Variant0(__v), __r)) => (__l, __v, __r), - _ => __symbol_type_mismatch() - } - } - fn __reduce0< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ( ",") = Expr, "," => ActionFn(51); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action51::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (2, 0) - } - fn __reduce1< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ( ",")* = => ActionFn(49); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); - let __end = __start; - let __nt = super::__action49::<>(input, &__start, &__end); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (0, 1) - } - fn __reduce2< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ( ",")* = ( ",")+ => ActionFn(50); - let __sym0 = __pop_Variant2(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action50::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (1, 1) - } - fn __reduce3< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ( ",")+ = Expr, "," => ActionFn(54); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action54::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (2, 2) - } - fn __reduce4< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // ( ",")+ = ( ",")+, Expr, "," => ActionFn(55); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant2(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action55::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant2(__nt), __end)); - (3, 2) - } - fn __reduce5< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AddExpr = MulExpr => ActionFn(19); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action19::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 3) - } - fn __reduce6< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AddExpr = AddExpr, "+", MulExpr => ActionFn(20); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action20::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 3) - } - fn __reduce7< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AddExpr = AddExpr, "-", MulExpr => ActionFn(21); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action21::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 3) - } - fn __reduce8< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AndExpr = CmpExpr => ActionFn(10); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action10::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 4) - } - fn __reduce9< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AndExpr = AndExpr, "&&", CmpExpr => ActionFn(11); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action11::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 4) - } - fn __reduce10< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = STRING => ActionFn(28); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action28::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 5) - } - fn __reduce11< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = NUM => ActionFn(29); - let __sym0 = __pop_Variant6(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action29::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 5) - } - fn __reduce12< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = "True" => ActionFn(30); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action30::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 5) - } - fn __reduce13< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = "False" => ActionFn(31); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action31::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 5) - } - fn __reduce14< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = Ident, "(", Comma, ")" => ActionFn(58); - assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant3(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym3.2.clone(); - let __nt = super::__action58::<>(input, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (4, 5) - } - fn __reduce15< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = Ident, "(", ")" => ActionFn(59); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action59::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 5) - } - fn __reduce16< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = "$", Ident => ActionFn(33); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant5(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action33::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (2, 5) - } - fn __reduce17< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = "$", "-", Ident => ActionFn(34); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant5(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action34::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 5) - } - fn __reduce18< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = "@", Ident => ActionFn(35); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant5(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action35::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (2, 5) - } - fn __reduce19< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = Ident => ActionFn(36); - let __sym0 = __pop_Variant5(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action36::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 5) - } - fn __reduce20< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // AtomExpr = "(", Expr, ")" => ActionFn(37); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action37::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 5) - } - fn __reduce21< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // CmpExpr = AddExpr => ActionFn(12); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action12::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 6) - } - fn __reduce22< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // CmpExpr = CmpExpr, "==", AddExpr => ActionFn(13); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action13::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 6) - } - fn __reduce23< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // CmpExpr = CmpExpr, "!=", AddExpr => ActionFn(14); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action14::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 6) - } - fn __reduce24< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // CmpExpr = CmpExpr, "<=", AddExpr => ActionFn(15); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action15::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 6) - } - fn __reduce25< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // CmpExpr = CmpExpr, ">=", AddExpr => ActionFn(16); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action16::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 6) - } - fn __reduce26< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // CmpExpr = CmpExpr, "<", AddExpr => ActionFn(17); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action17::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 6) - } - fn __reduce27< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // CmpExpr = CmpExpr, ">", AddExpr => ActionFn(18); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action18::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 6) - } - fn __reduce28< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Comma = Expr => ActionFn(56); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action56::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant3(__nt), __end)); - (1, 7) - } - fn __reduce29< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Comma = ( ",")+, Expr => ActionFn(57); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant2(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action57::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant3(__nt), __end)); - (2, 7) - } - fn __reduce30< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Comma? = Comma => ActionFn(44); - let __sym0 = __pop_Variant3(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action44::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant4(__nt), __end)); - (1, 8) - } - fn __reduce31< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Comma? = => ActionFn(45); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); - let __end = __start; - let __nt = super::__action45::<>(input, &__start, &__end); - __symbols.push((__start, __Symbol::Variant4(__nt), __end)); - (0, 8) - } - fn __reduce32< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Expr = OrExpr => ActionFn(7); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action7::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 9) - } - fn __reduce33< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Ident = r#"[a-zA-Z_][a-zA-Z0-9_]*"# => ActionFn(41); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action41::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (1, 10) - } - fn __reduce34< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // MulExpr = UnExpr => ActionFn(22); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action22::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 11) - } - fn __reduce35< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // MulExpr = MulExpr, "*", UnExpr => ActionFn(23); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action23::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 11) - } - fn __reduce36< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // MulExpr = MulExpr, "/", UnExpr => ActionFn(24); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action24::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 11) - } - fn __reduce37< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // NUM = r#"[0-9]+(\\.[0-9]+)?"# => ActionFn(40); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action40::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant6(__nt), __end)); - (1, 12) - } - fn __reduce38< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // OrExpr = AndExpr => ActionFn(8); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action8::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 13) - } - fn __reduce39< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // OrExpr = OrExpr, "||", AndExpr => ActionFn(9); - assert!(__symbols.len() >= 3); - let __sym2 = __pop_Variant1(__symbols); - let __sym1 = __pop_Variant0(__symbols); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym2.2.clone(); - let __nt = super::__action9::<>(input, __sym0, __sym1, __sym2); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (3, 13) - } - fn __reduce40< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Program = => ActionFn(60); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); - let __end = __start; - let __nt = super::__action60::<>(input, &__start, &__end); - __symbols.push((__start, __Symbol::Variant7(__nt), __end)); - (0, 14) - } - fn __reduce41< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Program = Stmt+ => ActionFn(61); - let __sym0 = __pop_Variant9(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action61::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant7(__nt), __end)); - (1, 14) - } - fn __reduce42< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // STRING = r#"\"[^\"]*\""# => ActionFn(39); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action39::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant5(__nt), __end)); - (1, 15) - } - fn __reduce43< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmt = "Var", Ident, "=", Expr => ActionFn(2); - assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant1(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant5(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym3.2.clone(); - let __nt = super::__action2::<>(input, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (4, 16) - } - fn __reduce44< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmt = "Var", Ident, "!", "assigned" => ActionFn(3); - assert!(__symbols.len() >= 4); - let __sym3 = __pop_Variant0(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant5(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym3.2.clone(); - let __nt = super::__action3::<>(input, __sym0, __sym1, __sym2, __sym3); - __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (4, 16) - } - fn __reduce45< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmt = "If", Expr, "Then", Stmts, "EndIf" => ActionFn(4); - assert!(__symbols.len() >= 5); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant10(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym4.2.clone(); - let __nt = super::__action4::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4); - __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (5, 16) - } - fn __reduce46< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmt = "If", Expr, "Then", Stmts, "Else", Stmts, "EndIf" => ActionFn(5); - assert!(__symbols.len() >= 7); - let __sym6 = __pop_Variant0(__symbols); - let __sym5 = __pop_Variant10(__symbols); - let __sym4 = __pop_Variant0(__symbols); - let __sym3 = __pop_Variant10(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym6.2.clone(); - let __nt = super::__action5::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5, __sym6); - __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (7, 16) - } - fn __reduce47< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmt = "For", Ident, "In", Expr, Stmts, "EndFor" => ActionFn(6); - assert!(__symbols.len() >= 6); - let __sym5 = __pop_Variant0(__symbols); - let __sym4 = __pop_Variant10(__symbols); - let __sym3 = __pop_Variant1(__symbols); - let __sym2 = __pop_Variant0(__symbols); - let __sym1 = __pop_Variant5(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym5.2.clone(); - let __nt = super::__action6::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4, __sym5); - __symbols.push((__start, __Symbol::Variant8(__nt), __end)); - (6, 16) - } - fn __reduce48< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmt* = => ActionFn(47); - let __start = __lookahead_start.cloned().or_else(|| __symbols.last().map(|s| s.2)).unwrap_or_default(); - let __end = __start; - let __nt = super::__action47::<>(input, &__start, &__end); - __symbols.push((__start, __Symbol::Variant9(__nt), __end)); - (0, 17) - } - fn __reduce49< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmt* = Stmt+ => ActionFn(48); - let __sym0 = __pop_Variant9(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action48::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant9(__nt), __end)); - (1, 17) - } - fn __reduce50< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmt+ = Stmt => ActionFn(42); - let __sym0 = __pop_Variant8(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action42::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant9(__nt), __end)); - (1, 18) - } - fn __reduce51< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmt+ = Stmt+, Stmt => ActionFn(43); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant8(__symbols); - let __sym0 = __pop_Variant9(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action43::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant9(__nt), __end)); - (2, 18) - } - fn __reduce52< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // Stmts = Stmt+ => ActionFn(38); - let __sym0 = __pop_Variant9(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action38::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant10(__nt), __end)); - (1, 19) - } - fn __reduce53< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // UnExpr = AtomExpr => ActionFn(25); - let __sym0 = __pop_Variant1(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym0.2.clone(); - let __nt = super::__action25::<>(input, __sym0); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (1, 20) - } - fn __reduce54< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // UnExpr = "!", UnExpr => ActionFn(26); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action26::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (2, 20) - } - fn __reduce55< - 'input, - >( - input: &'input str, - __lookahead_start: Option<&usize>, - __symbols: &mut alloc::vec::Vec<(usize,__Symbol<'input>,usize)>, - _: core::marker::PhantomData<(&'input ())>, - ) -> (usize, usize) - { - // UnExpr = "-", UnExpr => ActionFn(27); - assert!(__symbols.len() >= 2); - let __sym1 = __pop_Variant1(__symbols); - let __sym0 = __pop_Variant0(__symbols); - let __start = __sym0.0.clone(); - let __end = __sym1.2.clone(); - let __nt = super::__action27::<>(input, __sym0, __sym1); - __symbols.push((__start, __Symbol::Variant1(__nt), __end)); - (2, 20) - } -} -#[allow(unused_imports)] -pub use self::__parse__Program::ProgramParser; -#[rustfmt::skip] -mod __intern_token { - #![allow(unused_imports)] - use crate::xml::ast::nodes::{AssignmentType, BinaryOpKind, Expression, LiteralValue, Program, Statement, UnaryOpKind}; - #[allow(unused_extern_crates)] - extern crate lalrpop_util as __lalrpop_util; - #[allow(unused_imports)] - use self::__lalrpop_util::state_machine as __state_machine; - #[allow(unused_extern_crates)] - extern crate alloc; - pub fn new_builder() -> __lalrpop_util::lexer::MatcherBuilder { - let __strs: &[(&str, bool)] = &[ - ("(?:\"[\0-!\\#-\u{10ffff}]*\")", false), - ("(?:[0-9]+((?:\\.[0-9]+))?)", false), - ("(?:[A-Z_a-z][0-9A-Z_a-z]*)", false), - ("[\t-\r \u{85}\u{a0}\u{1680}\u{2000}-\u{200a}\u{2028}\u{2029}\u{202f}\u{205f}\u{3000}]+", true), - ("!", false), - ("(?:!=)", false), - ("\\$", false), - ("(?:\\&\\&)", false), - ("\\(", false), - ("\\)", false), - ("\\*", false), - ("\\+", false), - (",", false), - ("\\-", false), - ("/", false), - ("<", false), - ("(?:<=)", false), - ("=", false), - ("(?:==)", false), - (">", false), - ("(?:>=)", false), - ("@", false), - ("(?:Else)", false), - ("(?:EndFor)", false), - ("(?:EndIf)", false), - ("(?:False)", false), - ("(?:For)", false), - ("(?:If)", false), - ("(?:In)", false), - ("(?:Then)", false), - ("(?:True)", false), - ("(?:Var)", false), - ("(?:assigned)", false), - ("(?:\\|\\|)", false), - ]; - __lalrpop_util::lexer::MatcherBuilder::new(__strs.iter().copied()).unwrap() - } -} -pub(crate) use self::__lalrpop_util::lexer::Token; - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action0< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Program, usize), -) -> Program -{ - __0 -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action1< - 'input, ->( - input: &'input str, - (_, stmts, _): (usize, alloc::vec::Vec, usize), -) -> Program -{ - Program { statements: stmts } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action2< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, name, _): (usize, String, usize), - (_, _, _): (usize, &'input str, usize), - (_, v, _): (usize, Expression, usize), -) -> Statement -{ - Statement::VarDecl { - name, - value: Some(v), - assignment_type: AssignmentType::Equals, - } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action3< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, name, _): (usize, String, usize), - (_, _, _): (usize, &'input str, usize), - (_, _, _): (usize, &'input str, usize), -) -> Statement -{ - Statement::VarDecl { - name, - value: None, - assignment_type: AssignmentType::NotAssigned, - } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action4< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, cond, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, then_body, _): (usize, Vec, usize), - (_, _, _): (usize, &'input str, usize), -) -> Statement -{ - Statement::IfStmt { - condition: cond, - then_branch: then_body, - else_branch: vec![], - } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action5< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, cond, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, then_body, _): (usize, Vec, usize), - (_, _, _): (usize, &'input str, usize), - (_, else_body, _): (usize, Vec, usize), - (_, _, _): (usize, &'input str, usize), -) -> Statement -{ - Statement::IfStmt { - condition: cond, - then_branch: then_body, - else_branch: else_body, - } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action6< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, var, _): (usize, String, usize), - (_, _, _): (usize, &'input str, usize), - (_, iter, _): (usize, Expression, usize), - (_, body, _): (usize, Vec, usize), - (_, _, _): (usize, &'input str, usize), -) -> Statement -{ - Statement::ForStmt { - variable: var, - iterable: iter, - body, - } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action7< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expression, usize), -) -> Expression -{ - __0 -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action8< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expression, usize), -) -> Expression -{ - __0 -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action9< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { - left: Box::new(left), - op: BinaryOpKind::Add, - right: Box::new(right), - } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action10< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expression, usize), -) -> Expression -{ - __0 -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action11< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { - left: Box::new(left), - op: BinaryOpKind::Add, - right: Box::new(right), - } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action12< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expression, usize), -) -> Expression -{ - __0 -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action13< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Eq, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action14< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Neq, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action15< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Lte, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action16< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Gte, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action17< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Lt, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action18< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Gt, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action19< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expression, usize), -) -> Expression -{ - __0 -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action20< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Add, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action21< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Sub, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action22< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expression, usize), -) -> Expression -{ - __0 -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action23< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Mul, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action24< - 'input, ->( - input: &'input str, - (_, left, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), - (_, right, _): (usize, Expression, usize), -) -> Expression -{ - Expression::BinaryOp { left: Box::new(left), op: BinaryOpKind::Div, right: Box::new(right) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action25< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expression, usize), -) -> Expression -{ - __0 -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action26< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, e, _): (usize, Expression, usize), -) -> Expression -{ - Expression::UnaryOp { op: UnaryOpKind::Not, operand: Box::new(e) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action27< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, e, _): (usize, Expression, usize), -) -> Expression -{ - Expression::UnaryOp { op: UnaryOpKind::Neg, operand: Box::new(e) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action28< - 'input, ->( - input: &'input str, - (_, s, _): (usize, String, usize), -) -> Expression -{ - Expression::Literal(LiteralValue::String(s)) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action29< - 'input, ->( - input: &'input str, - (_, n, _): (usize, f64, usize), -) -> Expression -{ - Expression::Literal(LiteralValue::Number(n)) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action30< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Expression -{ - Expression::Literal(LiteralValue::Bool(true)) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action31< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, &'input str, usize), -) -> Expression -{ - Expression::Literal(LiteralValue::Bool(false)) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action32< - 'input, ->( - input: &'input str, - (_, name, _): (usize, String, usize), - (_, _, _): (usize, &'input str, usize), - (_, args, _): (usize, Option>, usize), - (_, _, _): (usize, &'input str, usize), -) -> Expression -{ - Expression::FunctionCall { name, args: args.unwrap_or_default() } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action33< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, name, _): (usize, String, usize), -) -> Expression -{ - Expression::SpecialVar { name, is_negative: false } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action34< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, _, _): (usize, &'input str, usize), - (_, name, _): (usize, String, usize), -) -> Expression -{ - Expression::SpecialVar { name, is_negative: true } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action35< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, name, _): (usize, String, usize), -) -> Expression -{ - Expression::AutoVarExpr { variable: Box::new(Expression::SpecialVar { name, is_negative: false }) } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action36< - 'input, ->( - input: &'input str, - (_, name, _): (usize, String, usize), -) -> Expression -{ - Expression::Identifier(name) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action37< - 'input, ->( - input: &'input str, - (_, _, _): (usize, &'input str, usize), - (_, e, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), -) -> Expression -{ - e -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action38< - 'input, ->( - input: &'input str, - (_, stmts, _): (usize, alloc::vec::Vec, usize), -) -> Vec -{ - stmts -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action39< - 'input, ->( - input: &'input str, - (_, s, _): (usize, &'input str, usize), -) -> String -{ - s[1..s.len()-1].to_string() -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action40< - 'input, ->( - input: &'input str, - (_, s, _): (usize, &'input str, usize), -) -> f64 -{ - s.parse::().unwrap() -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action41< - 'input, ->( - input: &'input str, - (_, s, _): (usize, &'input str, usize), -) -> String -{ - s.to_string() -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action42< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Statement, usize), -) -> alloc::vec::Vec -{ - alloc::vec![__0] -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action43< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec, usize), - (_, e, _): (usize, Statement, usize), -) -> alloc::vec::Vec -{ - { let mut v = v; v.push(e); v } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action44< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Vec, usize), -) -> Option> -{ - Some(__0) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action45< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> Option> -{ - None -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action46< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec, usize), - (_, e, _): (usize, Expression, usize), -) -> Vec -{ - { - let mut v = v; - v.push(e); - v - } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action47< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> alloc::vec::Vec -{ - alloc::vec![] -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action48< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec -{ - v -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action49< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> alloc::vec::Vec -{ - alloc::vec![] -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action50< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec, usize), -) -> alloc::vec::Vec -{ - v -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action51< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expression, usize), - (_, _, _): (usize, &'input str, usize), -) -> Expression -{ - __0 -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action52< - 'input, ->( - input: &'input str, - (_, __0, _): (usize, Expression, usize), -) -> alloc::vec::Vec -{ - alloc::vec![__0] -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, clippy::just_underscores_and_digits)] -fn __action53< - 'input, ->( - input: &'input str, - (_, v, _): (usize, alloc::vec::Vec, usize), - (_, e, _): (usize, Expression, usize), -) -> alloc::vec::Vec -{ - { let mut v = v; v.push(e); v } -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, - clippy::just_underscores_and_digits)] -fn __action54< - 'input, ->( - input: &'input str, - __0: (usize, Expression, usize), - __1: (usize, &'input str, usize), -) -> alloc::vec::Vec -{ - let __start0 = __0.0; - let __end0 = __1.2; - let __temp0 = __action51( - input, - __0, - __1, - ); - let __temp0 = (__start0, __temp0, __end0); - __action52( - input, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, - clippy::just_underscores_and_digits)] -fn __action55< - 'input, ->( - input: &'input str, - __0: (usize, alloc::vec::Vec, usize), - __1: (usize, Expression, usize), - __2: (usize, &'input str, usize), -) -> alloc::vec::Vec -{ - let __start0 = __1.0; - let __end0 = __2.2; - let __temp0 = __action51( - input, - __1, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action53( - input, - __0, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, - clippy::just_underscores_and_digits)] -fn __action56< - 'input, ->( - input: &'input str, - __0: (usize, Expression, usize), -) -> Vec -{ - let __start0 = __0.0; - let __end0 = __0.0; - let __temp0 = __action49( - input, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action46( - input, - __temp0, - __0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, - clippy::just_underscores_and_digits)] -fn __action57< - 'input, ->( - input: &'input str, - __0: (usize, alloc::vec::Vec, usize), - __1: (usize, Expression, usize), -) -> Vec -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action50( - input, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action46( - input, - __temp0, - __1, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, - clippy::just_underscores_and_digits)] -fn __action58< - 'input, ->( - input: &'input str, - __0: (usize, String, usize), - __1: (usize, &'input str, usize), - __2: (usize, Vec, usize), - __3: (usize, &'input str, usize), -) -> Expression -{ - let __start0 = __2.0; - let __end0 = __2.2; - let __temp0 = __action44( - input, - __2, - ); - let __temp0 = (__start0, __temp0, __end0); - __action32( - input, - __0, - __1, - __temp0, - __3, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, - clippy::just_underscores_and_digits)] -fn __action59< - 'input, ->( - input: &'input str, - __0: (usize, String, usize), - __1: (usize, &'input str, usize), - __2: (usize, &'input str, usize), -) -> Expression -{ - let __start0 = __1.2; - let __end0 = __2.0; - let __temp0 = __action45( - input, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action32( - input, - __0, - __1, - __temp0, - __2, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, - clippy::just_underscores_and_digits)] -fn __action60< - 'input, ->( - input: &'input str, - __lookbehind: &usize, - __lookahead: &usize, -) -> Program -{ - let __start0 = *__lookbehind; - let __end0 = *__lookahead; - let __temp0 = __action47( - input, - &__start0, - &__end0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1( - input, - __temp0, - ) -} - -#[allow(unused_variables)] -#[allow(clippy::too_many_arguments, clippy::needless_lifetimes, - clippy::just_underscores_and_digits)] -fn __action61< - 'input, ->( - input: &'input str, - __0: (usize, alloc::vec::Vec, usize), -) -> Program -{ - let __start0 = __0.0; - let __end0 = __0.2; - let __temp0 = __action48( - input, - __0, - ); - let __temp0 = (__start0, __temp0, __end0); - __action1( - input, - __temp0, - ) -} - -#[allow(clippy::type_complexity, dead_code)] -pub trait __ToTriple<'input, > -{ - fn to_triple(self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>>; -} - -impl<'input, > __ToTriple<'input, > for (usize, Token<'input>, usize) -{ - fn to_triple(self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>> { - Ok(self) - } -} -impl<'input, > __ToTriple<'input, > for Result<(usize, Token<'input>, usize), &'static str> -{ - fn to_triple(self) -> Result<(usize,Token<'input>,usize), __lalrpop_util::ParseError, &'static str>> { - self.map_err(|error| __lalrpop_util::ParseError::User { error }) - } -} diff --git a/src/xml/parser/mod.rs b/src/xml/parser/mod.rs index 64f4127..f38b465 100644 --- a/src/xml/parser/mod.rs +++ b/src/xml/parser/mod.rs @@ -1,10 +1,11 @@ -use crate::xml::ast::nodes::{ - AssignmentType, BinaryOpKind, Expression, LiteralValue, Program, Statement, UnaryOpKind, -}; use crate::xml::error::ParserResult; #[allow(clippy::all)] -pub mod grammar; +pub mod grammar { + include!(concat!(env!("OUT_DIR"), "/xml/parser/grammar.rs")); +} + +pub use crate::xml::ast::nodes::{AssignmentType, BinaryOpKind, Expression, LiteralValue, Program, Statement, UnaryOpKind}; use grammar::ProgramParser; @@ -88,13 +89,13 @@ mod tests { #[test] fn test_if_stmt_simple() { - let result = ScriptParser::parse("If x == 5 Then Var y = 10 EndIf"); + let result = ScriptParser::parse("If x = 5 Then Var y = 10 EndIf"); assert!(result.is_ok(), "parse failed: {:?}", result.err()); } #[test] fn test_if_with_else() { - let result = ScriptParser::parse("If x == 5 Then Var y = 10 Else Var y = 20 EndIf"); + let result = ScriptParser::parse("If x = 5 Then Var y = 10 Else Var y = 20 EndIf"); assert!(result.is_ok(), "parse failed: {:?}", result.err()); let program = result.unwrap(); if let Statement::IfStmt { else_branch, .. } = &program.statements[0] { @@ -152,10 +153,46 @@ mod tests { #[test] fn test_comparison() { - let result = ScriptParser::parse("If x != 5 Then Var y = 10 EndIf"); + let result = ScriptParser::parse("If x = 5 Then Var y = 10 EndIf"); assert!(result.is_ok(), "parse failed: {:?}", result.err()); } + #[test] + fn test_logical_and() { + let result = ScriptParser::parse("If x = 5 && y = 3 Then Var z = 1 EndIf"); + assert!(result.is_ok(), "parse failed: {:?}", result.err()); + } + + #[test] + fn test_logical_or() { + let result = ScriptParser::parse("If x = 5 || y = 3 Then Var z = 1 EndIf"); + assert!(result.is_ok(), "parse failed: {:?}", result.err()); + } + + #[test] + fn test_debug_var() { + let result = ScriptParser::parse("DEBUGVAR myVar"); + assert!(result.is_ok(), "parse failed: {:?}", result.err()); + let program = result.unwrap(); + if let Statement::DebugVar { name } = &program.statements[0] { + assert_eq!(name, "myVar"); + } else { + panic!("Expected DebugVar statement"); + } + } + + #[test] + fn test_open() { + let result = ScriptParser::parse(r#"Open "somefile.xml""#); + assert!(result.is_ok(), "parse failed: {:?}", result.err()); + let program = result.unwrap(); + if let Statement::Open { filename } = &program.statements[0] { + assert_eq!(filename, "somefile.xml"); + } else { + panic!("Expected Open statement"); + } + } + #[test] fn test_for_loop() { let result = ScriptParser::parse("For i In items Var x = i EndFor"); diff --git a/src/xml/vm/mod.rs b/src/xml/vm/mod.rs index 2cbd0b4..20c9d0a 100644 --- a/src/xml/vm/mod.rs +++ b/src/xml/vm/mod.rs @@ -279,7 +279,8 @@ impl Vm { if let Some(func) = self.functions.get(name) { func(&evaluated_args) } else { - Err(VmError::UndefinedFunction(name.clone())) + eprintln!("[WARN] Unknown function: {}, skipping", name); + Ok(Value::Null) } } @@ -370,6 +371,8 @@ impl Vm { let r = right.to_f64().ok_or_else(|| VmError::TypeError("Cannot compare non-numbers".into()))?; Ok(Value::Bool(l >= r)) } + BinaryOpKind::And => Ok(Value::Bool(left.to_bool() && right.to_bool())), + BinaryOpKind::Or => Ok(Value::Bool(left.to_bool() || right.to_bool())), } } @@ -425,6 +428,30 @@ impl Vm { self.eval_expr(expression)?; Ok(()) } + Statement::DebugVar { name } => { + if let Some(val) = self.globals.get(name) { + println!("{} = {}", name, val); + } else if let Some(val) = self.globals.get(&format!("${}", name)) { + println!("${} = {}", name, val); + } else { + println!("{} = ", name); + } + Ok(()) + } + Statement::Open { filename } => { + eprintln!("[WARN] Open \"{}\" - not yet implemented in VM", filename); + Ok(()) + } + Statement::Call { name, args } => { + let evaluated_args: VmResult> = args.iter().map(|a| self.eval_expr(a)).collect(); + let evaluated_args = evaluated_args?; + if let Some(func) = self.functions.get(name) { + func(&evaluated_args)?; + } else { + eprintln!("[WARN] Unknown function: {}, skipping", name); + } + Ok(()) + } } } @@ -452,6 +479,31 @@ impl Vm { let val = self.eval_expr(expression)?; Ok(Some(val)) } + Statement::DebugVar { name } => { + if let Some(val) = self.globals.get(name) { + println!("{} = {}", name, val); + } else if let Some(val) = self.globals.get(&format!("${}", name)) { + println!("${} = {}", name, val); + } else { + println!("{} = ", name); + } + Ok(None) + } + Statement::Open { filename } => { + eprintln!("[WARN] Open \"{}\" - not yet implemented in VM", filename); + Ok(None) + } + Statement::Call { name, args } => { + let evaluated_args: VmResult> = args.iter().map(|a| self.eval_expr(a)).collect(); + let evaluated_args = evaluated_args?; + if let Some(func) = self.functions.get(name) { + let result = func(&evaluated_args)?; + Ok(Some(result)) + } else { + eprintln!("[WARN] Unknown function: {}, skipping", name); + Ok(Some(Value::Null)) + } + } _ => { self.exec_statement(stmt)?; Ok(None) @@ -510,7 +562,7 @@ mod tests { fn test_comparison_eq() { let mut globals = Environment::new(); globals.insert("x".to_string(), Value::Number(5.0)); - let program = crate::xml::parser::ScriptParser::parse("If x == 5 Then Var y = 1 Else Var y = 0 EndIf") + let program = crate::xml::parser::ScriptParser::parse("If x = 5 Then Var y = 1 Else Var y = 0 EndIf") .map_err(|e| VmError::RuntimeError(e.to_string())).unwrap(); let mut vm = Vm::with_globals(globals); vm.run(&program).unwrap(); @@ -518,10 +570,10 @@ mod tests { } #[test] - fn test_comparison_neq() { + fn test_comparison_lt() { let mut globals = Environment::new(); globals.insert("x".to_string(), Value::Number(3.0)); - let program = crate::xml::parser::ScriptParser::parse("If x != 5 Then Var y = 1 Else Var y = 0 EndIf") + let program = crate::xml::parser::ScriptParser::parse("If x < 5 Then Var y = 1 Else Var y = 0 EndIf") .map_err(|e| VmError::RuntimeError(e.to_string())).unwrap(); let mut vm = Vm::with_globals(globals); vm.run(&program).unwrap(); @@ -532,7 +584,7 @@ mod tests { fn test_if_else_false() { let mut globals = Environment::new(); globals.insert("x".to_string(), Value::Number(10.0)); - let program = crate::xml::parser::ScriptParser::parse("If x == 5 Then Var y = 1 Else Var y = 2 EndIf") + let program = crate::xml::parser::ScriptParser::parse("If x = 5 Then Var y = 1 Else Var y = 2 EndIf") .map_err(|e| VmError::RuntimeError(e.to_string())).unwrap(); let mut vm = Vm::with_globals(globals); vm.run(&program).unwrap(); @@ -633,4 +685,46 @@ mod tests { let result = parse_and_run("Var x = unknown_var"); assert!(result.is_err()); } + + #[test] + fn test_unknown_function_returns_null() { + let result = parse_and_run("Var x = unknownFunc(1, 2)"); + assert!(result.is_ok()); + assert_eq!(result.unwrap(), Value::Null); + } + + #[test] + fn test_logical_and() { + let mut globals = Environment::new(); + globals.insert("x".to_string(), Value::Bool(true)); + globals.insert("y".to_string(), Value::Bool(false)); + let program = crate::xml::parser::ScriptParser::parse("If x && y Then Var z = 1 Else Var z = 0 EndIf") + .map_err(|e| VmError::RuntimeError(e.to_string())).unwrap(); + let mut vm = Vm::with_globals(globals); + vm.run(&program).unwrap(); + assert_eq!(*vm.get_global("z").unwrap(), Value::Number(0.0)); + } + + #[test] + fn test_logical_or() { + let mut globals = Environment::new(); + globals.insert("x".to_string(), Value::Bool(true)); + globals.insert("y".to_string(), Value::Bool(false)); + let program = crate::xml::parser::ScriptParser::parse("If x || y Then Var z = 1 Else Var z = 0 EndIf") + .map_err(|e| VmError::RuntimeError(e.to_string())).unwrap(); + let mut vm = Vm::with_globals(globals); + vm.run(&program).unwrap(); + assert_eq!(*vm.get_global("z").unwrap(), Value::Number(1.0)); + } + + #[test] + fn test_debug_var() { + let mut globals = Environment::new(); + globals.insert("myVar".to_string(), Value::Number(42.0)); + let program = crate::xml::parser::ScriptParser::parse("DEBUGVAR myVar") + .map_err(|e| VmError::RuntimeError(e.to_string())).unwrap(); + let mut vm = Vm::with_globals(globals); + let result = vm.run(&program); + assert!(result.is_ok()); + } } \ No newline at end of file