Vote count:
0
rustc 0.13.0-nightly (f168c12c5 2014-10-25 20:57:10 +0000)
I want to use the rust parser (libsyntax) to parse a rust file and extract information like function names etc. out of it. I just started digging in the docs and code, so my first goal is a program that prints all function names of freestanding functions in a .rs file.
The program should expand all macros before it prints the function names, so functions declared via macro aren't missed. That's why I can't write some crappy little parser by myself to do the job.
I have to admit that I'm not perfectly good at programming rust (yet), so I apologize in advance for any stupid statements in this question.
How I understood it I need to do the following steps:
- Parse the file via the Parser struct
- Expand macros with MacroExpander
- ???
- Use a Visitor to walk the AST and extract the information I need (eg. via #visit_fn)
So here are my questions:
- How do I use MacroExpander?
- How do I walk the expanded AST with a custom visitor?
I hope my question is well-understandable and not too broad. I will edit/split it if requested.
How do I use the rustc parser (libsyntax)?
Aucun commentaire:
Enregistrer un commentaire