Add SourceReference
This commit is contained in:
parent
78b454fb32
commit
a0f4abb9a3
@ -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<RefCell<symbol_table::SymbolTable>>,
|
||||
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<Vec<tokenizing::Token>, 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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user