use match syntax in simple_parse
This commit is contained in:
parent
582a7fd6dc
commit
868373f409
@ -68,7 +68,6 @@ pub fn parse(input: Vec<Token>) -> ParseResult {
|
|||||||
return ParseResult::Ok(AST::Statements(vec!()));
|
return ParseResult::Ok(AST::Statements(vec!()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
match statements(&mut tokens) {
|
match statements(&mut tokens) {
|
||||||
ok@ParseResult::Ok(_) => {
|
ok@ParseResult::Ok(_) => {
|
||||||
expect!(EOF, &mut tokens);
|
expect!(EOF, &mut tokens);
|
||||||
@ -250,19 +249,19 @@ fn get_binop_precedence(token: &Token) -> Option<i32> {
|
|||||||
|
|
||||||
fn simple_expression(tokens: &mut Tokens) -> ParseResult {
|
fn simple_expression(tokens: &mut Tokens) -> ParseResult {
|
||||||
let next = tokens.next();
|
let next = tokens.next();
|
||||||
if let Some(&Identifier(ref value)) = next {
|
|
||||||
return ParseResult::Ok(AST::Name(value.clone()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(&StrLiteral(ref value)) = next {
|
match next {
|
||||||
return ParseResult::Ok(AST::LangString(value.clone()));
|
Some(&Identifier(ref value)) =>
|
||||||
}
|
ParseResult::Ok(AST::Name(value.clone())),
|
||||||
|
|
||||||
if let Some(&NumLiteral(n)) = next {
|
Some(&StrLiteral(ref value)) =>
|
||||||
return ParseResult::Ok(AST::Number(n));
|
ParseResult::Ok(AST::LangString(value.clone())),
|
||||||
}
|
|
||||||
|
|
||||||
return ParseResult::Err("Bad parse in simple_expression()".to_string());
|
Some(&NumLiteral(n)) =>
|
||||||
|
ParseResult::Ok(AST::Number(n)),
|
||||||
|
|
||||||
|
_ => ParseResult::Err("Bad parse in simple_expression()".to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user