Skip to content

Commit

Permalink
WIP markups method match arms
Browse files Browse the repository at this point in the history
  • Loading branch information
anxiousmodernman committed Apr 8, 2018
1 parent c4232da commit 5f0048d
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions maud_macros/src/parse.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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 {
Expand Down Expand Up @@ -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)?,
}
}
Expand Down

0 comments on commit 5f0048d

Please sign in to comment.