%term
EOF
| SYMBOL of string | CSYMBOL of string
- | STRING of string
+ | STRING of string | DOC of string
| INT of int
| ARROW | DARROW | LARROW
| COLON | CARET | BANG | AND
| LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE
| EQ | COMMA | BSLASH | SEMI | LET | IN | END
| ROOT
+ | EXTERN | TYPE | VAL | WITH
%nonterm
- file of exp
+ file of file
+ | decls of decl list
+ | decl of decl
+ | decl' of decl'
+ | docOpt of string option
+ | expOpt of exp option
| exp of exp
| apps of exp
| term of exp
%%
-file : exp (exp)
+file : decls expOpt (decls, expOpt)
+
+decls : ([])
+ | decl SEMI decls (decl :: decls)
+
+decl : decl' docOpt (decl', docOpt, (decl'left, docOptright))
+
+decl' : EXTERN TYPE SYMBOL (DExternType SYMBOL)
+ | EXTERN VAL SYMBOL COLON typ (DExternVal (SYMBOL, typ))
+
+docOpt : (NONE)
+ | DOC (SOME DOC)
+
+expOpt : (NONE)
+ | exp (SOME (ELocal exp, (expleft, expright)))
+
exp : apps (apps)
| BSLASH SYMBOL COLON LPAREN typ RPAREN ARROW exp (ELam (SYMBOL, SOME typ, exp),
in
(ESeq ls, (exp1left, exp2right))
end)
- | SYMBOL LARROW CSYMBOL SEMI exp (EGet (SYMBOL, CSYMBOL, exp), (SYMBOLleft, expright))
+ | SYMBOL LARROW CSYMBOL SEMI exp (EGet (SYMBOL, CSYMBOL, exp), (SYMBOLleft, expright))
+ | apps WITH END (EWith (apps, (ESkip, (WITHleft, ENDright))), (appsleft, ENDright))
+ | apps WITH exp END (EWith (apps, exp), (appsleft, ENDright))
apps : term (term)
| apps term (EApp (apps, term), (appsleft, termright))
| LBRACK ctxt RBRACK (TAction (ctxt, StringMap.empty, StringMap.empty),
(LBRACKleft, ctxtright))
| LPAREN typ RPAREN (typ)
+ | ctxt DARROW ctxt (TNested (ctxt1, ctxt2), (ctxt1left, ctxt2right))
recd : LBRACE RBRACE (StringMap.empty)
| LBRACE recdNe RBRACE (recdNe)