diff options
| author | Graydon Hoare <[email protected]> | 2010-08-05 10:04:11 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-08-05 10:04:11 -0700 |
| commit | 29987b56e1dafff4a850eef4e668a364340fc59b (patch) | |
| tree | 6b760dd4406b6bb0087f040626f1b0e37a542f82 /src/boot/fe | |
| parent | Add to std._io some formatter/type-specific-writer mechanism. Make a few typ... (diff) | |
| download | rust-29987b56e1dafff4a850eef4e668a364340fc59b.tar.xz rust-29987b56e1dafff4a850eef4e668a364340fc59b.zip | |
Move 'as' precedence up to just above relational; support indexing str and vec by all integral types. Closes #94.
Diffstat (limited to 'src/boot/fe')
| -rw-r--r-- | src/boot/fe/pexp.ml | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/boot/fe/pexp.ml b/src/boot/fe/pexp.ml index fb2d91a0..3e17e0e4 100644 --- a/src/boot/fe/pexp.ml +++ b/src/boot/fe/pexp.ml @@ -817,11 +817,33 @@ and parse_or_pexp (ps:pstate) : pexp = step lhs +and parse_as_pexp (ps:pstate) : pexp = + let apos = lexpos ps in + let pexp = ctxt "as pexp" parse_or_pexp ps in + let rec step accum = + match peek ps with + AS -> + bump ps; + let tapos = lexpos ps in + let t = parse_ty ps in + let bpos = lexpos ps in + let t = span ps tapos bpos t in + let node = + span ps apos bpos + (PEXP_unop ((Ast.UNOP_cast t), accum)) + in + step node + + | _ -> accum + in + step pexp + + and parse_relational_pexp (ps:pstate) : pexp = let name = "relational pexp" in let apos = lexpos ps in - let lhs = ctxt (name ^ " lhs") parse_or_pexp ps in - let build = binop_build ps name apos parse_or_pexp in + let lhs = ctxt (name ^ " lhs") parse_as_pexp ps in + let build = binop_build ps name apos parse_as_pexp in let rec step accum = match peek ps with LT -> build accum step Ast.BINOP_lt @@ -883,30 +905,8 @@ and parse_oror_pexp (ps:pstate) : pexp = step lhs -and parse_as_pexp (ps:pstate) : pexp = - let apos = lexpos ps in - let pexp = ctxt "as pexp" parse_oror_pexp ps in - let rec step accum = - match peek ps with - AS -> - bump ps; - let tapos = lexpos ps in - let t = parse_ty ps in - let bpos = lexpos ps in - let t = span ps tapos bpos t in - let node = - span ps apos bpos - (PEXP_unop ((Ast.UNOP_cast t), accum)) - in - step node - - | _ -> accum - in - step pexp - - and parse_pexp (ps:pstate) : pexp = - parse_as_pexp ps + parse_oror_pexp ps and parse_mutable_and_pexp (ps:pstate) : (Ast.mutability * pexp) = let mutability = parse_mutability ps in |