From 1368849e36e1b5ecd0d595b713ca73f9d88da38b Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 18 Dec 2011 00:56:43 -0700 Subject: Minor tweaks. Now the game metadata can be read without reading anything else from the file, making it much easier to report info about a game rapidly. --- src/parser.y | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'src/parser.y') diff --git a/src/parser.y b/src/parser.y index 95bd00d..ef9d10b 100644 --- a/src/parser.y +++ b/src/parser.y @@ -35,6 +35,7 @@ void yyerror( YYLTYPE *llocp, yyscan_t yyscanner, const char *error ) %} %token tokGame +%token tokGlobal %token tokFunction %token tokSituation %token tokSetup @@ -78,22 +79,26 @@ void yyerror( YYLTYPE *llocp, yyscan_t yyscanner, const char *error ) %left '-' '+' %% -input: gameDecl bodyDecl +input: gameDecls globalDecl bodyDecl ; -gameDecl: tokGame '{' gameExprList '}' +gameDecls: + | gameDecls tokGame '.' tokIdent '=' literal ';' + ; + +globalDecl: tokGlobal '{' globalExprList '}' ; -gameExprList: - | gameExprList cmpltGameExpr - ; +globalExprList: + | globalExprList cmpltGlobalExpr + ; -cmpltGameExpr: gameExpr ';' - | commandDecl - ; +cmpltGlobalExpr: globalExpr ';' + | commandDecl + ; -gameExpr: tokIdent '=' expr - ; +globalExpr: tokIdent '=' expr + ; bodyDecl: | bodyDecl situation @@ -137,11 +142,15 @@ varRef: tokIdent | tokSituation '.' tokIdent ; -expr: tokInt - | tokFloat - | tokString - | tokBool - | tokNull +literal: tokInt + | tokFloat + | tokString + | tokBool + | tokNull + | tokSituationName + ; + +expr: literal | tokIdent '(' listValues ')' | varRef | varRef '=' expr @@ -149,7 +158,6 @@ expr: tokInt | varRef tokMinusAssign expr | varRef tokTimesAssign expr | varRef tokDivideAssign expr - | tokSituationName | expr '+' expr | expr '-' expr | expr '/' expr -- cgit v1.2.3