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.l | 2 ++ src/parser.y | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/parser.l b/src/parser.l index 7957c53..7ceee0a 100644 --- a/src/parser.l +++ b/src/parser.l @@ -42,6 +42,7 @@ if { return tokIf; } then { return tokThen; } else { return tokElse; } command { return tokCommand; } +option { return tokOption; } goto { return tokGoto; } not { return tokNot; } setup { return tokSetup; } @@ -49,6 +50,7 @@ enter { return tokEnter; } and { return tokAnd; } or { return tokOr; } return { return tokReturn; } +ignore { return tokIgnore; } true { yylval->bValue = true; return tokBool; } false { yylval->bValue = false; return tokBool; } 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