forked from AbleScript/ablescript
Tokens added or something
This commit is contained in:
parent
5cf69e933d
commit
2c4154025f
|
@ -1,6 +1,4 @@
|
|||
functio hello(words){
|
||||
words print;
|
||||
}
|
||||
|
||||
|
||||
hello("wonk");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,27 @@
|
|||
pub enum tokens {
|
||||
pub enum TOKENS {
|
||||
LEFT_PARENTHESIS, // (
|
||||
RIGHT_PARENTHESIS, // )
|
||||
LEFT_BRACKET, // [
|
||||
RIGHT_BRACKET, // ]
|
||||
LEFT_BRACE, // {
|
||||
RIGHT_BRACE, // }
|
||||
COMMENT, // #
|
||||
COMMENT { value: String }, // #
|
||||
SUBTRACT, // -
|
||||
ADDITION, // +
|
||||
MULTIPLY, // *
|
||||
DIVIDE, // /
|
||||
CHAR, // Base52 based character
|
||||
FUNCTION, // functio
|
||||
CONSTANT, // constant.e
|
||||
BF_FUNCTION, // Brain fuck FFI
|
||||
BF_FUNCTION { name: String, functio: String }, // Brain fuck FFI
|
||||
VARIABLE, // Variable bro
|
||||
BOOLEAN, // True, False
|
||||
ABOOLEAN, // Always, Sometimes, Never
|
||||
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, //
|
||||
T_DARK,
|
||||
}
|
||||
pub enum ABOOL {
|
||||
NEVER = -1,
|
||||
SOMETIMES = 0,
|
||||
ALWAYS = 1,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue