aboutsummaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-12-13 09:25:19 -0800
committerGraydon Hoare <[email protected]>2010-12-13 09:25:19 -0800
commit734c1909188c7b505ca9a0b88bda561a08cf45fd (patch)
tree0ba475271d0709ad657cc8853be8c5e3847bdd2f /src/boot
parentrustc: Typecheck "alt" expressions and patterns (diff)
downloadrust-734c1909188c7b505ca9a0b88bda561a08cf45fd.tar.xz
rust-734c1909188c7b505ca9a0b88bda561a08cf45fd.zip
Syntax tweak: move 'mutable' from pseudo-ty-param on vec ctor to low-precedence prefix inside paren.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/fe/pexp.ml30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/boot/fe/pexp.ml b/src/boot/fe/pexp.ml
index 2f9c2bad..a5f3759a 100644
--- a/src/boot/fe/pexp.ml
+++ b/src/boot/fe/pexp.ml
@@ -471,18 +471,28 @@ and parse_bottom_pexp (ps:pstate) : Ast.pexp =
| VEC ->
bump ps;
- let mutability =
- match peek ps with
- LBRACKET ->
- bump ps;
- expect ps MUTABLE;
- expect ps RBRACKET;
- Ast.MUT_mutable
- | _ -> Ast.MUT_immutable
+ let pexps =
+ ctxt "paren pexps(s)" (rstr false parse_mutable_and_pexp_list) ps
+ in
+ let mutability = ref Ast.MUT_immutable in
+ let pexps =
+ Array.mapi
+ begin
+ fun i (mut, e) ->
+ if i = 0
+ then
+ mutability := mut
+ else
+ if mut <> Ast.MUT_immutable
+ then
+ raise
+ (err "'mutable' keyword after first vec element" ps);
+ e
+ end
+ pexps
in
- let pexps = ctxt "vec pexp: exprs" parse_pexp_list ps in
let bpos = lexpos ps in
- span ps apos bpos (Ast.PEXP_vec (mutability, pexps))
+ span ps apos bpos (Ast.PEXP_vec (!mutability, pexps))
| LIT_STR s ->