forked from AbleScript/ablescript
Worst best parser
This commit is contained in:
parent
abd2d7e5f8
commit
6719d955e8
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3,7 +3,7 @@
|
|||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "able-lang"
|
||||
name = "able-script"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
|
|
10
src/main.rs
10
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");
|
||||
|
|
15
src/parser.rs
Normal file
15
src/parser.rs
Normal 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");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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, //
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue