aboutsummaryrefslogtreecommitdiff
path: root/src/boot/fe
diff options
context:
space:
mode:
authorRoy Frostig <[email protected]>2010-06-24 08:13:32 -0700
committerRoy Frostig <[email protected]>2010-06-24 08:13:32 -0700
commitbc286c7f2ceb5c3d2e06ec72f78d28842f94ef65 (patch)
treeeac0b9f72ce3a7c97440bc76f38f5159ecc2cdfb /src/boot/fe
parentUpdate README to point to github, test email notification. (diff)
downloadrust-bc286c7f2ceb5c3d2e06ec72f78d28842f94ef65.tar.xz
rust-bc286c7f2ceb5c3d2e06ec72f78d28842f94ef65.zip
Resolve and typecheck patterns in pattern alt.
Diffstat (limited to 'src/boot/fe')
-rw-r--r--src/boot/fe/ast.ml2
-rw-r--r--src/boot/fe/item.ml25
2 files changed, 16 insertions, 11 deletions
diff --git a/src/boot/fe/ast.ml b/src/boot/fe/ast.ml
index bf7a11ff..438d9de9 100644
--- a/src/boot/fe/ast.ml
+++ b/src/boot/fe/ast.ml
@@ -300,7 +300,7 @@ and domain =
and pat =
PAT_lit of lit
- | PAT_tag of ident * (pat array)
+ | PAT_tag of ((name identified) * (pat array))
| PAT_slot of ((slot identified) * ident)
| PAT_wild
diff --git a/src/boot/fe/item.ml b/src/boot/fe/item.ml
index 75f86a58..209526e5 100644
--- a/src/boot/fe/item.ml
+++ b/src/boot/fe/item.ml
@@ -224,24 +224,29 @@ and parse_stmts (ps:pstate) : Ast.stmt array =
let (stmts, lval) = bracketed LPAREN RPAREN parse_lval ps in
let rec parse_pat ps =
match peek ps with
- IDENT ident ->
+ IDENT _ ->
let apos = lexpos ps in
- bump ps;
+ let name = Pexp.parse_name ps in
let bpos = lexpos ps in
- (* TODO: nullary constructors *)
if peek ps != LPAREN then
- let slot =
- { Ast.slot_mode = Ast.MODE_interior;
- Ast.slot_mutable = false;
- Ast.slot_ty = None }
- in
- Ast.PAT_slot ((span ps apos bpos slot), ident)
+ begin
+ match name with
+ Ast.NAME_base (Ast.BASE_ident ident) ->
+ let slot =
+ { Ast.slot_mode = Ast.MODE_interior;
+ Ast.slot_mutable = false;
+ Ast.slot_ty = None }
+ in
+ Ast.PAT_slot
+ ((span ps apos bpos slot), ident)
+ |_ -> raise (unexpected ps)
+ end
else
let pats =
paren_comma_list parse_pat ps
in
- Ast.PAT_tag (ident, pats)
+ Ast.PAT_tag ((span ps apos bpos name), pats)
| LIT_INT _ | LIT_CHAR _ | LIT_BOOL _ ->
Ast.PAT_lit (Pexp.parse_lit ps)
| UNDERSCORE -> bump ps; Ast.PAT_wild