1 (* HCoop Domtool (http://hcoop.sourceforge.net/)
2 * Copyright (c) 2006, Adam Chlipala
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 (* Parser for Domtool configuration files *)
23 %header (functor DomtoolLrValsFn(structure Token : TOKEN))
27 | SYMBOL of string | CSYMBOL of string
30 | ARROW | DARROW | COLON
31 | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE
32 | EQ | COMMA | BSLASH | SEMI | LET | IN | END
45 %verbose (* print summary of errors *)
46 %pos int (* positions *)
65 | BSLASH SYMBOL COLON typ ARROW exp (ELam (SYMBOL, typ, exp), (BSLASHleft, expright))
66 | CSYMBOL EQ exp (ESet (CSYMBOL, exp), (CSYMBOLleft, expright))
68 val ls = case #1 exp2 of
72 (ESeq ls, (exp1left, exp2right))
76 | apps term (EApp (apps, term), (appsleft, termright))
78 term : LPAREN exp RPAREN (exp)
79 | INT (EInt INT, (INTleft, INTright))
80 | STRING (EString STRING, (STRINGleft, STRINGright))
81 | LBRACK elist RBRACK (EList elist, (LBRACKleft, RBRACKright))
82 | LET exp IN exp END (let
83 val ls = case (#1 exp1, #1 exp2) of
84 (ESeq ls1, ESeq ls2) => ls1 @ ls2
85 | (ESeq ls, _) => ls @ [exp2]
86 | (_, ESeq ls) => exp1 :: ls
89 (ESeq ls, (exp1left, exp2right))
96 | exp COMMA elistNe (exp :: elistNe)
98 typ : SYMBOL (TBase SYMBOL, (SYMBOLleft, SYMBOLright))