mirror of
https://github.com/mii443/gpsl.git
synced 2025-08-22 15:55:26 +00:00
add gpsl bin
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
target/
|
29
src/bin/gpsl.rs
Normal file
29
src/bin/gpsl.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use gpsl::{
|
||||
gpsl::GPSL,
|
||||
source::Source,
|
||||
std::*,
|
||||
tokenizer::Tokenizer,
|
||||
parser::Parser
|
||||
};
|
||||
use std::{fs, env, collections::HashMap};
|
||||
fn main() {
|
||||
env::set_var("RUST_LOG", "info");
|
||||
env_logger::init();
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let mut source = Source::new(fs::read_to_string(&(args.last().unwrap())).expect("Cannot read file."));
|
||||
|
||||
let mut tokenizer = Tokenizer::new();
|
||||
tokenizer.tokenize(&mut source);
|
||||
|
||||
let mut parser = Parser {
|
||||
tokenizer,
|
||||
local_vars: HashMap::new()
|
||||
};
|
||||
|
||||
let mut gpsl = GPSL::new(source, Some(parser.functions().unwrap()), vec![STD_FUNC]);
|
||||
let res = gpsl.run("main".to_string(), vec![]);
|
||||
if let Err(err) = res {
|
||||
println!("Error: {:?}", err);
|
||||
}
|
||||
}
|
@ -332,7 +332,7 @@ impl GPSL {
|
||||
value: 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
while match cond {
|
||||
Variable::Number { value } => value == 1,
|
||||
_ => false
|
||||
|
Reference in New Issue
Block a user