Adding proc macro for codegen
This should hopefully make the compiler pass thing I want to do possible
This commit is contained in:
parent
9547275355
commit
82cfd3f03d
@ -6,6 +6,7 @@ authors = ["greg <greg.shuflin@protonmail.com>"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
schala-repl = { path = "schala-repl" }
|
schala-repl = { path = "schala-repl" }
|
||||||
|
schala-codegen = { path = "schala-codegen" }
|
||||||
maaru-lang = { path = "maaru" }
|
maaru-lang = { path = "maaru" }
|
||||||
rukka-lang = { path = "rukka" }
|
rukka-lang = { path = "rukka" }
|
||||||
robo-lang = { path = "robo" }
|
robo-lang = { path = "robo" }
|
||||||
|
9
TODO.md
9
TODO.md
@ -1,6 +1,15 @@
|
|||||||
|
|
||||||
# TODO Items
|
# 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
|
-should have an Idris-like `cast To From` function
|
||||||
|
|
||||||
- REPL:
|
- REPL:
|
||||||
|
9
schala-codegen/Cargo.toml
Normal file
9
schala-codegen/Cargo.toml
Normal 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
16
schala-codegen/src/lib.rs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -10,3 +10,4 @@ maplit = "*"
|
|||||||
lazy_static = "0.2.8"
|
lazy_static = "0.2.8"
|
||||||
|
|
||||||
schala-repl = { path = "../schala-repl" }
|
schala-repl = { path = "../schala-repl" }
|
||||||
|
schala-codegen = { path = "../schala-codegen" }
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#![feature(slice_patterns, box_patterns, box_syntax)]
|
#![feature(slice_patterns, box_patterns, box_syntax)]
|
||||||
|
#![feature(proc_macro)]
|
||||||
extern crate itertools;
|
extern crate itertools;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
@ -6,6 +7,7 @@ extern crate lazy_static;
|
|||||||
extern crate maplit;
|
extern crate maplit;
|
||||||
|
|
||||||
extern crate schala_repl;
|
extern crate schala_repl;
|
||||||
|
extern crate schala_codegen;
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use schala_repl::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, UnfinishedComputation, FinishedComputation};
|
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 {
|
fn execute(&mut self, input: &str, options: &EvalOptions) -> FinishedComputation {
|
||||||
|
schala_codegen::print_a_thing!();
|
||||||
|
|
||||||
let mut evaluation = UnfinishedComputation::default();
|
let mut evaluation = UnfinishedComputation::default();
|
||||||
|
|
||||||
//tokenzing
|
//tokenzing
|
||||||
|
Loading…
Reference in New Issue
Block a user