More concision in parser

This commit is contained in:
greg 2016-01-17 01:17:54 -08:00
parent f53c14535b
commit 70bf68d9bd

View File

@ -119,7 +119,6 @@ macro_rules! expect_identifier {
} }
} }
fn is_delimiter(token: &Token) -> bool { fn is_delimiter(token: &Token) -> bool {
use tokenizer::Token::*; use tokenizer::Token::*;
match *token { match *token {
@ -179,9 +178,7 @@ impl Parser {
fn identlist(&mut self) -> ParseResult<Vec<String>> { fn identlist(&mut self) -> ParseResult<Vec<String>> {
use tokenizer::Token::*; use tokenizer::Token::*;
let mut args: Vec<String> = Vec::new(); let mut args: Vec<String> = Vec::new();
loop { while let Some(Identifier(name)) = self.peek() {
match self.peek() {
Some(Identifier(name)) => {
args.push(name); args.push(name);
self.next(); self.next();
if let Some(Comma) = self.peek() { if let Some(Comma) = self.peek() {
@ -189,12 +186,7 @@ impl Parser {
} else { } else {
break; break;
} }
},
_ => break
} }
}
Ok(args) Ok(args)
} }