More concision in parser
This commit is contained in:
parent
f53c14535b
commit
70bf68d9bd
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user