BIND
[hcoop/domtool2.git] / src / domtool.grm
index 349ab7a..549a183 100644 (file)
@@ -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 *)
 
@@ -33,7 +33,7 @@ open Ast
  | LPAREN | RPAREN | LBRACK | RBRACK | LBRACE | RBRACE
  | EQ | COMMA | BSLASH | 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)
@@ -119,13 +122,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))