tcr / parser-c

Haskell's language-c ported to Rust.
http://docs.rs/parser-c
31 stars 5 forks source link

Make reduce! a macro-by-example to work on stable #6

Closed tcr closed 7 years ago

tcr commented 7 years ago

In the rush to get this compiling, there's some regex(!) hacks used in the parser-c-macro crate to get code compiling.

https://github.com/tcr/parser-c/blob/master/parser-c-macro/src/lib.rs#L18-L56

These regexes should be run against and directly committed into the code that uses the reduce!() macro. Then the reduce!() macro can focus exclusively on converting a pattern-matching function like fn test (Some(value): Option<i32>) { .. } into its deconstructed function fn test (_0: Option<i32>) { match _0 { Some(value) => { .. }, _ => panic!("Irrefutable pattern in Rust"); }.

This also would allow it to be rewritten as a procedural macro and compiled on normal rust (see #7).

tcr commented 7 years ago

As of #22 the reduce! macro is very straightforward, and could be converted to run on stable (or really, removed entirely by inlining the code into the alex/happy forks).

birkenfeld commented 7 years ago

Indeed, I've moved the generation into Happy now.