X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/1a4e5a6c9a8fbbdc980cf0661c444ddc2910544a..411a85f26421358c20b11839310cce6caff8cf77:/src/domtool.grm diff --git a/src/domtool.grm b/src/domtool.grm index 349ab7a..ca9ff3a 100644 --- a/src/domtool.grm +++ b/src/domtool.grm @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*) + *) (* Parser for Domtool configuration files *) @@ -31,9 +31,9 @@ open Ast | ARROW | DARROW | LARROW | COLON | CARET | BANG | AND | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE - | EQ | COMMA | BSLASH | SEMI | LET | IN | END + | EQ | COMMA | BSLASH | BSLASHBSLASH | SEMI | LET | IN | END | ROOT - | EXTERN | TYPE | VAL | WITH | WHERE + | EXTERN | TYPE | VAL | WITH | WHERE | CONTEXT %nonterm file of file @@ -76,15 +76,18 @@ open Ast %% -file : decls expOpt (decls, expOpt) +file : docOpt decls expOpt (docOpt, decls, expOpt) decls : ([]) - | decl SEMI decls (decl :: decls) + | decl decls (decl :: decls) -decl : decl' docOpt (decl', docOpt, (decl'left, docOptright)) +decl : decl' SEMI docOpt (decl', docOpt, (decl'left, docOptright)) decl' : EXTERN TYPE SYMBOL (DExternType SYMBOL) | EXTERN VAL SYMBOL COLON typ (DExternVal (SYMBOL, typ)) + | VAL SYMBOL EQ exp (DVal (SYMBOL, NONE, exp)) + | VAL SYMBOL COLON typ EQ exp (DVal (SYMBOL, SOME typ, exp)) + | CONTEXT CSYMBOL (DContext CSYMBOL) docOpt : (NONE) | DOC (SOME DOC) @@ -111,6 +114,8 @@ exp : apps (apps) | BSLASH SYMBOL COLON LPAREN typ RPAREN ARROW exp (ELam (SYMBOL, SOME typ, exp), (BSLASHleft, expright)) | BSLASH SYMBOL ARROW exp (ELam (SYMBOL, NONE, exp), (BSLASHleft, expright)) + | BSLASHBSLASH SYMBOL COLON ctxt ARROW exp (EALam (SYMBOL, ctxt, exp), + (BSLASHBSLASHleft, expright)) | CSYMBOL EQ exp (ESet (CSYMBOL, exp), (CSYMBOLleft, expright)) | exp SEMI exp (let val ls = case #1 exp2 of @@ -119,13 +124,8 @@ exp : apps (apps) in (ESeq ls, (exp1left, exp2right)) end) + | exp SEMI (exp) | SYMBOL LARROW CSYMBOL SEMI exp (EGet (SYMBOL, CSYMBOL, exp), (SYMBOLleft, expright)) - (*| exp WHERE exp END (ELocal (exp1, exp2), (exp1left, ENDright)) - | exp WHERE exp WITH END (EWith ((ELocal (exp1, exp2), (exp1left, ENDright)), - (ESkip, (WITHleft, ENDright))), - (exp1left, ENDright)) - | exp WITH END (EWith (exp, (ESkip, (WITHleft, ENDright))), (expleft, ENDright)) - | exp WITH exp END (EWith (exp1, exp2), (exp1left, ENDright))*) apps : term (term) | apps term (EApp (apps, term), (appsleft, termright))