This commit is contained in:
TerraMaster85 2024-01-15 16:18:18 -05:00
commit 8d4226b185
21 changed files with 418 additions and 0 deletions

7
kabel-rs/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "kabel-rs"
version = "0.1.0"

8
kabel-rs/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "kabel-rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

40
kabel-rs/src/lexer.rs Normal file
View File

@ -0,0 +1,40 @@
pub mod variables;
enum ArithmeticOperatorToken {
Add
Subtract
Multiply
Divide
Exponentiate
Modulus
}
enum BooleanOperatorToken {
And
Or
}
enum LiteralToken {
Str(String)
Num(f64)
}
enum StatementToken {
If
Foreach
While
To
}
enum BracketToken {
Open
Close
}
enum Token {
Literal(LiteralToken)
ArithmeticOperator(ArithmeticOperatorToken)
Statement(StatementToken)
Bracket(BracketToken)
Variable(variables::VariableToken)
}

9
kabel-rs/src/main.rs Normal file
View File

@ -0,0 +1,9 @@
use std::env;
use std::fs;
pub mod lexer;
fn main() {
let args: Vec<String> = env::args().collect();
dbg!(&args[1]);
}

View File

@ -0,0 +1 @@
{"rustc_fingerprint":7338601337485693249,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.74.0 (79e9716c9 2023-11-13)\nbinary: rustc\ncommit-hash: 79e9716c980570bfd1f666e3b16ac583f0168962\ncommit-date: 2023-11-13\nhost: x86_64-unknown-linux-gnu\nrelease: 1.74.0\nLLVM version: 17.0.4\n","stderr":""},"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/tm85/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}

View File

@ -0,0 +1,3 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by cargo.
# For information about cache directory tags see https://bford.info/cachedir/

View File

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1,21 @@
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `Subtract`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":58,"byte_end":58,"line_start":4,"line_end":4,"column_start":8,"column_end":8,"is_primary":false,"text":[{"text":" Add","highlight_start":8,"highlight_end":8}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":63,"byte_end":71,"line_start":5,"line_end":5,"column_start":5,"column_end":13,"is_primary":true,"text":[{"text":" Subtract","highlight_start":5,"highlight_end":13}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":58,"byte_end":58,"line_start":4,"line_end":4,"column_start":8,"column_end":8,"is_primary":true,"text":[{"text":" Add","highlight_start":8,"highlight_end":8}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `Subtract`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:5:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m4\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Add\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m5\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Subtract\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `Multiply`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":71,"byte_end":71,"line_start":5,"line_end":5,"column_start":13,"column_end":13,"is_primary":false,"text":[{"text":" Subtract","highlight_start":13,"highlight_end":13}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":76,"byte_end":84,"line_start":6,"line_end":6,"column_start":5,"column_end":13,"is_primary":true,"text":[{"text":" Multiply","highlight_start":5,"highlight_end":13}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":71,"byte_end":71,"line_start":5,"line_end":5,"column_start":13,"column_end":13,"is_primary":true,"text":[{"text":" Subtract","highlight_start":13,"highlight_end":13}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `Multiply`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:6:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m5\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Subtract\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m6\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Multiply\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `Divide`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":84,"byte_end":84,"line_start":6,"line_end":6,"column_start":13,"column_end":13,"is_primary":false,"text":[{"text":" Multiply","highlight_start":13,"highlight_end":13}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":89,"byte_end":95,"line_start":7,"line_end":7,"column_start":5,"column_end":11,"is_primary":true,"text":[{"text":" Divide","highlight_start":5,"highlight_end":11}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":84,"byte_end":84,"line_start":6,"line_end":6,"column_start":13,"column_end":13,"is_primary":true,"text":[{"text":" Multiply","highlight_start":13,"highlight_end":13}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `Divide`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:7:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m6\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Multiply\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m7\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Divide\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `Exponentiate`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":95,"byte_end":95,"line_start":7,"line_end":7,"column_start":11,"column_end":11,"is_primary":false,"text":[{"text":" Divide","highlight_start":11,"highlight_end":11}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":100,"byte_end":112,"line_start":8,"line_end":8,"column_start":5,"column_end":17,"is_primary":true,"text":[{"text":" Exponentiate","highlight_start":5,"highlight_end":17}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":95,"byte_end":95,"line_start":7,"line_end":7,"column_start":11,"column_end":11,"is_primary":true,"text":[{"text":" Divide","highlight_start":11,"highlight_end":11}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `Exponentiate`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:8:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m7\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Divide\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m8\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Exponentiate\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `Modulus`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":112,"byte_end":112,"line_start":8,"line_end":8,"column_start":17,"column_end":17,"is_primary":false,"text":[{"text":" Exponentiate","highlight_start":17,"highlight_end":17}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":117,"byte_end":124,"line_start":9,"line_end":9,"column_start":5,"column_end":12,"is_primary":true,"text":[{"text":" Modulus","highlight_start":5,"highlight_end":12}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":112,"byte_end":112,"line_start":8,"line_end":8,"column_start":17,"column_end":17,"is_primary":true,"text":[{"text":" Exponentiate","highlight_start":17,"highlight_end":17}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `Modulus`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:9:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m8\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Exponentiate\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m9\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Modulus\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `Or`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":163,"byte_end":163,"line_start":13,"line_end":13,"column_start":8,"column_end":8,"is_primary":false,"text":[{"text":" And","highlight_start":8,"highlight_end":8}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":168,"byte_end":170,"line_start":14,"line_end":14,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":" Or","highlight_start":5,"highlight_end":7}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":163,"byte_end":163,"line_start":13,"line_end":13,"column_start":8,"column_end":8,"is_primary":true,"text":[{"text":" And","highlight_start":8,"highlight_end":8}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `Or`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:14:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m13\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m And\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m14\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Or\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `,`, `=`, or `}`, found `Num`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":209,"byte_end":209,"line_start":18,"line_end":18,"column_start":16,"column_end":16,"is_primary":false,"text":[{"text":" Str(String)","highlight_start":16,"highlight_end":16}],"label":"expected one of `,`, `=`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":214,"byte_end":217,"line_start":19,"line_end":19,"column_start":5,"column_end":8,"is_primary":true,"text":[{"text":" Num(f64)","highlight_start":5,"highlight_end":8}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":209,"byte_end":209,"line_start":18,"line_end":18,"column_start":16,"column_end":16,"is_primary":true,"text":[{"text":" Str(String)","highlight_start":16,"highlight_end":16}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `,`, `=`, or `}`, found `Num`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:19:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m18\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Str(String)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `,`, `=`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m19\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Num(f64)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `Foreach`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":254,"byte_end":254,"line_start":23,"line_end":23,"column_start":7,"column_end":7,"is_primary":false,"text":[{"text":" If","highlight_start":7,"highlight_end":7}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":259,"byte_end":266,"line_start":24,"line_end":24,"column_start":5,"column_end":12,"is_primary":true,"text":[{"text":" Foreach","highlight_start":5,"highlight_end":12}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":254,"byte_end":254,"line_start":23,"line_end":23,"column_start":7,"column_end":7,"is_primary":true,"text":[{"text":" If","highlight_start":7,"highlight_end":7}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `Foreach`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:24:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m23\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m If\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m24\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Foreach\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `While`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":266,"byte_end":266,"line_start":24,"line_end":24,"column_start":12,"column_end":12,"is_primary":false,"text":[{"text":" Foreach","highlight_start":12,"highlight_end":12}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":271,"byte_end":276,"line_start":25,"line_end":25,"column_start":5,"column_end":10,"is_primary":true,"text":[{"text":" While","highlight_start":5,"highlight_end":10}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":266,"byte_end":266,"line_start":24,"line_end":24,"column_start":12,"column_end":12,"is_primary":true,"text":[{"text":" Foreach","highlight_start":12,"highlight_end":12}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `While`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:25:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m24\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Foreach\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m25\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m While\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `To`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":276,"byte_end":276,"line_start":25,"line_end":25,"column_start":10,"column_end":10,"is_primary":false,"text":[{"text":" While","highlight_start":10,"highlight_end":10}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":281,"byte_end":283,"line_start":26,"line_end":26,"column_start":5,"column_end":7,"is_primary":true,"text":[{"text":" To","highlight_start":5,"highlight_end":7}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":276,"byte_end":276,"line_start":25,"line_end":25,"column_start":10,"column_end":10,"is_primary":true,"text":[{"text":" While","highlight_start":10,"highlight_end":10}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `To`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:26:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m25\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m While\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m26\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m To\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `(`, `,`, `=`, `{`, or `}`, found `Close`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":315,"byte_end":315,"line_start":30,"line_end":30,"column_start":9,"column_end":9,"is_primary":false,"text":[{"text":" Open","highlight_start":9,"highlight_end":9}],"label":"expected one of `(`, `,`, `=`, `{`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":320,"byte_end":325,"line_start":31,"line_end":31,"column_start":5,"column_end":10,"is_primary":true,"text":[{"text":" Close","highlight_start":5,"highlight_end":10}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":315,"byte_end":315,"line_start":30,"line_end":30,"column_start":9,"column_end":9,"is_primary":true,"text":[{"text":" Open","highlight_start":9,"highlight_end":9}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `(`, `,`, `=`, `{`, or `}`, found `Close`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:31:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m30\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Open\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `(`, `,`, `=`, `{`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m31\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Close\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `,`, `=`, or `}`, found `ArithmeticOperator`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":367,"byte_end":367,"line_start":35,"line_end":35,"column_start":26,"column_end":26,"is_primary":false,"text":[{"text":" Literal(LiteralToken)","highlight_start":26,"highlight_end":26}],"label":"expected one of `,`, `=`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":372,"byte_end":390,"line_start":36,"line_end":36,"column_start":5,"column_end":23,"is_primary":true,"text":[{"text":" ArithmeticOperator(ArithmeticOperatorToken)","highlight_start":5,"highlight_end":23}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":367,"byte_end":367,"line_start":35,"line_end":35,"column_start":26,"column_end":26,"is_primary":true,"text":[{"text":" Literal(LiteralToken)","highlight_start":26,"highlight_end":26}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `,`, `=`, or `}`, found `ArithmeticOperator`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:36:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m35\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Literal(LiteralToken)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `,`, `=`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m36\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m ArithmeticOperator(ArithmeticOperatorToken)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^^^^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `,`, `=`, or `}`, found `Statement`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":415,"byte_end":415,"line_start":36,"line_end":36,"column_start":48,"column_end":48,"is_primary":false,"text":[{"text":" ArithmeticOperator(ArithmeticOperatorToken)","highlight_start":48,"highlight_end":48}],"label":"expected one of `,`, `=`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":420,"byte_end":429,"line_start":37,"line_end":37,"column_start":5,"column_end":14,"is_primary":true,"text":[{"text":" Statement(StatementToken)","highlight_start":5,"highlight_end":14}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":415,"byte_end":415,"line_start":36,"line_end":36,"column_start":48,"column_end":48,"is_primary":true,"text":[{"text":" ArithmeticOperator(ArithmeticOperatorToken)","highlight_start":48,"highlight_end":48}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `,`, `=`, or `}`, found `Statement`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:37:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m36\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m ArithmeticOperator(ArithmeticOperatorToken)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `,`, `=`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m37\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Statement(StatementToken)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `,`, `=`, or `}`, found `Bracket`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":445,"byte_end":445,"line_start":37,"line_end":37,"column_start":30,"column_end":30,"is_primary":false,"text":[{"text":" Statement(StatementToken)","highlight_start":30,"highlight_end":30}],"label":"expected one of `,`, `=`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":450,"byte_end":457,"line_start":38,"line_end":38,"column_start":5,"column_end":12,"is_primary":true,"text":[{"text":" Bracket(BracketToken)","highlight_start":5,"highlight_end":12}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":445,"byte_end":445,"line_start":37,"line_end":37,"column_start":30,"column_end":30,"is_primary":true,"text":[{"text":" Statement(StatementToken)","highlight_start":30,"highlight_end":30}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `,`, `=`, or `}`, found `Bracket`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:38:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m37\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Statement(StatementToken)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `,`, `=`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m38\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Bracket(BracketToken)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"expected one of `,`, `=`, or `}`, found `Variable`","code":null,"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":471,"byte_end":471,"line_start":38,"line_end":38,"column_start":26,"column_end":26,"is_primary":false,"text":[{"text":" Bracket(BracketToken)","highlight_start":26,"highlight_end":26}],"label":"expected one of `,`, `=`, or `}`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/lexer.rs","byte_start":476,"byte_end":484,"line_start":39,"line_end":39,"column_start":5,"column_end":13,"is_primary":true,"text":[{"text":" Variable(variables::VariableToken)","highlight_start":5,"highlight_end":13}],"label":"unexpected token","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"missing `,`","code":null,"level":"help","spans":[{"file_name":"src/lexer.rs","byte_start":471,"byte_end":471,"line_start":38,"line_end":38,"column_start":26,"column_end":26,"is_primary":true,"text":[{"text":" Bracket(BracketToken)","highlight_start":26,"highlight_end":26}],"label":null,"suggested_replacement":",","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: expected one of `,`, `=`, or `}`, found `Variable`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:39:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m38\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Bracket(BracketToken)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m-\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mexpected one of `,`, `=`, or `}`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12mhelp: missing `,`\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m39\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Variable(variables::VariableToken)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9munexpected token\u001b[0m\n\n"}
{"message":"file not found for module `variables`","code":{"code":"E0583","explanation":"A file wasn't found for an out-of-line module.\n\nErroneous code example:\n\n```compile_fail,E0583\nmod file_that_doesnt_exist; // error: file not found for module\n\nfn main() {}\n```\n\nPlease be sure that a file corresponding to the module exists. If you\nwant to use a module named `file_that_doesnt_exist`, you need to have a file\nnamed `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the\nsame directory.\n"},"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":0,"byte_end":18,"line_start":1,"line_end":1,"column_start":1,"column_end":19,"is_primary":true,"text":[{"text":"pub mod variables;","highlight_start":1,"highlight_end":19}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"to create the module `variables`, create file \"src/lexer/variables.rs\" or \"src/lexer/variables/mod.rs\"","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0583]\u001b[0m\u001b[0m\u001b[1m: file not found for module `variables`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:1:1\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m1\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0mpub mod variables;\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^^^^^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mhelp\u001b[0m\u001b[0m: to create the module `variables`, create file \"src/lexer/variables.rs\" or \"src/lexer/variables/mod.rs\"\u001b[0m\n\n"}
{"message":"cannot find type `VariableToken` in module `variables`","code":{"code":"E0412","explanation":"A used type name is not in scope.\n\nErroneous code examples:\n\n```compile_fail,E0412\nimpl Something {} // error: type name `Something` is not in scope\n\n// or:\n\ntrait Foo {\n fn bar(N); // error: type name `N` is not in scope\n}\n\n// or:\n\nfn foo(x: T) {} // type name `T` is not in scope\n```\n\nTo fix this error, please verify you didn't misspell the type name, you did\ndeclare it or imported it into the scope. Examples:\n\n```\nstruct Something;\n\nimpl Something {} // ok!\n\n// or:\n\ntrait Foo {\n type N;\n\n fn bar(_: Self::N); // ok!\n}\n\n// or:\n\nfn foo<T>(x: T) {} // ok!\n```\n\nAnother case that causes this error is when a type is imported into a parent\nmodule. To fix this, you can follow the suggestion and use File directly or\n`use super::File;` which will import the types from the parent namespace. An\nexample that causes this error is below:\n\n```compile_fail,E0412\nuse std::fs::File;\n\nmod foo {\n fn some_function(f: File) {}\n}\n```\n\n```\nuse std::fs::File;\n\nmod foo {\n // either\n use super::File;\n // or\n // use std::fs::File;\n fn foo(f: File) {}\n}\n# fn main() {} // don't insert it for us; that'll break imports\n```\n"},"level":"error","spans":[{"file_name":"src/lexer.rs","byte_start":496,"byte_end":509,"line_start":39,"line_end":39,"column_start":25,"column_end":38,"is_primary":true,"text":[{"text":" Variable(variables::VariableToken)","highlight_start":25,"highlight_end":38}],"label":"not found in `variables`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror[E0412]\u001b[0m\u001b[0m\u001b[1m: cannot find type `VariableToken` in module `variables`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/lexer.rs:39:25\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m39\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m Variable(variables::VariableToken)\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^^^^^^^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mnot found in `variables`\u001b[0m\n\n"}
{"message":"unused import: `std::fs`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":18,"byte_end":25,"line_start":2,"line_end":2,"column_start":5,"column_end":12,"is_primary":true,"text":[{"text":"use std::fs;","highlight_start":5,"highlight_end":12}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(unused_imports)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove the whole `use` item","code":null,"level":"help","spans":[{"file_name":"src/main.rs","byte_start":14,"byte_end":26,"line_start":2,"line_end":2,"column_start":1,"column_end":13,"is_primary":true,"text":[{"text":"use std::fs;","highlight_start":1,"highlight_end":13}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"\u001b[0m\u001b[1m\u001b[33mwarning\u001b[0m\u001b[0m\u001b[1m: unused import: `std::fs`\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0msrc/main.rs:2:5\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m\u001b[1m\u001b[38;5;12m2\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0muse std::fs;\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[33m^^^^^^^\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\n\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m= \u001b[0m\u001b[0m\u001b[1mnote\u001b[0m\u001b[0m: `#[warn(unused_imports)]` on by default\u001b[0m\n\n"}
{"message":"aborting due to 17 previous errors; 1 warning emitted","code":null,"level":"error","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1m\u001b[38;5;9merror\u001b[0m\u001b[0m\u001b[1m: aborting due to 17 previous errors; 1 warning emitted\u001b[0m\n\n"}
{"message":"Some errors have detailed explanations: E0412, E0583.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1mSome errors have detailed explanations: E0412, E0583.\u001b[0m\n"}
{"message":"For more information about an error, try `rustc --explain E0412`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"\u001b[0m\u001b[1mFor more information about an error, try `rustc --explain E0412`.\u001b[0m\n"}

View File

@ -0,0 +1,6 @@
/home/tm85/git/kabel/kabel-rs/target/debug/deps/kabel_rs-b7a5db911f8343d3: src/main.rs src/lexer.rs
/home/tm85/git/kabel/kabel-rs/target/debug/deps/kabel_rs-b7a5db911f8343d3.d: src/main.rs src/lexer.rs
src/main.rs:
src/lexer.rs:

91
kabel-zig/build.zig Normal file
View File

@ -0,0 +1,91 @@
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{
.name = "kabel-zig",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = .{ .path = "src/root.zig" },
.target = target,
.optimize = optimize,
});
// This declares intent for the library to be installed into the standard
// location when the user invokes the "install" step (the default step when
// running `zig build`).
b.installArtifact(lib);
const exe = b.addExecutable(.{
.name = "kabel-zig",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
// step when running `zig build`).
b.installArtifact(exe);
// This *creates* a Run step in the build graph, to be executed when another
// step is evaluated that depends on it. The next line below will establish
// such a dependency.
const run_cmd = b.addRunArtifact(exe);
// By making the run step depend on the install step, it will be run from the
// installation directory rather than directly from within the cache directory.
// This is not necessary, however, if the application depends on other installed
// files, this ensures they will be present and in the expected location.
run_cmd.step.dependOn(b.getInstallStep());
// This allows the user to pass arguments to the application in the build
// command itself, like this: `zig build run -- arg1 arg2 etc`
if (b.args) |args| {
run_cmd.addArgs(args);
}
// This creates a build step. It will be visible in the `zig build --help` menu,
// and can be selected like this: `zig build run`
// This will evaluate the `run` step rather than the default, which is "install".
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const lib_unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/root.zig" },
.target = target,
.optimize = optimize,
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const exe_unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
// Similar to creating the run step earlier, this exposes a `test` step to
// the `zig build --help` menu, providing a way for the user to request
// running the unit tests.
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
test_step.dependOn(&run_exe_unit_tests.step);
}

62
kabel-zig/build.zig.zon Normal file
View File

@ -0,0 +1,62 @@
.{
.name = "kabel-zig",
// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.0.0",
// This field is optional.
// This is currently advisory only; Zig does not yet do anything
// with this value.
//.minimum_zig_version = "0.11.0",
// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
// Once all dependencies are fetched, `zig build` no longer requires
// internet connectivity.
.dependencies = .{
// See `zig fetch --save <url>` for a command-line interface for adding dependencies.
//.example = .{
// // When updating this field to a new URL, be sure to delete the corresponding
// // `hash`, otherwise you are communicating that you expect to find the old hash at
// // the new URL.
// .url = "https://example.com/foo.tar.gz",
//
// // This is computed from the file contents of the directory of files that is
// // obtained after fetching `url` and applying the inclusion rules given by
// // `paths`.
// //
// // This field is the source of truth; packages do not come from a `url`; they
// // come from a `hash`. `url` is just one of many possible mirrors for how to
// // obtain a package matching this `hash`.
// //
// // Uses the [multihash](https://multiformats.io/multihash/) format.
// .hash = "...",
//
// // When this is provided, the package is found in a directory relative to the
// // build root. In this case the package's hash is irrelevant and therefore not
// // computed. This field and `url` are mutually exclusive.
// .path = "foo",
//},
},
// Specifies the set of files and directories that are included in this package.
// Only files and directories listed here are included in the `hash` that
// is computed for this package.
// Paths are relative to the build root. Use the empty string (`""`) to refer to
// the build root itself.
// A directory listed here means that all files within, recursively, are included.
.paths = .{
// This makes *all* files, recursively, included in this package. It is generally
// better to explicitly list the files and directories instead, to insure that
// fetching from tarballs, file system paths, and version control all result
// in the same contents hash.
"",
// For example...
//"build.zig",
//"build.zig.zon",
//"src",
//"LICENSE",
//"README.md",
},
}

4
kabel-zig/src/lexer.zig Normal file
View File

@ -0,0 +1,4 @@
const std = @import("std");
const lexutils = @import("lexutils.zig");
pub fn lexer(

45
kabel-zig/src/lexutil.zig Normal file
View File

@ -0,0 +1,45 @@
const variables = @import("variables.zig");
const ArithmeticOperatorToken = enum {
Add, // +
Subtract, // -
Multiply, // *
Divide, // /
Exponentiate, // ^
Modulus, // %
};
const BooleanOperatorToken = enum {
And,
Or,
};
const LiteralToken = union(enum) {
String: struct { // String (up to 256 chars)
value: [256]u8,
},
Nuumber: struct { // Equivalent to TS 'Number'
value: f64,
},
};
const StatementToken = enum {
If, // if
Foreach, // foreach [<element> of] <operand>: (block)
While, // while <cond>: (block)
To, // to <function> [with <params, ...>]: (block)
};
const BracketToken = enum {
Open, // (
Close, // )
};
pub const Token = union(enum) {
Literal: LiteralToken,
ArithmeticOperator: ArithmeticOperatorToken,
BooleanOperator: BooleanOperatorToken,
Statement: StatementToken,
Bracket: BracketToken,
Variable: variables.VariableToken,
};

20
kabel-zig/src/main.zig Normal file
View File

@ -0,0 +1,20 @@
const std = @import("std");
const lexer = @import("lexer.zig");
pub fn main() !u8 {
const stdout_fd = std.io.getStdOut().writer();
var bw = std.io.bufferedWriter(stdout_fd);
const stdout = bw.writer();
try stdout.print("Run `zig build test` to run the tests.\n", .{});
try bw.flush(); // don't forget to flush!
return 0;
}
//test "simple test" {
// var list = std.ArrayList(i32).init(std.testing.allocator);
// defer list.deinit(); // try commenting this out and see if zig detects the memory leak!
// try list.append(42);
// try std.testing.expectEqual(@as(i32, 42), list.pop());
//}

View File

@ -0,0 +1,8 @@
pub const Modules = union(enum) {
Thruster: struct {
on:
};
pub const ModuleVar = union(enum) {
};

10
kabel-zig/src/root.zig Normal file
View File

@ -0,0 +1,10 @@
const std = @import("std");
const testing = std.testing;
export fn add(a: i32, b: i32) i32 {
return a + b;
}
test "basic add functionality" {
try testing.expect(add(3, 7) == 10);
}

View File

@ -0,0 +1,7 @@
const modules = @import("modules.zig");
pub const VariableToken = union(enum) {
Module: modules.ModuleVar,
Number: f64,
String: [256]u8,
};

75
kabel.py Normal file
View File

@ -0,0 +1,75 @@
#!/usr/bin/env python3
import sys, enum
class ModuleType(enum.Enum):
Basic =
Thruster = enum.auto()
Hub = enum.auto()
class TokenType(enum.Enum):
Declarator = enum.auto()
Arithmetic = enum.auto()
Literal = enum.auto()
Variable = enum.auto()
KEYWORDS = [
"if", # if
"to", # function definition
"using", # arg introducers
"by", # "
"with", # "
"foreach", # for
"it" # iterator
]
STATEMENT_CLASSIFIERS = [
"if",
"to",
"foreach"
]
KEYWORDS_ACCEPT = {
"if":
}
mem = {
"w": [], # Current word being processed
"stno": 0, # Number of statement being processed
"next": 0,
"if":
"cvl": 0, # Convolution level (paren depth)
}
program = []
with open(sys.argv[1]) as f:
prg = f.read().split(";")
def lexer(prg):
for statement in prg: # For statement in program
mem["stno"] = 0
mem["w"] = ""
for char in list(statement):
if char == " " && !mem[""]:
# On spaces or new lines, begin a new word
mem["w"] = ""
continue
else if char == "(":
cvl
else:
mem["w"] += char
#match mem["w"]:
# case "if":
# # Now parsing an if statement
# mem["if"]["active"] = True
# case
if mem["w"] in STATEMENT_CLASSIFIERS:
# Activate mode specified by word
# If mem["w"] is 'if', enable if mode
mem[mem["w"]]["active"] = True