diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-01-17 16:06:32 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-01-18 12:27:12 -0800 |
| commit | 1aaee207378eeb4a6335c1c3621fff9296f2bb63 (patch) | |
| tree | efc657da3f1d2a2e6bd7d30989f47ece2eb2977e /src/comp/syntax/parse/parser.rs | |
| parent | 397d9148a77cfdbbc850da4fa97310afc218a385 (diff) | |
| download | rust-1aaee207378eeb4a6335c1c3621fff9296f2bb63.tar.gz rust-1aaee207378eeb4a6335c1c3621fff9296f2bb63.zip | |
rustc: Accept commas to separate tag variants
Diffstat (limited to 'src/comp/syntax/parse/parser.rs')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index b8f55dcba96..4a4b22c3e12 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -2047,7 +2047,8 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item { expect(p, token::LBRACE); let all_nullary = true; let have_disr = false; - while p.token != token::RBRACE { + let done = false; + while !done { let tok = p.token; alt tok { token::IDENT(name, _) { @@ -2075,13 +2076,21 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item { } _ {/* empty */ } } - expect(p, token::SEMI); + + alt p.token { + token::SEMI. | token::COMMA. { + p.bump(); + if p.token == token::RBRACE { done = true; } + } + token::RBRACE. { done = true; } + _ { /* fall through */ } + } + p.get_id(); let vr = {name: p.get_str(name), args: args, id: p.get_id(), disr_expr: disr_expr}; variants += [spanned(vlo, vhi, vr)]; } - token::RBRACE. {/* empty */ } _ { p.fatal("expected name of variant or '}' but found '" + token::to_str(p.reader, tok) + "'"); |
