X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/db427c6775f4d2babcabadbbea93117f593259c6..234b917a6149413bbbeab7dccfaeab5f16e43fe1:/src/domtool.grm diff --git a/src/domtool.grm b/src/domtool.grm index 1ad3a5b..4b8405f 100644 --- a/src/domtool.grm +++ b/src/domtool.grm @@ -26,16 +26,22 @@ open Ast %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 @@ -67,7 +73,22 @@ open Ast %% -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), @@ -81,7 +102,9 @@ exp : apps (apps) 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)) @@ -109,6 +132,7 @@ typ : SYMBOL (TBase SYMBOL, (SYMBOLleft, SYMBOLrig | 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)