forked from AbleScript/ablescript
Tokens added or something
This commit is contained in:
parent
5cf69e933d
commit
2c4154025f
|
@ -1,6 +1,4 @@
|
||||||
functio hello(words){
|
functio hello(words){
|
||||||
words print;
|
words print;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
hello("wonk");
|
hello("wonk");
|
||||||
|
|
|
@ -4,6 +4,7 @@ use clap::{App, Arg};
|
||||||
mod base_55;
|
mod base_55;
|
||||||
mod parser;
|
mod parser;
|
||||||
pub mod tokens;
|
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"))
|
||||||
|
@ -18,11 +19,9 @@ fn main() {
|
||||||
.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) => {
|
||||||
// Start parsing that file
|
// Start parsing that file
|
||||||
parser::parse(file_path.to_string());
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
println!("hi");
|
println!("hi");
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
use crate::tokens;
|
use crate::tokens::{ABOOL, TOKENS};
|
||||||
|
|
||||||
pub fn parse(line: String) {
|
pub fn abool2num(abool: ABOOL) -> i32 {
|
||||||
//match the tokens
|
match abool {
|
||||||
//This will not work
|
ABOOL::NEVER => -1,
|
||||||
let iter = line.split_whitespace();
|
ABOOL::SOMETIMES => 0,
|
||||||
for x in iter {
|
ABOOL::ALWAYS => 1,
|
||||||
match x {
|
}
|
||||||
"#" => {
|
}
|
||||||
println!("hi");
|
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, // (
|
LEFT_PARENTHESIS, // (
|
||||||
RIGHT_PARENTHESIS, // )
|
RIGHT_PARENTHESIS, // )
|
||||||
LEFT_BRACKET, // [
|
LEFT_BRACKET, // [
|
||||||
RIGHT_BRACKET, // ]
|
RIGHT_BRACKET, // ]
|
||||||
LEFT_BRACE, // {
|
LEFT_BRACE, // {
|
||||||
RIGHT_BRACE, // }
|
RIGHT_BRACE, // }
|
||||||
COMMENT, // #
|
COMMENT { value: String }, // #
|
||||||
SUBTRACT, // -
|
SUBTRACT, // -
|
||||||
ADDITION, // +
|
ADDITION, // +
|
||||||
MULTIPLY, // *
|
MULTIPLY, // *
|
||||||
DIVIDE, // /
|
DIVIDE, // /
|
||||||
CHAR, // Base52 based character
|
CHAR, // Base52 based character
|
||||||
FUNCTION, // functio
|
FUNCTION, // functio
|
||||||
CONSTANT, // constant.e
|
BF_FUNCTION { name: String, functio: String }, // Brain fuck FFI
|
||||||
BF_FUNCTION, // Brain fuck FFI
|
|
||||||
VARIABLE, // Variable bro
|
VARIABLE, // Variable bro
|
||||||
BOOLEAN, // True, False
|
BOOLEAN { state: bool }, // True, False
|
||||||
ABOOLEAN, // Always, Sometimes, Never
|
ABOOLEAN { state: u8 }, // Always, Sometimes, Never
|
||||||
PRINT, // Prints the preceding things
|
PRINT, // Prints the preceding things
|
||||||
MELO, // Ban the following variable from ever being used again
|
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