Created
February 25, 2016 21:35
-
-
Save sophiajt/74de80d7566380d91308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn parse_if<'a>(input: &mut Peekable<TokenIterator<'a>>) -> Result<Stmt, ParseError> { | |
Ok(Stmt::Expr(Node::IntConst(3))) | |
} | |
fn parse_expr_stmt<'a>(input: &mut Peekable<TokenIterator<'a>>) -> Result<Stmt, ParseError> { | |
Ok(Stmt::Expr(Node::IntConst(4))) | |
} | |
fn parse_stmt<'a>(input: &mut Peekable<TokenIterator<'a>>) -> Result<Stmt, ParseError> { | |
let mut parser = match input.peek() { | |
Some(_) => parse_if, | |
_ => parse_expr_stmt | |
}; | |
parser(input) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment