From e150ee5e1ce33b0a4913d53e5df4658ea508eb6e Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 30 Jan 2012 08:55:14 -0700 Subject: Syntax updated to support options & commands. --- src/parser.y | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/parser.y') diff --git a/src/parser.y b/src/parser.y index 2aff29c..e127627 100644 --- a/src/parser.y +++ b/src/parser.y @@ -58,11 +58,13 @@ void yyerror( YYLTYPE *llocp, yyscan_t yyscanner, GameBuilder &, const char *err %token tokElse %token tokNot %token tokCommand +%token tokOption %token tokPlayer %token tokLtEq %token tokGtEq %token tokCmp %token tokReturn +%token tokIgnore %token tokPlusAssign %token tokMinusAssign %token tokTimesAssign @@ -108,6 +110,7 @@ globalExprList: cmpltGlobalExpr: globalExpr ';' | commandDecl + | ignoreDecl ; globalExpr: tokIdent '=' expr @@ -118,12 +121,19 @@ bodyDecl: | bodyDecl function ; -situation: tokSituation tokSituationName { bld.beginSituation( *($2) ); } '{' situationMembers '}' { bld.endSituation(); } +situationMode: tokSituation tokSituationName { bld.beginSituation( *($2) ); } + | tokCommand tokSituation tokSituationName { bld.beginSituation( *($2) ); } + | tokOption tokSituation tokSituationName { bld.beginSituation( *($2) ); } + ; + +situation: situationMode '{' situationMembers '}' { bld.endSituation(); } ; situationMembers: | situationMembers situationModeFunc | situationMembers commandDecl + | situationMembers optionDecl + | situationMembers ignoreDecl ; situationModeFunc: situationMode '{' cmpltExprList '}' { @@ -274,6 +284,9 @@ dictValues: expr ':' expr { bld.addNode( AstNode::tInsert ); } | dictValues ',' expr ':' expr { bld.addNode( AstNode::tInsert ); } ; +optionDecl: tokOption ':' tokString '{' cmpltExprList '}' + ; + commandDecl: tokCommand ':' tokString { bld.beginCommand( *$3 ); } commandParamList '{' { bld.endCommandParams(); } cmpltExprList '}' { bld.closeCommand(); } ; @@ -282,6 +295,13 @@ commandParamList: | commandParamList tokString { bld.addCommandLiteral( *$2 ); } | commandParamList tokIdent { bld.addCommandParam( *$2 ); } ; + +ignoreDecl: tokIgnore ':' tokString ignoreList ';' + ; + +ignoreList: + | ignoreList tokString + ; %% /* void yylex_init( yyscan_t * ); -- cgit v1.2.3