Add parse_token_trees.
Token trees are much simpler than an AST.
This makes them easier to work with when they are sufficient
for the task at hand, such as for example [expanding a procedural macro](
https://github.com/servo/html5ever/pull/217).
diff --git a/src/lib.rs b/src/lib.rs
index f331a0b..f051a78 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -92,7 +92,7 @@
use nom::IResult;
#[cfg(feature = "full")]
- use {expr, item, krate};
+ use {expr, item, krate, mac};
pub fn parse_macro_input(input: &str) -> Result<MacroInput, String> {
unwrap("macro input", macro_input::parsing::macro_input, input)
@@ -125,6 +125,11 @@
unwrap("where clause", generics::parsing::where_clause, input)
}
+ #[cfg(feature = "full")]
+ pub fn parse_token_trees(input: &str) -> Result<Vec<TokenTree>, String> {
+ unwrap("token trees", mac::parsing::token_trees, input)
+ }
+
fn unwrap<T>(name: &'static str,
f: fn(&str) -> IResult<&str, T>,
input: &str)