diff options
Diffstat (limited to 'parsing')
-rw-r--r-- | parsing/ast_helper.mli | 2 | ||||
-rw-r--r-- | parsing/ast_mapper.ml | 4 | ||||
-rw-r--r-- | parsing/parser.mly | 4 | ||||
-rw-r--r-- | parsing/parsetree.mli | 2 | ||||
-rw-r--r-- | parsing/pprintast.ml | 4 | ||||
-rw-r--r-- | parsing/printast.ml | 5 |
6 files changed, 11 insertions, 10 deletions
diff --git a/parsing/ast_helper.mli b/parsing/ast_helper.mli index 562f51989..995b1ca64 100644 --- a/parsing/ast_helper.mli +++ b/parsing/ast_helper.mli @@ -100,7 +100,7 @@ module Exp: val ifthenelse: ?loc:loc -> ?attrs:attrs -> expression -> expression -> expression option -> expression val sequence: ?loc:loc -> ?attrs:attrs -> expression -> expression -> expression val while_: ?loc:loc -> ?attrs:attrs -> expression -> expression -> expression - val for_: ?loc:loc -> ?attrs:attrs -> str -> expression -> expression -> direction_flag -> expression -> expression + val for_: ?loc:loc -> ?attrs:attrs -> pattern -> expression -> expression -> direction_flag -> expression -> expression val coerce: ?loc:loc -> ?attrs:attrs -> expression -> core_type option -> core_type -> expression val constraint_: ?loc:loc -> ?attrs:attrs -> expression -> core_type -> expression val send: ?loc:loc -> ?attrs:attrs -> expression -> string -> expression diff --git a/parsing/ast_mapper.ml b/parsing/ast_mapper.ml index e10e32cbd..f6edb55f4 100644 --- a/parsing/ast_mapper.ml +++ b/parsing/ast_mapper.ml @@ -292,8 +292,8 @@ module E = struct | Pexp_sequence (e1, e2) -> sequence ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) | Pexp_while (e1, e2) -> while_ ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) - | Pexp_for (id, e1, e2, d, e3) -> - for_ ~loc ~attrs (map_loc sub id) (sub.expr sub e1) (sub.expr sub e2) d + | Pexp_for (p, e1, e2, d, e3) -> + for_ ~loc ~attrs (sub.pat sub p) (sub.expr sub e1) (sub.expr sub e2) d (sub.expr sub e3) | Pexp_coerce (e, t1, t2) -> coerce ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t1) diff --git a/parsing/parser.mly b/parsing/parser.mly index 8b69f265e..3bb662087 100644 --- a/parsing/parser.mly +++ b/parsing/parser.mly @@ -1048,8 +1048,8 @@ expr: { mkexp_attrs (Pexp_ifthenelse($3, $5, None)) $2 } | WHILE ext_attributes seq_expr DO seq_expr DONE { mkexp_attrs (Pexp_while($3, $5)) $2 } - | FOR ext_attributes val_ident EQUAL seq_expr direction_flag seq_expr DO seq_expr DONE - { mkexp_attrs(Pexp_for(mkrhs $3 3, $5, $7, $6, $9)) $2 } + | FOR ext_attributes pattern EQUAL seq_expr direction_flag seq_expr DO seq_expr DONE + { mkexp_attrs(Pexp_for($3, $5, $7, $6, $9)) $2 } | expr COLONCOLON expr { mkexp_cons (rhs_loc 2) (ghexp(Pexp_tuple[$1;$3])) (symbol_rloc()) } | LPAREN COLONCOLON RPAREN LPAREN expr COMMA expr RPAREN diff --git a/parsing/parsetree.mli b/parsing/parsetree.mli index 5de17d439..df0dd47ab 100644 --- a/parsing/parsetree.mli +++ b/parsing/parsetree.mli @@ -244,7 +244,7 @@ and expression_desc = | Pexp_while of expression * expression (* while E1 do E2 done *) | Pexp_for of - string loc * expression * expression * direction_flag * expression + pattern * expression * expression * direction_flag * expression (* for i = E1 to E2 do E3 done (flag = Upto) for i = E1 downto E2 do E3 done (flag = Downto) *) diff --git a/parsing/pprintast.ml b/parsing/pprintast.ml index f8db3d646..cf218f2a8 100644 --- a/parsing/pprintast.ml +++ b/parsing/pprintast.ml @@ -680,8 +680,8 @@ class printer ()= object(self:'self) pp f fmt self#expression e1 self#expression e2 | Pexp_for (s, e1, e2, df, e3) -> let fmt:(_,_,_)format = - "@[<hv0>@[<hv2>@[<2>for %s =@;%a@;%a%a@;do@]@;%a@]@;done@]" in - pp f fmt s.txt self#expression e1 self#direction_flag df self#expression e2 self#expression e3 + "@[<hv0>@[<hv2>@[<2>for %a =@;%a@;%a%a@;do@]@;%a@]@;done@]" in + pp f fmt self#pattern s self#expression e1 self#direction_flag df self#expression e2 self#expression e3 | _ -> self#paren true self#expression f x method attributes f l = diff --git a/parsing/printast.ml b/parsing/printast.ml index dfaf8ce8b..7c6fd9a22 100644 --- a/parsing/printast.ml +++ b/parsing/printast.ml @@ -299,8 +299,9 @@ and expression i ppf x = line i ppf "Pexp_while\n"; expression i ppf e1; expression i ppf e2; - | Pexp_for (s, e1, e2, df, e3) -> - line i ppf "Pexp_for %a %a\n" fmt_direction_flag df fmt_string_loc s; + | Pexp_for (p, e1, e2, df, e3) -> + line i ppf "Pexp_for %a\n" fmt_direction_flag df; + pattern i ppf p; expression i ppf e1; expression i ppf e2; expression i ppf e3; |