Doc requests in type system

This commit is contained in:
greg 2019-03-19 19:26:05 -07:00
parent c767402865
commit 9476e7039b
2 changed files with 19 additions and 12 deletions

View File

@ -52,12 +52,10 @@ pub struct Schala {
}
impl Schala {
fn get_doc(&self, commands: &Vec<&str>) -> Option<String> {
Some(format!("Documentation on commands: {:?}", commands))
}
fn handle_custom_interpreter_directives(&mut self, commands: &Vec<&str>) -> Option<String> {
Some(format!("Schala-lang command: {:?} not supported", commands.get(0)))
fn handle_docs(&self, source: String) -> LangMetaResponse {
LangMetaResponse::Docs {
doc_string: format!("<<Schala-lang documentation not yet implemented>>")
}
}
}
@ -246,7 +244,14 @@ impl ProgrammingLanguageInterface for Schala {
}
}
fn repl_request(&self, repl_request: String) -> String {
format!("Schala: can't understand {}", repl_request)
fn request_meta(&mut self, request: LangMetaRequest) -> LangMetaResponse {
match request {
LangMetaRequest::StageNames => LangMetaResponse::StageNames(
vec!["tokenizing".into(), "parsing".into(), "typechecking".into(),
"ast reduction".into(), "ast-walking evaluation".into()]
),
LangMetaRequest::Docs { source } => self.handle_docs(source),
LangMetaRequest::Custom { .. } => LangMetaResponse::Custom { kind: format!("not-implemented"), value: format!("") }
}
}
}

View File

@ -12,10 +12,6 @@ pub trait ProgrammingLanguageInterface {
}
}
fn repl_request(&self, repl_request: String) -> String {
format!("<<No custom interpreter directives or help info specified>>")
}
fn request_meta(&mut self, _request: LangMetaRequest) -> LangMetaResponse {
LangMetaResponse::Custom { kind: format!("not-implemented"), value: format!("") }
}
@ -44,6 +40,9 @@ pub struct DebugResponse {
pub enum LangMetaRequest {
StageNames,
Docs {
source: String,
},
Custom {
kind: String,
value: String
@ -52,6 +51,9 @@ pub enum LangMetaRequest {
pub enum LangMetaResponse {
StageNames(Vec<String>),
Docs {
doc_string: String,
},
Custom {
kind: String,
value: String