From aa40b985f3ad2bb5e4f65b132a18198d33fce7a0 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 10 Mar 2018 14:04:10 -0800 Subject: [PATCH] Experiment to automatically generate parser Gonna give this a shot, automatically generate a recursive-descent parser from BNF --- src/main.rs | 1 + src/schala_lang/autoparser.rs | 25 +++++++++++++++++++++++++ src/schala_lang/mod.rs | 2 ++ 3 files changed, 28 insertions(+) create mode 100644 src/schala_lang/autoparser.rs diff --git a/src/main.rs b/src/main.rs index eb97f4d..63ceef0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,7 @@ extern { } fn main() { let generators: Vec = vec![ Box::new(|| { Box::new(schala_lang::Schala::new())}), + Box::new(|| { Box::new(schala_lang::autoparser::Schala::new())}), Box::new(|| { Box::new(maaru_lang::Maaru::new())}), Box::new(|| { Box::new(robo_lang::Robo::new())}), Box::new(|| { Box::new(rukka_lang::Rukka::new())}), diff --git a/src/schala_lang/autoparser.rs b/src/schala_lang/autoparser.rs new file mode 100644 index 0000000..9a235f8 --- /dev/null +++ b/src/schala_lang/autoparser.rs @@ -0,0 +1,25 @@ +use schala_lib::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, LanguageOutput}; + +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(); + output + } +} diff --git a/src/schala_lang/mod.rs b/src/schala_lang/mod.rs index 0bbc76e..170f250 100644 --- a/src/schala_lang/mod.rs +++ b/src/schala_lang/mod.rs @@ -5,6 +5,8 @@ macro_rules! bx { ($e:expr) => { Box::new($e) } } +pub mod autoparser; + mod builtin; mod tokenizing;