35 lines
948 B
Rust
35 lines
948 B
Rust
use schala_lib::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, LanguageOutput};
|
|
use itertools::Itertools;
|
|
|
|
use schala_lang::{tokenizing, parsing};
|
|
|
|
pub struct Schala { }
|
|
|
|
impl Schala {
|
|
pub fn new() -> Schala {
|
|
Schala { }
|
|
}
|
|
}
|
|
|
|
impl ProgrammingLanguageInterface for Schala {
|
|
fn get_language_name(&self) -> String {
|
|
"Schala-autoparser".to_string()
|
|
}
|
|
fn get_source_file_suffix(&self) -> String {
|
|
format!("schala")
|
|
}
|
|
|
|
fn evaluate_in_repl(&mut self, input: &str, options: &EvalOptions) -> LanguageOutput {
|
|
let mut output = LanguageOutput::default();
|
|
|
|
let tokens = tokenizing::tokenize(input);
|
|
if options.debug_tokens {
|
|
let token_string = tokens.iter().map(|t| format!("{:?}<L:{},C:{}>", t.token_type, t.offset.0, t.offset.1)).join(", ");
|
|
output.add_artifact(TraceArtifact::new("tokens", format!("{:?}", token_string)));
|
|
}
|
|
|
|
output.add_output(format!("{:?}", tokens));
|
|
output
|
|
}
|
|
}
|