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,22 +178,15 @@ 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() { args.push(name);
Some(Identifier(name)) => { self.next();
args.push(name); if let Some(Comma) = self.peek() {
self.next(); self.next();
if let Some(Comma) = self.peek() { } else {
self.next(); break;
} else {
break;
}
},
_ => break
} }
} }
Ok(args) Ok(args)
} }