Adding proc macro for codegen

This should hopefully make the compiler pass thing I want to do possible
This commit is contained in:
greg 2018-04-27 02:19:09 -07:00
parent 9547275355
commit 82cfd3f03d
6 changed files with 40 additions and 0 deletions

View File

@ -6,6 +6,7 @@ authors = ["greg <greg.shuflin@protonmail.com>"]
[dependencies]
schala-repl = { path = "schala-repl" }
schala-codegen = { path = "schala-codegen" }
maaru-lang = { path = "maaru" }
rukka-lang = { path = "rukka" }
robo-lang = { path = "robo" }

View File

@ -1,6 +1,15 @@
# TODO Items
- sketch of an idea for the REPL:
-each compiler pass should be a (procedural?) macro like
compiler_pass!("parse", dataproducts: ["ast", "parse_tree"], {
match parsing::parse(INPUT) {
Ok(
PASS.add_artifact(
}
-should have an Idris-like `cast To From` function
- REPL:

View File

@ -0,0 +1,9 @@
[package]
name = "schala-codegen"
version = "0.1.0"
authors = ["greg <greg.shuflin@protonmail.com>"]
[dependencies]
[lib]
proc-macro = true

16
schala-codegen/src/lib.rs Normal file
View File

@ -0,0 +1,16 @@
#![feature(proc_macro)]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro]
pub fn print_a_thing(_input: TokenStream) -> TokenStream {
"println!(\"Invoked from a proc macro\");".parse().unwrap()
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

View File

@ -10,3 +10,4 @@ maplit = "*"
lazy_static = "0.2.8"
schala-repl = { path = "../schala-repl" }
schala-codegen = { path = "../schala-codegen" }

View File

@ -1,4 +1,5 @@
#![feature(slice_patterns, box_patterns, box_syntax)]
#![feature(proc_macro)]
extern crate itertools;
#[macro_use]
extern crate lazy_static;
@ -6,6 +7,7 @@ extern crate lazy_static;
extern crate maplit;
extern crate schala_repl;
extern crate schala_codegen;
use itertools::Itertools;
use schala_repl::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, UnfinishedComputation, FinishedComputation};
@ -47,6 +49,8 @@ impl ProgrammingLanguageInterface for Schala {
}
fn execute(&mut self, input: &str, options: &EvalOptions) -> FinishedComputation {
schala_codegen::print_a_thing!();
let mut evaluation = UnfinishedComputation::default();
//tokenzing