From a0f4abb9a30d86822a32ae66de1c5b6e0a1419f9 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 6 Jan 2019 01:58:16 -0800 Subject: [PATCH] Add SourceReference --- schala-lang/language/src/lib.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index 8585e28..02746c4 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -42,13 +42,14 @@ mod eval; #[derive(ProgrammingLanguageInterface)] #[LanguageName = "Schala"] #[SourceFileExtension = "schala"] -#[PipelineSteps(tokenizing, parsing(compact,expanded,trace), symbol_table, typechecking, ast_reducing, eval)] +#[PipelineSteps(load_source, tokenizing, parsing(compact,expanded,trace), symbol_table, typechecking, ast_reducing, eval)] #[DocMethod = get_doc] #[HandleCustomInterpreterDirectives = handle_custom_interpreter_directives] /// All bits of state necessary to parse and execute a Schala program are stored in this struct /// `state` represents the execution state for the AST-walking interpreter, the other fields /// should be self-explanatory. pub struct Schala { + source_reference: SourceReference, state: eval::State<'static>, symbol_table: Rc>, type_context: typechecking::TypeContext<'static>, @@ -70,6 +71,7 @@ impl Schala { fn new_blank_env() -> Schala { let symbols = Rc::new(RefCell::new(symbol_table::SymbolTable::new())); Schala { + source_reference: SourceReference::new(), symbol_table: symbols.clone(), state: eval::State::new(symbols), type_context: typechecking::TypeContext::new(), @@ -87,6 +89,11 @@ impl Schala { } } +//TODO rejigger the signature of these methods so you don't awkwardly have the input in the middle +fn load_source<'a>(_handle: &mut Schala, input: &'a str, comp: Option<&mut UnfinishedComputation>) -> Result<&'a str, String> { + Ok(input) +} + fn tokenizing(_handle: &mut Schala, input: &str, comp: Option<&mut UnfinishedComputation>) -> Result, String> { let tokens = tokenizing::tokenize(input); comp.map(|comp| { @@ -175,3 +182,16 @@ fn eval(handle: &mut Schala, input: reduced_ast::ReducedAST, comp: Option<&mut U eval_output } +struct SourceReference { + +} + +impl SourceReference { + fn new() -> SourceReference { + SourceReference { } + } + + fn load_new_source(&mut self, source: String) { + + } +}