Extended map expression to map constants by extension.
Fixed the grammar for variable declarations (the ":=" had been disabled by mistake in the last commit).
This commit is contained in:
parent
0768f0c27d
commit
589b62a30c
6
AST.ml
6
AST.ml
@ -446,6 +446,7 @@ and expr =
|
||||
|
||||
and map_expr =
|
||||
MapLookUp of map_lookup reg
|
||||
| MapInj of map_injection reg
|
||||
|
||||
and map_lookup = {
|
||||
path : path;
|
||||
@ -618,7 +619,8 @@ let rec expr_to_region = function
|
||||
| ParExpr {region; _} -> region
|
||||
|
||||
and map_expr_to_region = function
|
||||
MapLookUp {region; _} -> region
|
||||
MapLookUp {region; _}
|
||||
| MapInj {region; _} -> region
|
||||
|
||||
and logic_expr_to_region = function
|
||||
BoolExpr e -> bool_expr_to_region e
|
||||
@ -1091,6 +1093,8 @@ and print_map_expr = function
|
||||
print_token lbracket "[";
|
||||
print_expr inside;
|
||||
print_token rbracket "]"
|
||||
| MapInj inj ->
|
||||
print_map_injection inj
|
||||
|
||||
and print_path = function
|
||||
Name var -> print_var var
|
||||
|
1
AST.mli
1
AST.mli
@ -430,6 +430,7 @@ and expr =
|
||||
|
||||
and map_expr =
|
||||
MapLookUp of map_lookup reg
|
||||
| MapInj of map_injection reg
|
||||
|
||||
and map_lookup = {
|
||||
path : path;
|
||||
|
15
Parser.mly
15
Parser.mly
@ -358,8 +358,8 @@ local_decl:
|
||||
| const_decl { LocalConst $1 }
|
||||
| var_decl { LocalVar $1 }
|
||||
|
||||
unqualified_decl:
|
||||
var COLON type_expr EQUAL extended_expr option(SEMI) {
|
||||
unqualified_decl(OP):
|
||||
var COLON type_expr OP extended_expr option(SEMI) {
|
||||
let stop = match $6 with
|
||||
Some region -> region
|
||||
| None -> $5.region in
|
||||
@ -387,13 +387,13 @@ unqualified_decl:
|
||||
opt_type = $3};
|
||||
rpar = Region.ghost}
|
||||
in ConstrExpr (NoneExpr {region; value})
|
||||
(* | `EMap inj ->
|
||||
MapExpr ( ) *)
|
||||
| `EMap inj ->
|
||||
MapExpr (MapInj inj)
|
||||
in $1, $2, $3, $4, init, $6, stop
|
||||
}
|
||||
|
||||
const_decl:
|
||||
Const unqualified_decl {
|
||||
Const unqualified_decl(EQUAL) {
|
||||
let name, colon, const_type, equal,
|
||||
init, terminator, stop = $2 in
|
||||
let region = cover $1 stop in
|
||||
@ -409,7 +409,7 @@ const_decl:
|
||||
}
|
||||
|
||||
var_decl:
|
||||
Var unqualified_decl {
|
||||
Var unqualified_decl(ASS) {
|
||||
let name, colon, var_type, assign,
|
||||
init, terminator, stop = $2 in
|
||||
let region = cover $1 stop in
|
||||
@ -430,9 +430,8 @@ extended_expr:
|
||||
| LBRACKET RBRACKET { {region = cover $1 $2;
|
||||
value = `EList ($1,$2)} }
|
||||
| C_None { {region = $1; value = `ENone $1} }
|
||||
(*
|
||||
| map_injection { {region = $1.region; value = `EMap $1} }
|
||||
*)
|
||||
|
||||
|
||||
instruction:
|
||||
single_instr { Single $1 }
|
||||
|
Loading…
Reference in New Issue
Block a user