Worst best parser

This commit is contained in:
able 2021-04-11 15:11:23 -05:00
parent abd2d7e5f8
commit 6719d955e8
4 changed files with 31 additions and 9 deletions

2
Cargo.lock generated
View file

@ -3,7 +3,7 @@
version = 3
[[package]]
name = "able-lang"
name = "able-script"
version = "0.1.0"
dependencies = [
"clap",

View file

@ -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");

15
src/parser.rs Normal file
View file

@ -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");
}
_ => {}
}
}
}

View file

@ -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, //
}