From: Clinton Ebadi Date: Wed, 9 Apr 2014 09:50:10 +0000 (-0400) Subject: Parse new `var' primitive X-Git-Tag: release_20140428~3^2~7 X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/commitdiff_plain/8230d01037874c933554158251c0e8c80be0613a Parse new `var' primitive Binds CSymbol to default for an environment variable. --- diff --git a/src/ast.sml b/src/ast.sml index d4c5727..caa7e9d 100644 --- a/src/ast.sml +++ b/src/ast.sml @@ -99,6 +99,7 @@ datatype decl' = DExternType of string | DExternVal of string * typ | DVal of string * typ option * exp + | DEnv of string * typ option * exp | DContext of string type decl = decl' * string option * position diff --git a/src/domtool.grm b/src/domtool.grm index bd2726c..ea6db74 100644 --- a/src/domtool.grm +++ b/src/domtool.grm @@ -34,7 +34,7 @@ open Ast | EQ | COMMA | BSLASH | BSLASHBSLASH | SEMI | LET | IN | BEGIN | END | IF | THEN | ELSE | ROOT | SKIP - | EXTERN | TYPE | VAL | WITH | WHERE | CONTEXT + | EXTERN | TYPE | VAL | ENV | WITH | WHERE | CONTEXT %nonterm file of file @@ -90,6 +90,8 @@ 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)) + | ENV CSYMBOL EQ exp (DEnv (CSYMBOL, NONE, exp)) + | ENV CSYMBOL COLON typ EQ exp (DEnv (CSYMBOL, SOME typ, exp)) | CONTEXT CSYMBOL (DContext CSYMBOL) docOpt : (NONE) diff --git a/src/domtool.lex b/src/domtool.lex index 4f51821..65ceda1 100644 --- a/src/domtool.lex +++ b/src/domtool.lex @@ -138,6 +138,7 @@ lineComment = #[^\n]*\n; "extern" => (Tokens.EXTERN (yypos, yypos + size yytext)); "type" => (Tokens.TYPE (yypos, yypos + size yytext)); "val" => (Tokens.VAL (yypos, yypos + size yytext)); + "var" => (Tokens.ENV (yypos, yypos + size yytext)); "context" => (Tokens.CONTEXT (yypos, yypos + size yytext)); "Root" => (Tokens.ROOT (yypos, yypos + size yytext));