Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ edition = "2018"

[dependencies]
indexing = "0.3.1"
indexmap = "1"
grammer = "0.0.1"
ordermap = "0.3.0"
proc-macro2 = "0.4.0"
proc-quote = "0.2.0"

[build-dependencies]
indexing = "0.3.1"
indexmap = "1"
grammer = "0.0.1"
ordermap = "0.3.0"
proc-macro2 = "0.4.0"
proc-quote = "0.2.0"

Expand All @@ -31,7 +31,7 @@ doctest = false
test = false

[patch.'crates-io']
grammer = { git = "https://github.com/lykenware/grammer", rev = "ed4fc4f9be9aa2c1a6c3245ba4e91684ddff5f2f" }
grammer = { git = "https://github.com/lykenware/grammer", rev = "eb47b51a9332c0e82d7c02d988e203d2a01f3654" }

[workspace]
members = [
Expand Down
13 changes: 5 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
extern crate grammer;
extern crate indexing;
extern crate ordermap;
extern crate proc_macro2;
extern crate proc_quote;
#![deny(rust_2018_idioms)]

// HACK(eddyb) bootstrap by including a subset of the `gll` crate.
#[path = "src/generate/mod.rs"]
Expand All @@ -23,12 +19,13 @@ fn main() {

let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());

let mut grammar = proc_macro::builtin();
grammar.extend(grammer::grammar_grammar());
let mut cx = proc_macro::Context::new();
let mut grammar = proc_macro::builtin(&mut cx);
grammar.extend(grammer::grammar_grammar(&mut cx));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buffalo buffalo buffalo ;)


fs::write(
&out_dir.join("parse_grammar.rs"),
generate::rust::generate(&grammar).to_rustfmt_or_pretty_string(),
generate::rust::generate(&mut cx, &grammar).to_rustfmt_or_pretty_string(),
)
.unwrap();
}
12 changes: 7 additions & 5 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ use proc_quote::ToTokens as _;

#[proc_macro]
pub fn scannerless_parser(input: TokenStream) -> TokenStream {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same on this one.

let grammar: gll::scannerless::Grammar = gll::parse_grammar(input.into()).unwrap();
gll::generate::rust::generate(&grammar)
let mut cx = gll::scannerless::Context::new();
let grammar = gll::parse_grammar(&mut cx, input.into()).unwrap();
gll::generate::rust::generate(&mut cx, &grammar)
.into_token_stream()
.into()
}

#[proc_macro]
pub fn proc_macro_parser(input: TokenStream) -> TokenStream {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preexisting, but could use a doc comment on the function in a follow up PR or something.

let mut grammar = gll::proc_macro::builtin();
grammar.extend(gll::parse_grammar(input.into()).unwrap());
gll::generate::rust::generate(&grammar)
let mut cx = gll::proc_macro::Context::new();
let mut grammar = gll::proc_macro::builtin(&mut cx);
grammar.extend(gll::parse_grammar(&mut cx, input.into()).unwrap());
gll::generate::rust::generate(&mut cx, &grammar)
.into_token_stream()
.into()
}
Loading