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