From 9476e7039b1cd4ecc7bb6167081679eb98069836 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 19 Mar 2019 19:26:05 -0700 Subject: [PATCH] Doc requests in type system --- schala-lang/language/src/lib.rs | 21 +++++++++++++-------- schala-repl/src/language.rs | 10 ++++++---- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index 78cdf7a..8e2ac04 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -52,12 +52,10 @@ pub struct Schala { } impl Schala { - fn get_doc(&self, commands: &Vec<&str>) -> Option { - Some(format!("Documentation on commands: {:?}", commands)) - } - - fn handle_custom_interpreter_directives(&mut self, commands: &Vec<&str>) -> Option { - Some(format!("Schala-lang command: {:?} not supported", commands.get(0))) + fn handle_docs(&self, source: String) -> LangMetaResponse { + LangMetaResponse::Docs { + doc_string: format!("<>") + } } } @@ -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!("") } + } } } diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index fd7bcf5..b60fb2c 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -12,10 +12,6 @@ pub trait ProgrammingLanguageInterface { } } - fn repl_request(&self, repl_request: String) -> String { - format!("<>") - } - 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), + Docs { + doc_string: String, + }, Custom { kind: String, value: String