summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-08-28 14:05:47 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-08-28 14:05:47 -0400
commit6cc9b62f90276ce8535ead07a3865cd71d98a526 (patch)
tree58484e9f64d99d6b82faa7c6893700c8e9776319 /src
parent59cfa9f433c17202e1df89de6cdda4cedfae594d (diff)
Shorthand for multi-binding exp declaration
Diffstat (limited to 'src')
-rw-r--r--src/lacweb.grm21
-rw-r--r--src/lacweb.lex1
2 files changed, 19 insertions, 3 deletions
diff --git a/src/lacweb.grm b/src/lacweb.grm
index 2e328891..87fa4655 100644
--- a/src/lacweb.grm
+++ b/src/lacweb.grm
@@ -151,7 +151,7 @@ fun sql_relop (oper, sqlexp1, sqlexp2, loc) =
| LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE
| EQ | COMMA | COLON | DCOLON | TCOLON | DOT | HASH | UNDER | UNDERUNDER | BAR
| DIVIDE | DOTDOTDOT
- | CON | LTYPE | VAL | REC | AND | FOLD | UNIT | KUNIT | CLASS
+ | CON | LTYPE | VAL | REC | AND | FUN | FOLD | UNIT | KUNIT | CLASS
| DATATYPE | OF
| TYPE | NAME
| ARROW | LARROW | DARROW | STAR
@@ -177,6 +177,7 @@ fun sql_relop (oper, sqlexp1, sqlexp2, loc) =
| decl of decl
| vali of string * con option * exp
| valis of (string * con option * exp) list
+ | copt of con option
| dargs of string list
| barOpt of unit
@@ -230,6 +231,7 @@ fun sql_relop (oper, sqlexp1, sqlexp2, loc) =
| eargp of exp * con -> exp * con
| eargs of exp * con -> exp * con
| eargl of exp * con -> exp * con
+ | eargl2 of exp * con -> exp * con
| branch of pat * exp
| branchs of (pat * exp) list
@@ -319,6 +321,7 @@ decl : CON SYMBOL cargl2 kopt EQ cexp (let
| _ => raise Fail "Arguments specified for imported datatype")
| VAL vali (DVal vali, s (VALleft, valiright))
| VAL REC valis (DValRec valis, s (VALleft, valisright))
+ | FUN valis (DValRec valis, s (FUNleft, valisright))
| SIGNATURE CSYMBOL EQ sgn (DSgn (CSYMBOL, sgn), s (SIGNATUREleft, sgnright))
| STRUCTURE CSYMBOL EQ str (DStr (CSYMBOL, NONE, str), s (STRUCTUREleft, strright))
@@ -365,8 +368,17 @@ dcons : dcon ([dcon])
dcon : CSYMBOL (CSYMBOL, NONE)
| CSYMBOL OF cexp (CSYMBOL, SOME cexp)
-vali : SYMBOL EQ eexp (SYMBOL, NONE, eexp)
- | SYMBOL COLON cexp EQ eexp (SYMBOL, SOME cexp, eexp)
+vali : SYMBOL eargl2 copt EQ eexp (let
+ val loc = s (SYMBOLleft, eexpright)
+ val t = Option.getOpt (copt, (CWild (KType, loc), loc))
+
+ val (e, t) = eargl2 (eexp, t)
+ in
+ (SYMBOL, SOME t, e)
+ end)
+
+copt : (NONE)
+ | COLON cexp (SOME cexp)
valis : vali ([vali])
| vali AND valis (vali :: valis)
@@ -581,6 +593,9 @@ eargs : earg (earg)
eargl : eargp eargp (eargp1 o eargp2)
| eargp eargl (eargp o eargl)
+eargl2 : (fn x => x)
+ | eargp eargl2 (eargp o eargl2)
+
earg : SYMBOL kcolon kind (fn (e, t) =>
let
val loc = s (SYMBOLleft, kindright)
diff --git a/src/lacweb.lex b/src/lacweb.lex
index 5ba2f5c8..b7459675 100644
--- a/src/lacweb.lex
+++ b/src/lacweb.lex
@@ -274,6 +274,7 @@ notags = [^<{\n]+;
<INITIAL> "val" => (Tokens.VAL (pos yypos, pos yypos + size yytext));
<INITIAL> "rec" => (Tokens.REC (pos yypos, pos yypos + size yytext));
<INITIAL> "and" => (Tokens.AND (pos yypos, pos yypos + size yytext));
+<INITIAL> "fun" => (Tokens.FUN (pos yypos, pos yypos + size yytext));
<INITIAL> "fn" => (Tokens.FN (pos yypos, pos yypos + size yytext));
<INITIAL> "fold" => (Tokens.FOLD (pos yypos, pos yypos + size yytext));
<INITIAL> "case" => (Tokens.CASE (pos yypos, pos yypos + size yytext));