Change "etc" syntax for record patterns from {a:b ...} to {a:b, _}.

This commit is contained in:
Paul Stansifer 2011-07-11 15:20:33 -07:00
parent 48dbee6b47
commit 9a0e85a920
3 changed files with 7 additions and 6 deletions

View File

@ -1465,10 +1465,11 @@ fn parse_pat(&parser p) -> @ast::pat {
auto etc = false;
auto first = true;
while (p.peek() != token::RBRACE) {
if (p.peek() == token::DOT) {
if (first) { first = false; }
else { expect(p, token::COMMA); }
if (p.peek() == token::UNDERSCORE) {
p.bump();
expect(p, token::DOT);
expect(p, token::DOT);
if (p.peek() != token::RBRACE) {
p.fatal("expecting }, found " +
token::to_str(p.get_reader(), p.peek()));
@ -1476,8 +1477,7 @@ fn parse_pat(&parser p) -> @ast::pat {
etc = true;
break;
}
if (first) { first = false; }
else { expect(p, token::COMMA); }
auto fieldname = parse_ident(p);
auto subpat;
if (p.peek() == token::COLON) {

View File

@ -116,6 +116,7 @@ fn to_str(lexer::reader r, token t) -> str {
/* Structural symbols */
case (AT) { ret "@"; }
case (DOT) { ret "."; }
case (ELIPSIS) { ret "..."; }
case (COMMA) { ret ","; }
case (SEMI) { ret ";"; }
case (COLON) { ret ":"; }

View File

@ -4,7 +4,7 @@ tag t3 { c(t2, uint); }
fn m(&t3 in) -> int {
alt in {
c({x: a(?m) ...}, _) { ret m; }
c({x: a(?m), _}, _) { ret m; }
c({x: b(?m), y}, ?z) { ret (m + z) as int + y; }
}
}