Hello!
I'm trying to write a proc macro that parses some custom DSL and transforms it into good Rust ~ for those familiar, I'm trying to parse some kind of separation logic but it's not important.
The "expressions" I want to parse are *
-separated. For example:
emp * (l -> v)
(read "emp star l points to v), and a predicate would look like:
#[predicate]
fn dummy(l: &T) {
emp * (l -> v)
}
Now, Rust is unhappy with my use of ->
in the middle of a function, and I my proc_macro_attribute
function isn't even call if I write this ()
I found a workaround, I write emp * #(l -> v)
and success, I get a token stream! I do what I have to do, and return the correct token stream, in this case something like:
fn dummy(l: &T) {
let v = ...;
__internal::star(
__internal::emp(),
__internal::point_to(l, v)
)
}
Everything parses well and works well, the proc_macro_attribute
function exits correctly, but the compilation still fails, pointing at the #
character before the (l -> v)
saying this:
I looked at the -Z unpretty=expanded
output and it shows a program that correctly parses, but somehow it looks like my dummy
function is parsed twice, once inside of the macro, and once by the actual rust compiler.
Any idea why this is happening?
Cheers