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 = {
|
and for_collect = {
|
||||||
kwd_for : kwd_for;
|
kwd_for : kwd_for;
|
||||||
var : variable;
|
var : variable;
|
||||||
bind_to : (arrow * variable) option;
|
bind_to : (arrow * variable) option;
|
||||||
kwd_in : kwd_in;
|
colon : colon;
|
||||||
expr : expr;
|
elt_type : type_expr;
|
||||||
block : block reg
|
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 *)
|
(* Expressions *)
|
||||||
|
|
||||||
and expr =
|
and expr =
|
||||||
|
@ -419,14 +419,22 @@ and var_assign = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
and for_collect = {
|
and for_collect = {
|
||||||
kwd_for : kwd_for;
|
kwd_for : kwd_for;
|
||||||
var : variable;
|
var : variable;
|
||||||
bind_to : (arrow * variable) option;
|
bind_to : (arrow * variable) option;
|
||||||
kwd_in : kwd_in;
|
colon : colon;
|
||||||
expr : expr;
|
elt_type : type_expr;
|
||||||
block : block reg
|
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 *)
|
(* Expressions *)
|
||||||
|
|
||||||
and expr =
|
and expr =
|
||||||
|
@ -630,17 +630,26 @@ for_loop:
|
|||||||
block = $5}
|
block = $5}
|
||||||
in For (ForInt {region; value})
|
in For (ForInt {region; value})
|
||||||
}
|
}
|
||||||
| For var option(arrow_clause) In expr block {
|
| For var option(arrow_clause) COLON type_expr
|
||||||
let region = cover $1 $6.region in
|
In collection expr block {
|
||||||
|
let region = cover $1 $9.region in
|
||||||
let value = {
|
let value = {
|
||||||
kwd_for = $1;
|
kwd_for = $1;
|
||||||
var = $2;
|
var = $2;
|
||||||
bind_to = $3;
|
bind_to = $3;
|
||||||
kwd_in = $4;
|
colon = $4;
|
||||||
expr = $5;
|
elt_type = $5;
|
||||||
block = $6}
|
kwd_in = $6;
|
||||||
|
collection = $7;
|
||||||
|
expr = $8;
|
||||||
|
block = $9}
|
||||||
in For (ForCollect {region; value})}
|
in For (ForCollect {region; value})}
|
||||||
|
|
||||||
|
collection:
|
||||||
|
Map { Map $1 }
|
||||||
|
| Set { Set $1 }
|
||||||
|
| List { List $1 }
|
||||||
|
|
||||||
var_assign:
|
var_assign:
|
||||||
var ASS expr {
|
var ASS expr {
|
||||||
let region = cover $1.region (expr_to_region $3)
|
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