diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-01-31 13:31:02 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-06 09:13:32 +0100 |
| commit | 5c42e3df9c811be18a220f33fbcb229702922104 (patch) | |
| tree | 09c9978cd068011e8541862bc46fb3de29f17231 /src/comp/syntax/parse/parser.rs | |
| parent | da61e1ff15a3f1ad3aa8dfcf7ac0a646d08f60eb (diff) | |
| download | rust-5c42e3df9c811be18a220f33fbcb229702922104.tar.gz rust-5c42e3df9c811be18a220f33fbcb229702922104.zip | |
Allow non-semicolon-requiring expressions to be followed by .field
There is no valid expression that starts with a dot token (.5 is a number token), so this introduces no ambiguities. Issue #1716
Diffstat (limited to 'src/comp/syntax/parse/parser.rs')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index d3c5695496c..7879aecb7a0 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1039,7 +1039,28 @@ fn parse_dot_or_call_expr_with(p: parser, e0: pexpr) -> pexpr { let e = e0; let lo = e.span.lo; let hi = e.span.hi; - while !expr_is_complete(p, e) { + while true { + // expr.f + if eat(p, token::DOT) { + alt p.token { + token::IDENT(i, _) { + hi = p.span.hi; + p.bump(); + let tys = if eat(p, token::MOD_SEP) { + expect(p, token::LT); + parse_seq_to_gt(some(token::COMMA), + {|p| parse_ty(p, false)}, p) + } else { [] }; + e = mk_pexpr(p, lo, hi, + ast::expr_field(to_expr(e), + p.get_str(i), + tys)); + } + t { unexpected(p, t); } + } + cont; + } + if expr_is_complete(p, e) { break; } alt p.token { // expr(...) token::LPAREN if permits_call(p) { @@ -1076,27 +1097,6 @@ fn parse_dot_or_call_expr_with(p: parser, e0: pexpr) -> pexpr { e = mk_pexpr(p, lo, hi, ast::expr_index(to_expr(e), ix)); } - // expr.f - token::DOT { - p.bump(); - alt p.token { - token::IDENT(i, _) { - hi = p.span.hi; - p.bump(); - let tys = if eat(p, token::MOD_SEP) { - expect(p, token::LT); - parse_seq_to_gt(some(token::COMMA), - {|p| parse_ty(p, false)}, p) - } else { [] }; - e = mk_pexpr(p, lo, hi, - ast::expr_field(to_expr(e), - p.get_str(i), - tys)); - } - t { unexpected(p, t); } - } - } - _ { ret e; } } } |
