diff --git a/maud_macros/src/parse.rs b/maud_macros/src/parse.rs index c9bdbdf1..08d1a87f 100644 --- a/maud_macros/src/parse.rs +++ b/maud_macros/src/parse.rs @@ -1,13 +1,18 @@ use proc_macro::{ Delimiter, + Group, Literal, + Op, Spacing, Span, - TokenNode, + Term, +// TokenNode, TokenStream, TokenTree, - TokenTreeIter, +// TokenTreeIter, }; + +use proc_macro::token_stream; use std::iter; use std::mem; @@ -28,7 +33,8 @@ struct Parser { output_ident: TokenTree, /// Indicates whether we're inside an attribute node. in_attr: bool, - input: TokenTreeIter, + // Formerly TokenTreeIter; Other candidate: TokenStream? + input: token_stream::IntoIter, } impl Iterator for Parser { @@ -97,26 +103,20 @@ impl Parser { loop { match self.peek2() { None => return Ok(()), - Some((TokenTree { kind: TokenNode::Op(';', _), .. }, _)) => self.advance(), - Some(( - TokenTree { kind: TokenNode::Op('@', _), .. }, - Some(TokenTree { kind: TokenNode::Term(term), span }), - )) if term.as_str() == "let" => { + Some((TokenTree::Op(o), _)) if o.op() == ';' => self.advance(), + Some((TokenTree::Op(o), Some(TokenTree::Term(term)))) if o.op() == '@' && term.as_str() == "let" => { // When emitting a `@let`, wrap the rest of the block in a // new block to avoid scoping issues - let keyword = TokenTree { kind: TokenNode::Term(term), span }; + let keyword = Term::new(term.as_str(), term.span()); self.advance2(); builder.push({ let mut builder = self.builder(); builder.push(keyword); self.let_expr(&mut builder)?; self.markups(&mut builder)?; - TokenTree { - kind: TokenNode::Group(Delimiter::Brace, builder.build()), - span, - } + Group::new(Delimiter::Brace, TokenStream::empty()) }); - }, + }, // end @ op arm _ => self.markup(builder)?, } }