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

Tweak the syntax of polymorphic types.

parent a3340e0d
Pipeline #164 failed with stages
in 3 minutes and 26 seconds
......@@ -278,7 +278,7 @@ match n with
Cduce_loc.protect_op "schema";
SchemaDecl (U.mk name, uri)
}
| "debug" d = IDENT "(" l = nonempty_list (arrow_pat) ")" {
| "debug" d = IDENT "(" l = nonempty_list (var_pat) ")" {
let dir = match d, l with
"filter", [t; p] -> `Filter(t, p)
| "accept", [p] -> `Accept p
......@@ -324,8 +324,8 @@ match n with
pat:
| x = app_pat "where" l = and_pat_list { mk $sloc (Recurs(x, List.rev l)) }
| x = app_pat { x }
| x = arrow_pat "where" l = and_pat_list { mk $sloc (Recurs(x, List.rev l)) }
| x = arrow_pat { x }
;
and_pat_list:
......@@ -334,15 +334,6 @@ and_pat_list:
{ (fst id, snd id, p)::l }
;
app_pat:
| x = var_pat p=simple_pat { mk_app_pat $sloc x [p] }
| x = var_pat p=separated_nonempty_list (".", IDENT) {
mk_app_pat $sloc x [ mk $loc(p) (PatVar (List.map ident p, []))]
}
| x = var_pat "(" p = separated_nonempty_list (",", pat) ")" { mk_app_pat $sloc x p }
| x = arrow_pat { x }
;
arrow_pat:
| x = or_pat "->" y = arrow_pat { mk $sloc (Arrow(x, y)) }
| x = or_pat "@" y = arrow_pat { mk $sloc (Concat(x, y)) }
......@@ -358,12 +349,18 @@ or_pat:
and_pat:
| x = and_pat "&" y = var_pat { mk $sloc (And(x, y)) }
| x = and_pat SETMINUS y = var_pat { mk $sloc (Diff(x, y)) }
| x = var_pat { x }
| x = app_pat { x }
;
app_pat:
| x = var_pat "(" l = separated_nonempty_list(",", pat) ")" {
mk_app_pat $sloc x l
}
| x = var_pat { x }
var_pat:
| id = ident_or_keyword_no_ref_no_where ids = e_list
| id = ident_or_keyword_no_ref_no_where "." ids = separated_nonempty_list(".", ident_or_keyword)
| id = ident_or_keyword_no_ref_no_where "." ids = separated_nonempty_list(".", ident_or_keyword)
{ let iids = List.map ident (id::ids) in
mk $sloc (PatVar (iids,[]))
}
......@@ -372,6 +369,8 @@ var_pat:
%inline e_list:
| { [] }
;
constr_pat:
| "(" a = IDENT ":=" c = expr ")" { mk $sloc (Constant (ident a,c))}
| "(" l = separated_nonempty_list (",", pat) ")" {multi_prod $sloc l}
......@@ -824,7 +823,7 @@ expr:
exp $sloc (if check then Check(e, p) else Forget (e, p))
}
(*| e1 = expr ";" e2 = expr { exp $sloc (seq e1 e2)}*)
| "ref" p = arrow_pat e = expr { exp $sloc (Ref (e, p))}
| "ref" p = var_pat e = expr { exp $sloc (Ref (e, p))}
| e1 = expr ":=" e2 = expr { exp $sloc (set_ref e1 e2) }
| e1 = expr op = binop e2 = expr { match op with
| "||" -> exp $sloc (logical_or e1 e2)
......@@ -945,7 +944,7 @@ no_seq_expr:
;
simple_expr:
| e = simple_expr "::" "{" l = nonempty_list(arrow_pat) "}" { exp $sloc (TyArgs(e, l)) }
| e = simple_expr "::" "{" l = nonempty_list(var_pat) "}" { exp $sloc (TyArgs(e, l)) }
| e = simple_expr "." l = ident_or_keyword { exp $sloc (Dot (e, label l)) }
| "(" e = expr l = with_annot ")" { exp $sloc (TyArgs (e, l)) }
| "(" l = separated_nonempty_list(",", multi_expr) ")" { exp $sloc (tuple l) }
......@@ -981,7 +980,7 @@ simple_expr:
;
with_annot:
| "with" "{" l= nonempty_list(arrow_pat) "}" { l }
| "with" "{" l= nonempty_list(var_pat) "}" { l }
;
......
......@@ -38,6 +38,14 @@
(rule (alias overloading) (action (diff overloading.exp overloading.out)))
; end: overloading.cd
; begin: poly-ok.cd
(rule (deps poly-ok.cd) (target poly-ok.cdo)
(action (ignore-outputs (with-accepted-exit-codes 0 (run cduce --compile %{deps})))))
(rule (deps poly-ok.cdo) (target poly-ok.out)
(action (ignore-stderr (with-stdout-to %{target} (with-accepted-exit-codes 0 (run cduce --run %{deps}))))))
(rule (alias poly-ok) (action (diff poly-ok.exp poly-ok.out)))
; end: poly-ok.cd
; begin: web_site.cd
(rule (deps web_site.cd) (target web_site.cdo)
(action (ignore-outputs (with-accepted-exit-codes 0 (run cduce --compile %{deps})))))
......@@ -54,5 +62,6 @@
(alias lazy)
(alias map_even)
(alias overloading)
(alias poly-ok)
(alias web_site)
))
let f =
let r = ref (`Cached,Int)| `None `None in
let r = ref ((`Cached,Int)| `None) `None in
fun ([] : []) : Int =
match !r with
| (`Cached,x) -> x
......
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