parser: use braces around tuples, not parentheses
This is the syntax we use in the printer. It has the advantage of
making the printing (and parsing) of tuple types unambiguous, even for
tuples of type 0 or 1:
- `(int)` could be `int` or a 1-ary tuple
- `{int}` can only be a 1-ary tuple
This commit is contained in:
parent
e848910039
commit
1852d50231
@ -34,6 +34,8 @@ rule read = parse
|
||||
| "->" { ARROW }
|
||||
| '(' { LPAR }
|
||||
| ')' { RPAR }
|
||||
| '{' { LBRACE }
|
||||
| '}' { RBRACE }
|
||||
| '*' { STAR }
|
||||
| ',' { COMMA }
|
||||
| '=' { EQ }
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
%token ARROW "->"
|
||||
%token LPAR "("
|
||||
%token RPAR ")"
|
||||
%token LBRACE "{"
|
||||
%token RBRACE "}"
|
||||
%token STAR "*"
|
||||
%token COMMA ","
|
||||
%token EQ "="
|
||||
@ -96,7 +98,7 @@ let typ_arrow :=
|
||||
let typ_atom :=
|
||||
| x = tyvar ;
|
||||
{ STLC.Constr (Structure.Var x) }
|
||||
| "(" ; tys = separated_list ("*", typ) ; ")" ;
|
||||
| "{" ; tys = separated_list ("*", typ) ; "}" ;
|
||||
{ STLC.Constr (Structure.Prod tys) }
|
||||
| "(" ; ~ = typ ; ")" ; <>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user