I added an optional semi-colon in record type declarations.
This commit is contained in:
parent
fa8adb9bde
commit
285be32729
16
AST.ml
16
AST.ml
@ -196,9 +196,10 @@ and variant = {
|
||||
}
|
||||
|
||||
and record_type = {
|
||||
kwd_record : kwd_record;
|
||||
fields : field_decls;
|
||||
kwd_end : kwd_end
|
||||
opening : kwd_record;
|
||||
field_decls : field_decls;
|
||||
terminator : semi option;
|
||||
close : kwd_end
|
||||
}
|
||||
|
||||
and field_decls = (field_decl reg, semi) nsepseq
|
||||
@ -833,10 +834,11 @@ and print_sum_type {value; _} =
|
||||
print_nsepseq "|" print_variant value
|
||||
|
||||
and print_record_type {value; _} =
|
||||
let {kwd_record; fields; kwd_end} = value in
|
||||
print_token kwd_record "record";
|
||||
print_field_decls fields;
|
||||
print_token kwd_end "end"
|
||||
let {opening; field_decls; terminator; close} = value in
|
||||
print_token opening "record";
|
||||
print_field_decls field_decls;
|
||||
print_terminator terminator;
|
||||
print_token close "end"
|
||||
|
||||
and print_type_app {value; _} =
|
||||
let type_name, type_tuple = value in
|
||||
|
7
AST.mli
7
AST.mli
@ -180,9 +180,10 @@ and variant = {
|
||||
}
|
||||
|
||||
and record_type = {
|
||||
kwd_record : kwd_record;
|
||||
fields : field_decls;
|
||||
kwd_end : kwd_end
|
||||
opening : kwd_record;
|
||||
field_decls : field_decls;
|
||||
terminator : semi option;
|
||||
close : kwd_end
|
||||
}
|
||||
|
||||
and field_decls = (field_decl reg, semi) nsepseq
|
||||
|
6
AST2.ml
6
AST2.ml
@ -18,7 +18,7 @@ module O = struct
|
||||
PVar of var_name
|
||||
| PWild
|
||||
| PInt of Z.t
|
||||
| PBytes of Hex.t
|
||||
| PBytes of MBytes.t
|
||||
| PString of string
|
||||
| PUnit
|
||||
| PFalse
|
||||
@ -81,7 +81,7 @@ module O = struct
|
||||
|
||||
and constant =
|
||||
Unit
|
||||
| Int of Z.t | String of string | Bytes of Hex.t
|
||||
| Int of Z.t | String of string | Bytes of MBytes.t
|
||||
| False | True
|
||||
| Null of type_expr
|
||||
| EmptySet of type_expr
|
||||
@ -654,7 +654,7 @@ let s_ast (ast : I.ast) : O.ast =
|
||||
(* and s_bytes {region; value = lexeme, abstract} = *)
|
||||
(* printf "%s: Bytes (\"%s\", \"0x%s\")\n" *)
|
||||
(* (compact region) lexeme *)
|
||||
(* (Hex.to_string abstract) *)
|
||||
(* (MBytes.to_hex abstract |> Hex.to_string) *)
|
||||
|
||||
(* and s_int {region; value = lexeme, abstract} = *)
|
||||
(* printf "%s: Int (\"%s\", %s)\n" *)
|
||||
|
14
Parser.mly
14
Parser.mly
@ -201,12 +201,14 @@ variant:
|
||||
}
|
||||
|
||||
record_type:
|
||||
Record
|
||||
nsepseq(field_decl,SEMI)
|
||||
End
|
||||
{
|
||||
let region = cover $1 $3
|
||||
and value = {kwd_record = $1; fields = $2; kwd_end = $3}
|
||||
Record series(field_decl) {
|
||||
let first, (others, terminator, close) = $2 in
|
||||
let region = cover $1 close
|
||||
and value = {
|
||||
opening = $1;
|
||||
field_decls = first, others;
|
||||
terminator;
|
||||
close}
|
||||
in {region; value}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ type store is
|
||||
goal : nat;
|
||||
deadline : timestamp;
|
||||
backers : map (address, nat);
|
||||
funded : bool
|
||||
funded : bool;
|
||||
end
|
||||
|
||||
const foo : store = map "X" -> 10; "Y" -> 11 end
|
||||
|
Loading…
Reference in New Issue
Block a user