diff --git a/able-script-test/functio.able b/able-script-test/functio.able index f1ad098..ce690b4 100644 --- a/able-script-test/functio.able +++ b/able-script-test/functio.able @@ -1,6 +1,4 @@ functio hello(words){ words print; } - - hello("wonk"); diff --git a/src/main.rs b/src/main.rs index ee20b68..87b856c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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"); diff --git a/src/parser.rs b/src/parser.rs index 8ece020..f2efb06 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -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, } } diff --git a/src/tokens.rs b/src/tokens.rs index 00ba2cb..187afa3 100644 --- a/src/tokens.rs +++ b/src/tokens.rs @@ -1,23 +1,27 @@ -pub enum tokens { - LEFT_PARENTHESIS, // ( - RIGHT_PARENTHESIS, // ) - LEFT_BRACKET, // [ - RIGHT_BRACKET, // ] - LEFT_BRACE, // { - RIGHT_BRACE, // } - COMMENT, // # - SUBTRACT, // - - ADDITION, // + - MULTIPLY, // * - DIVIDE, // / - CHAR, // Base52 based character - FUNCTION, // functio - CONSTANT, // constant.e - BF_FUNCTION, // Brain fuck FFI - VARIABLE, // Variable bro - BOOLEAN, // True, False - ABOOLEAN, // Always, Sometimes, Never - PRINT, // Prints the preceding things - MELO, // Ban the following variable from ever being used again - T_DARK, // +pub enum TOKENS { + LEFT_PARENTHESIS, // ( + RIGHT_PARENTHESIS, // ) + LEFT_BRACKET, // [ + RIGHT_BRACKET, // ] + LEFT_BRACE, // { + RIGHT_BRACE, // } + COMMENT { value: String }, // # + SUBTRACT, // - + ADDITION, // + + MULTIPLY, // * + DIVIDE, // / + CHAR, // Base52 based character + FUNCTION, // functio + BF_FUNCTION { name: String, functio: String }, // Brain fuck FFI + VARIABLE, // Variable bro + 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, +} +pub enum ABOOL { + NEVER = -1, + SOMETIMES = 0, + ALWAYS = 1, }