diff --git a/compile.schala b/compile.schala index 4923424..c51175f 100644 --- a/compile.schala +++ b/compile.schala @@ -16,5 +16,6 @@ c = if a { } q = 4 +q = q + 2 q + 1 + c diff --git a/src/language.rs b/src/language.rs new file mode 100644 index 0000000..db758d4 --- /dev/null +++ b/src/language.rs @@ -0,0 +1,18 @@ + +pub struct TokenError { + pub msg: String, +} + +pub struct ParseError { + pub msg: String, +} + +pub trait ProgrammingLanguage { + type Token; + type AST; + + fn tokenize(input: &str) -> Result, TokenError>; + fn parse(input: Vec) -> Result; + fn evaluate(input: &Self::AST); + fn compile(input: &Self::AST); +} diff --git a/src/main.rs b/src/main.rs index 4c40664..efc8dfa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,9 @@ mod parser; use eval::Evaluator; mod eval; +use language::{ProgrammingLanguage, ParseError, TokenError}; +mod language; + use compilation::{compilation_sequence, compile_ast}; mod compilation; mod llvm_wrap; @@ -137,6 +140,13 @@ impl<'a> Repl<'a> { println!("Exiting..."); } + fn new_input_handler(input: &str) -> String { + + let language = Schala {}; + + unimplemented!() + } + fn input_handler(&mut self, input: &str) -> String { let mut output = String::new(); @@ -226,3 +236,25 @@ impl<'a> Repl<'a> { return true; } } + +struct Schala { } + +impl ProgrammingLanguage for Schala { + type Token = tokenizer::Token; + type AST = parser::AST; + + fn tokenize(input: &str) -> Result, TokenError> { + tokenizer::tokenize(input).map_err(|x| TokenError { msg: x.msg }) + } + + fn parse(input: Vec) -> Result { + unimplemented!() + } + fn evaluate(input: &Self::AST) { + unimplemented!() + } + fn compile(input: &Self::AST) { + unimplemented!() + } +} +