summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-01-30 08:55:14 -0700
committerMike Buland <eichlan@xagasoft.com>2012-01-30 08:55:14 -0700
commite150ee5e1ce33b0a4913d53e5df4658ea508eb6e (patch)
tree50014a30908cf434752943994482d22ab3e5fcbd /src
parent22170e030efdeadc1dfbd548a8f0b24b0e10ceee (diff)
downloadstage-e150ee5e1ce33b0a4913d53e5df4658ea508eb6e.tar.gz
stage-e150ee5e1ce33b0a4913d53e5df4658ea508eb6e.tar.bz2
stage-e150ee5e1ce33b0a4913d53e5df4658ea508eb6e.tar.xz
stage-e150ee5e1ce33b0a4913d53e5df4658ea508eb6e.zip
Syntax updated to support options & commands.
Diffstat (limited to 'src')
-rw-r--r--src/parser.l2
-rw-r--r--src/parser.y22
2 files changed, 23 insertions, 1 deletions
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; }
42then { return tokThen; } 42then { return tokThen; }
43else { return tokElse; } 43else { return tokElse; }
44command { return tokCommand; } 44command { return tokCommand; }
45option { return tokOption; }
45goto { return tokGoto; } 46goto { return tokGoto; }
46not { return tokNot; } 47not { return tokNot; }
47setup { return tokSetup; } 48setup { return tokSetup; }
@@ -49,6 +50,7 @@ enter { return tokEnter; }
49and { return tokAnd; } 50and { return tokAnd; }
50or { return tokOr; } 51or { return tokOr; }
51return { return tokReturn; } 52return { return tokReturn; }
53ignore { return tokIgnore; }
52 54
53true { yylval->bValue = true; return tokBool; } 55true { yylval->bValue = true; return tokBool; }
54false { yylval->bValue = false; return tokBool; } 56false { 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
58%token tokElse 58%token tokElse
59%token tokNot 59%token tokNot
60%token tokCommand 60%token tokCommand
61%token tokOption
61%token tokPlayer 62%token tokPlayer
62%token tokLtEq 63%token tokLtEq
63%token tokGtEq 64%token tokGtEq
64%token tokCmp 65%token tokCmp
65%token tokReturn 66%token tokReturn
67%token tokIgnore
66%token tokPlusAssign 68%token tokPlusAssign
67%token tokMinusAssign 69%token tokMinusAssign
68%token tokTimesAssign 70%token tokTimesAssign
@@ -108,6 +110,7 @@ globalExprList:
108 110
109cmpltGlobalExpr: globalExpr ';' 111cmpltGlobalExpr: globalExpr ';'
110 | commandDecl 112 | commandDecl
113 | ignoreDecl
111 ; 114 ;
112 115
113globalExpr: tokIdent '=' expr 116globalExpr: tokIdent '=' expr
@@ -118,12 +121,19 @@ bodyDecl:
118 | bodyDecl function 121 | bodyDecl function
119 ; 122 ;
120 123
121situation: tokSituation tokSituationName { bld.beginSituation( *($2) ); } '{' situationMembers '}' { bld.endSituation(); } 124situationMode: tokSituation tokSituationName { bld.beginSituation( *($2) ); }
125 | tokCommand tokSituation tokSituationName { bld.beginSituation( *($2) ); }
126 | tokOption tokSituation tokSituationName { bld.beginSituation( *($2) ); }
127 ;
128
129situation: situationMode '{' situationMembers '}' { bld.endSituation(); }
122 ; 130 ;
123 131
124situationMembers: 132situationMembers:
125 | situationMembers situationModeFunc 133 | situationMembers situationModeFunc
126 | situationMembers commandDecl 134 | situationMembers commandDecl
135 | situationMembers optionDecl
136 | situationMembers ignoreDecl
127 ; 137 ;
128 138
129situationModeFunc: situationMode '{' cmpltExprList '}' { 139situationModeFunc: situationMode '{' cmpltExprList '}' {
@@ -274,6 +284,9 @@ dictValues: expr ':' expr { bld.addNode( AstNode::tInsert ); }
274 | dictValues ',' expr ':' expr { bld.addNode( AstNode::tInsert ); } 284 | dictValues ',' expr ':' expr { bld.addNode( AstNode::tInsert ); }
275 ; 285 ;
276 286
287optionDecl: tokOption ':' tokString '{' cmpltExprList '}'
288 ;
289
277commandDecl: tokCommand ':' tokString { bld.beginCommand( *$3 ); } 290commandDecl: tokCommand ':' tokString { bld.beginCommand( *$3 ); }
278 commandParamList '{' { bld.endCommandParams(); } cmpltExprList '}' { bld.closeCommand(); } 291 commandParamList '{' { bld.endCommandParams(); } cmpltExprList '}' { bld.closeCommand(); }
279 ; 292 ;
@@ -282,6 +295,13 @@ commandParamList:
282 | commandParamList tokString { bld.addCommandLiteral( *$2 ); } 295 | commandParamList tokString { bld.addCommandLiteral( *$2 ); }
283 | commandParamList tokIdent { bld.addCommandParam( *$2 ); } 296 | commandParamList tokIdent { bld.addCommandParam( *$2 ); }
284 ; 297 ;
298
299ignoreDecl: tokIgnore ':' tokString ignoreList ';'
300 ;
301
302ignoreList:
303 | ignoreList tokString
304 ;
285%% 305%%
286/* 306/*
287void yylex_init( yyscan_t * ); 307void yylex_init( yyscan_t * );