Tokens added or something

This commit is contained in:
able 2021-04-11 17:22:06 -05:00
parent 5cf69e933d
commit 2c4154025f
4 changed files with 41 additions and 38 deletions

View file

@ -1,6 +1,4 @@
functio hello(words){
words print;
}
hello("wonk");

View file

@ -4,6 +4,7 @@ use clap::{App, Arg};
mod base_55;
mod parser;
pub mod tokens;
fn main() {
let matches = App::new("AbleScript")
.version(env!("CARGO_PKG_VERSION"))
@ -18,11 +19,9 @@ fn main() {
.takes_value(true),
)
.get_matches();
match matches.value_of("file") {
Some(file_path) => {
// Start parsing that file
parser::parse(file_path.to_string());
}
None => {
println!("hi");

View file

@ -1,15 +1,17 @@
use crate::tokens;
use crate::tokens::{ABOOL, TOKENS};
pub fn parse(line: String) {
//match the tokens
//This will not work
let iter = line.split_whitespace();
for x in iter {
match x {
"#" => {
println!("hi");
}
_ => {}
}
pub fn abool2num(abool: ABOOL) -> i32 {
match abool {
ABOOL::NEVER => -1,
ABOOL::SOMETIMES => 0,
ABOOL::ALWAYS => 1,
}
}
pub fn num2abool(number: i32) -> ABOOL {
match number {
-1 => ABOOL::NEVER,
0 => ABOOL::SOMETIMES,
1 => ABOOL::ALWAYS,
_ => ABOOL::SOMETIMES,
}
}

View file

@ -1,23 +1,27 @@
pub enum tokens {
pub enum TOKENS {
LEFT_PARENTHESIS, // (
RIGHT_PARENTHESIS, // )
LEFT_BRACKET, // [
RIGHT_BRACKET, // ]
LEFT_BRACE, // {
RIGHT_BRACE, // }
COMMENT, // #
COMMENT { value: String }, // #
SUBTRACT, // -
ADDITION, // +
MULTIPLY, // *
DIVIDE, // /
CHAR, // Base52 based character
FUNCTION, // functio
CONSTANT, // constant.e
BF_FUNCTION, // Brain fuck FFI
BF_FUNCTION { name: String, functio: String }, // Brain fuck FFI
VARIABLE, // Variable bro
BOOLEAN, // True, False
ABOOLEAN, // Always, Sometimes, Never
BOOLEAN { state: bool }, // True, False
ABOOLEAN { state: u8 }, // Always, Sometimes, Never
PRINT, // Prints the preceding things
MELO, // Ban the following variable from ever being used again
T_DARK, //
T_DARK,
}
pub enum ABOOL {
NEVER = -1,
SOMETIMES = 0,
ALWAYS = 1,
}