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