diff --git a/Cargo.lock b/Cargo.lock index 4274890..d5bb103 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ version = 3 [[package]] -name = "able-lang" +name = "able-script" version = "0.1.0" dependencies = [ "clap", diff --git a/src/main.rs b/src/main.rs index a87d1cc..ee20b68 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,9 @@ extern crate clap; use clap::{App, Arg}; + mod base_55; +mod parser; +pub mod tokens; fn main() { let matches = App::new("AbleScript") .version(env!("CARGO_PKG_VERSION")) @@ -11,18 +14,15 @@ fn main() { .short("f") .long("file") .value_name("FILE") - .help("Sets a custom config file") + .help("Set the path to interpret from") .takes_value(true), ) .get_matches(); match matches.value_of("file") { Some(file_path) => { - println!("{}", file_path); // Start parsing that file - for x in file_path.chars() { - println!("{}", base_55::char2num(x)); - } + parser::parse(file_path.to_string()); } None => { println!("hi"); diff --git a/src/parser.rs b/src/parser.rs new file mode 100644 index 0000000..8ece020 --- /dev/null +++ b/src/parser.rs @@ -0,0 +1,15 @@ +use crate::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"); + } + _ => {} + } + } +} diff --git a/src/tokens.rs b/src/tokens.rs index 4478e2d..00ba2cb 100644 --- a/src/tokens.rs +++ b/src/tokens.rs @@ -5,12 +5,19 @@ pub enum tokens { 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, - TDARK, + MELO, // Ban the following variable from ever being used again + T_DARK, // }