Fix problem with parsing commas
I should probably rethink how delimited block expressions like if-blocks (and eventually for-blocks) work
This commit is contained in:
parent
c394b81746
commit
1bd48ed5db
@ -677,7 +677,7 @@ if (1, 5) {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn need_to_fix_parser_to_make_work() {
|
||||
fn tuple_pattern_4() {
|
||||
let source = r#"
|
||||
if (1, 5) {
|
||||
is (10, x) -> x,
|
||||
|
@ -749,19 +749,26 @@ impl Parser {
|
||||
//TODO - delimited! isn't sophisticated enough to do thisa
|
||||
//let guards = delimited!(self, LCurlyBrace, guard_arm, Comma, RCurlyBrace);
|
||||
expect!(self, LCurlyBrace);
|
||||
|
||||
let mut guards = vec![];
|
||||
loop {
|
||||
while let Newline = self.peek() {
|
||||
self.next();
|
||||
}
|
||||
match self.peek() {
|
||||
RCurlyBrace | EOF => break,
|
||||
Semicolon | Newline => { self.next(); continue},
|
||||
_ => {
|
||||
let guard_arm = self.guard_arm()?;
|
||||
guards.push(guard_arm);
|
||||
while let Newline = self.peek() {
|
||||
self.next();
|
||||
}
|
||||
loop {
|
||||
match self.peek() {
|
||||
Comma => {self.next(); continue },
|
||||
_ => break
|
||||
Semicolon | Newline => { self.next(); continue; },
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
if let RCurlyBrace = self.peek() {
|
||||
break;
|
||||
}
|
||||
expect!(self, Comma);
|
||||
}
|
||||
}
|
||||
}
|
||||
expect!(self, RCurlyBrace);
|
||||
|
Loading…
Reference in New Issue
Block a user