Bug fixing in the AST pretty-printer and new syntax for iterators.
I added a type annotation for the variable iterating a collection, which is also now marked as "map", "set" or "list". I fixed and refactored the pretty-printer for the AST.
This commit is contained in:
parent
27564426da
commit
15937a2459
@ -435,14 +435,22 @@ and var_assign = {
|
||||
}
|
||||
|
||||
and for_collect = {
|
||||
kwd_for : kwd_for;
|
||||
var : variable;
|
||||
bind_to : (arrow * variable) option;
|
||||
kwd_in : kwd_in;
|
||||
expr : expr;
|
||||
block : block reg
|
||||
kwd_for : kwd_for;
|
||||
var : variable;
|
||||
bind_to : (arrow * variable) option;
|
||||
colon : colon;
|
||||
elt_type : type_expr;
|
||||
kwd_in : kwd_in;
|
||||
collection : collection;
|
||||
expr : expr;
|
||||
block : block reg
|
||||
}
|
||||
|
||||
and collection =
|
||||
Map of kwd_map
|
||||
| Set of kwd_set
|
||||
| List of kwd_list
|
||||
|
||||
(* Expressions *)
|
||||
|
||||
and expr =
|
||||
|
@ -419,14 +419,22 @@ and var_assign = {
|
||||
}
|
||||
|
||||
and for_collect = {
|
||||
kwd_for : kwd_for;
|
||||
var : variable;
|
||||
bind_to : (arrow * variable) option;
|
||||
kwd_in : kwd_in;
|
||||
expr : expr;
|
||||
block : block reg
|
||||
kwd_for : kwd_for;
|
||||
var : variable;
|
||||
bind_to : (arrow * variable) option;
|
||||
colon : colon;
|
||||
elt_type : type_expr;
|
||||
kwd_in : kwd_in;
|
||||
collection : collection;
|
||||
expr : expr;
|
||||
block : block reg
|
||||
}
|
||||
|
||||
and collection =
|
||||
Map of kwd_map
|
||||
| Set of kwd_set
|
||||
| List of kwd_list
|
||||
|
||||
(* Expressions *)
|
||||
|
||||
and expr =
|
||||
|
@ -630,17 +630,26 @@ for_loop:
|
||||
block = $5}
|
||||
in For (ForInt {region; value})
|
||||
}
|
||||
| For var option(arrow_clause) In expr block {
|
||||
let region = cover $1 $6.region in
|
||||
| For var option(arrow_clause) COLON type_expr
|
||||
In collection expr block {
|
||||
let region = cover $1 $9.region in
|
||||
let value = {
|
||||
kwd_for = $1;
|
||||
var = $2;
|
||||
bind_to = $3;
|
||||
kwd_in = $4;
|
||||
expr = $5;
|
||||
block = $6}
|
||||
kwd_for = $1;
|
||||
var = $2;
|
||||
bind_to = $3;
|
||||
colon = $4;
|
||||
elt_type = $5;
|
||||
kwd_in = $6;
|
||||
collection = $7;
|
||||
expr = $8;
|
||||
block = $9}
|
||||
in For (ForCollect {region; value})}
|
||||
|
||||
collection:
|
||||
Map { Map $1 }
|
||||
| Set { Set $1 }
|
||||
| List { List $1 }
|
||||
|
||||
var_assign:
|
||||
var ASS expr {
|
||||
let region = cover $1.region (expr_to_region $3)
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user