Implement sample with working preprocessor (Stage 1 + 2)
This commit is contained in:
30
src/main.rs
30
src/main.rs
@@ -1,16 +1,26 @@
|
||||
mod collector;
|
||||
mod identification;
|
||||
mod preprocessor;
|
||||
mod testcases;
|
||||
mod tokenizer;
|
||||
|
||||
use collector::Collector;
|
||||
use tokenizer::*;
|
||||
|
||||
fn main() {
|
||||
let mut _collector: Collector = Collector {
|
||||
definitions: vec![(String::from(""), String::from(""))],
|
||||
arguments: vec![(String::from(""), String::from(""))],
|
||||
};
|
||||
let sample_code: String = std::fs::read_to_string("example.mlc").unwrap();
|
||||
let mut example_tokenizer: Tokenizer = Tokenizer::new();
|
||||
let mut meta_rules: crate::preprocessor::MetaRules =
|
||||
crate::preprocessor::MetaRules::new("./language.toml");
|
||||
let processed_sample_code: String = meta_rules.process(sample_code.to_owned());
|
||||
example_tokenizer.read_configuration_from_file("./language.toml");
|
||||
example_tokenizer.eat(processed_sample_code.as_str());
|
||||
example_tokenizer.identify_tokens();
|
||||
|
||||
let test_string: String = String::from("(1 + 2) * 3");
|
||||
let mut example_identifier: identification::Identifier =
|
||||
identification::Identifier::new(example_tokenizer.tokens);
|
||||
example_identifier.load_criteria_from_configuration(example_tokenizer.configuration);
|
||||
example_identifier.identify_identifiers();
|
||||
|
||||
let echo_string: String = _collector.eval(test_string);
|
||||
|
||||
println!("Result: {}", echo_string);
|
||||
for token in example_identifier.tokens.iter() {
|
||||
print!("{}", token.token);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user