From f67793308e2fe6e7996b7e4734715e6a68fe9e47 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 22 Sep 2018 00:24:27 -0700 Subject: [PATCH] Part of the work for a doc handler --- schala-codegen/src/lib.rs | 6 ++++-- schala-lang/src/lib.rs | 6 ++++++ schala-repl/src/language.rs | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/schala-codegen/src/lib.rs b/schala-codegen/src/lib.rs index 8ab48a0..0d2315d 100644 --- a/schala-codegen/src/lib.rs +++ b/schala-codegen/src/lib.rs @@ -1,5 +1,4 @@ #![feature(trace_macros)] -#![feature(proc_macro)] extern crate proc_macro; #[macro_use] extern crate quote; @@ -52,7 +51,7 @@ fn extract_attribute_list(name: &str, attrs: &Vec) -> Option TokenStream { let ast: DeriveInput = syn::parse(input).unwrap(); let name = &ast.ident; @@ -62,6 +61,7 @@ pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream let file_ext = extract_attribute_arg_by_name("SourceFileExtension", attrs).expect("SourceFileExtension is required"); let passes = extract_attribute_list("PipelineSteps", attrs).expect("PipelineSteps are required"); let pass_idents = passes.iter().map(|x| x.0); + let doc_method: Option = extract_attribute_arg_by_name("DocMethod", attrs); //let pass_names: Vec = passes.iter().map(|pass| pass.0.to_string()).collect(); let pass_descriptors = passes.iter().map(|pass| { @@ -97,6 +97,8 @@ pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream //vec![ #(PassDescriptor { name: #pass_names.to_string(), debug_options: vec![] }),* ] } } + //TODO if doc_method is defined, add code here }; + tokens.into() } diff --git a/schala-lang/src/lib.rs b/schala-lang/src/lib.rs index d9da7af..231db05 100644 --- a/schala-lang/src/lib.rs +++ b/schala-lang/src/lib.rs @@ -35,12 +35,18 @@ mod eval; #[LanguageName = "Schala"] #[SourceFileExtension = "schala"] #[PipelineSteps(tokenizing, parsing(compact,expanded,trace), symbol_table, typechecking, ast_reducing, eval)] +#[DocMethod = "get_doc"] pub struct Schala { state: eval::State<'static>, symbol_table: Rc>, type_context: typechecking::TypeContext<'static>, } +impl Schala { + fn get_doc(&self, _commands: &Vec<&str>) -> Option { + Some(format!("yup this is getting called right")) + } +} impl Schala { fn new_blank_env() -> Schala { diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 79bb860..3ea7f4f 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -156,7 +156,7 @@ pub trait ProgrammingLanguageInterface { fn custom_interpreter_directives_help(&self) -> String { format!(">> No custom interpreter directives specified <<") } - fn get_doc(&mut self, _commands: &Vec<&str>) -> Option { + fn get_doc(&self, _commands: &Vec<&str>) -> Option { None } }