diff options
-rw-r--r-- | demo.stage | 6 | ||||
-rw-r--r-- | src/parser.l | 2 | ||||
-rw-r--r-- | src/parser.y | 22 | ||||
-rw-r--r-- | support/vim/syntax/stage.vim | 2 |
4 files changed, 28 insertions, 4 deletions
@@ -118,9 +118,10 @@ situation <<beachEast>> | |||
118 | } | 118 | } |
119 | enter | 119 | enter |
120 | { | 120 | { |
121 | display('''You're standing on a narrow stretch of beach.[break] The ocean | 121 | display('''You're standing on a narrow stretch of beach. The ocean |
122 | sparkles to the north, there's a cliff face just to the south. The | 122 | sparkles to the north, there's a cliff face just to the south. The |
123 | beach extends [green>westward<green]. To the east are some jagged rocks.'''); | 123 | beach extends [green>westward<green]. To the east are some jagged |
124 | rocks.'''); | ||
124 | } | 125 | } |
125 | } | 126 | } |
126 | 127 | ||
@@ -136,6 +137,7 @@ situation <<beachCenter>> | |||
136 | } | 137 | } |
137 | enter | 138 | enter |
138 | { | 139 | { |
140 | |||
139 | } | 141 | } |
140 | } | 142 | } |
141 | 143 | ||
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; } | |||
42 | then { return tokThen; } | 42 | then { return tokThen; } |
43 | else { return tokElse; } | 43 | else { return tokElse; } |
44 | command { return tokCommand; } | 44 | command { return tokCommand; } |
45 | option { return tokOption; } | ||
45 | goto { return tokGoto; } | 46 | goto { return tokGoto; } |
46 | not { return tokNot; } | 47 | not { return tokNot; } |
47 | setup { return tokSetup; } | 48 | setup { return tokSetup; } |
@@ -49,6 +50,7 @@ enter { return tokEnter; } | |||
49 | and { return tokAnd; } | 50 | and { return tokAnd; } |
50 | or { return tokOr; } | 51 | or { return tokOr; } |
51 | return { return tokReturn; } | 52 | return { return tokReturn; } |
53 | ignore { return tokIgnore; } | ||
52 | 54 | ||
53 | true { yylval->bValue = true; return tokBool; } | 55 | true { yylval->bValue = true; return tokBool; } |
54 | false { yylval->bValue = false; return tokBool; } | 56 | 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 | |||
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 | ||
109 | cmpltGlobalExpr: globalExpr ';' | 111 | cmpltGlobalExpr: globalExpr ';' |
110 | | commandDecl | 112 | | commandDecl |
113 | | ignoreDecl | ||
111 | ; | 114 | ; |
112 | 115 | ||
113 | globalExpr: tokIdent '=' expr | 116 | globalExpr: tokIdent '=' expr |
@@ -118,12 +121,19 @@ bodyDecl: | |||
118 | | bodyDecl function | 121 | | bodyDecl function |
119 | ; | 122 | ; |
120 | 123 | ||
121 | situation: tokSituation tokSituationName { bld.beginSituation( *($2) ); } '{' situationMembers '}' { bld.endSituation(); } | 124 | situationMode: tokSituation tokSituationName { bld.beginSituation( *($2) ); } |
125 | | tokCommand tokSituation tokSituationName { bld.beginSituation( *($2) ); } | ||
126 | | tokOption tokSituation tokSituationName { bld.beginSituation( *($2) ); } | ||
127 | ; | ||
128 | |||
129 | situation: situationMode '{' situationMembers '}' { bld.endSituation(); } | ||
122 | ; | 130 | ; |
123 | 131 | ||
124 | situationMembers: | 132 | situationMembers: |
125 | | situationMembers situationModeFunc | 133 | | situationMembers situationModeFunc |
126 | | situationMembers commandDecl | 134 | | situationMembers commandDecl |
135 | | situationMembers optionDecl | ||
136 | | situationMembers ignoreDecl | ||
127 | ; | 137 | ; |
128 | 138 | ||
129 | situationModeFunc: situationMode '{' cmpltExprList '}' { | 139 | situationModeFunc: 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 | ||
287 | optionDecl: tokOption ':' tokString '{' cmpltExprList '}' | ||
288 | ; | ||
289 | |||
277 | commandDecl: tokCommand ':' tokString { bld.beginCommand( *$3 ); } | 290 | commandDecl: 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 | |||
299 | ignoreDecl: tokIgnore ':' tokString ignoreList ';' | ||
300 | ; | ||
301 | |||
302 | ignoreList: | ||
303 | | ignoreList tokString | ||
304 | ; | ||
285 | %% | 305 | %% |
286 | /* | 306 | /* |
287 | void yylex_init( yyscan_t * ); | 307 | void yylex_init( yyscan_t * ); |
diff --git a/support/vim/syntax/stage.vim b/support/vim/syntax/stage.vim index 45e1346..13d86b4 100644 --- a/support/vim/syntax/stage.vim +++ b/support/vim/syntax/stage.vim | |||
@@ -19,7 +19,7 @@ syn keyword Statement setup enter | |||
19 | syn keyword Todo TODO FIXME XXX | 19 | syn keyword Todo TODO FIXME XXX |
20 | syn keyword Type function command situation game global player | 20 | syn keyword Type function command situation game global player |
21 | syn keyword Constant null true false | 21 | syn keyword Constant null true false |
22 | syn keyword Builtins display goto exists delete exit return random integer float | 22 | syn keyword Builtins display goto exists delete exit return random integer float string debugString keys join |
23 | 23 | ||
24 | syn cluster CommentGroup contains=Todo | 24 | syn cluster CommentGroup contains=Todo |
25 | 25 | ||