Commit ebcb342f authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Add a non-overloaded "::" operator to assign Cduce types to OCaml polymorphic values.

This allows to write `Stdlib.List.map :: {Int Bool}`. The previous syntax,
`Stdlib.List.map with { Int Bool }` is ambiguous with the `match ... with` and needs
arbitrary look-ahead. It can still be written, with explicit parentheses.
parent d83e713e
...@@ -181,6 +181,7 @@ let id_dummy = U.mk "$$$" ...@@ -181,6 +181,7 @@ let id_dummy = U.mk "$$$"
%left SETMINUS "//" "/@" "/" %left SETMINUS "//" "/@" "/"
%nonassoc ":" %nonassoc ":"
%nonassoc "!" unary_op %nonassoc "!" unary_op
%left "::"
%left "." %left "."
%nonassoc "," ")" %nonassoc "," ")"
...@@ -889,6 +890,7 @@ no_seq_expr: ...@@ -889,6 +890,7 @@ no_seq_expr:
; ;
simple_expr: simple_expr:
| e = simple_expr "::" "{" l = nonempty_list(pat) "}" { exp $sloc (TyArgs(e, l)) }
| e = simple_expr "." l = ident_or_keyword { exp $sloc (Dot (e, label l)) } | e = simple_expr "." l = ident_or_keyword { exp $sloc (Dot (e, label l)) }
| "(" e = expr l = with_annot ")" { exp $sloc (TyArgs (e, l)) } | "(" e = expr l = with_annot ")" { exp $sloc (TyArgs (e, l)) }
| "(" l = separated_nonempty_list(",", multi_expr) ")" { exp $sloc (tuple l) } | "(" l = separated_nonempty_list(",", multi_expr) ")" { exp $sloc (tuple l) }
...@@ -923,7 +925,7 @@ simple_expr: ...@@ -923,7 +925,7 @@ simple_expr:
; ;
with_annot: with_annot:
| "with" "{" l= list(pat) "}" { l } | "with" "{" l= nonempty_list(pat) "}" { l }
; ;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment