* 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 *)
| 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
%%
-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)
| 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
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))