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
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "able-lang"
|
name = "able-script"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -1,6 +1,9 @@
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
|
||||||
mod base_55;
|
mod base_55;
|
||||||
|
mod parser;
|
||||||
|
pub mod tokens;
|
||||||
fn main() {
|
fn main() {
|
||||||
let matches = App::new("AbleScript")
|
let matches = App::new("AbleScript")
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
.version(env!("CARGO_PKG_VERSION"))
|
||||||
|
@ -11,18 +14,15 @@ fn main() {
|
||||||
.short("f")
|
.short("f")
|
||||||
.long("file")
|
.long("file")
|
||||||
.value_name("FILE")
|
.value_name("FILE")
|
||||||
.help("Sets a custom config file")
|
.help("Set the path to interpret from")
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
match matches.value_of("file") {
|
match matches.value_of("file") {
|
||||||
Some(file_path) => {
|
Some(file_path) => {
|
||||||
println!("{}", file_path);
|
|
||||||
// Start parsing that file
|
// Start parsing that file
|
||||||
for x in file_path.chars() {
|
parser::parse(file_path.to_string());
|
||||||
println!("{}", base_55::char2num(x));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
println!("hi");
|
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, // ]
|
RIGHT_BRACKET, // ]
|
||||||
LEFT_BRACE, // {
|
LEFT_BRACE, // {
|
||||||
RIGHT_BRACE, // }
|
RIGHT_BRACE, // }
|
||||||
|
COMMENT, // #
|
||||||
|
SUBTRACT, // -
|
||||||
|
ADDITION, // +
|
||||||
|
MULTIPLY, // *
|
||||||
|
DIVIDE, // /
|
||||||
CHAR, // Base52 based character
|
CHAR, // Base52 based character
|
||||||
|
FUNCTION, // functio
|
||||||
|
CONSTANT, // constant.e
|
||||||
|
BF_FUNCTION, // Brain fuck FFI
|
||||||
VARIABLE, // Variable bro
|
VARIABLE, // Variable bro
|
||||||
BOOLEAN, // True, False
|
BOOLEAN, // True, False
|
||||||
ABOOLEAN, // Always, Sometimes, Never
|
ABOOLEAN, // Always, Sometimes, Never
|
||||||
PRINT, // Prints the preceding things
|
PRINT, // Prints the preceding things
|
||||||
|
MELO, // Ban the following variable from ever being used again
|
||||||
MELO,
|
T_DARK, //
|
||||||
TDARK,
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue