summaryrefslogtreecommitdiff
path: root/src/parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.y')
-rw-r--r--src/parser.y27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/parser.y b/src/parser.y
index 90c771d..e6210d1 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -96,7 +96,8 @@ gameDecls:
96 ; 96 ;
97 97
98globalDecl: 98globalDecl:
99 | tokGlobal '{' globalExprList '}' 99 | tokGlobal '{' { bld.beginGlobal(); } globalExprList '}'
100 { bld.closeGlobal(); }
100 ; 101 ;
101 102
102globalExprList: 103globalExprList:
@@ -134,11 +135,11 @@ function: tokFunction tokIdent { bld.beginFunction( *($2) ); } '(' funcParamList
134 ; 135 ;
135 136
136funcParamList: 137funcParamList:
137 | tokIdent { bld.addParam( *($1) ); } funcParamListEx 138 | tokIdent { bld.addFunctionParam( *($1) ); } funcParamListEx
138 ; 139 ;
139 140
140funcParamListEx: 141funcParamListEx:
141 | funcParamListEx ',' tokIdent { bld.addParam( *($3) ); } 142 | funcParamListEx ',' tokIdent { bld.addFunctionParam( *($3) ); }
142 ; 143 ;
143 144
144cmpltExprList: 145cmpltExprList:
@@ -156,7 +157,8 @@ cmpltExpr: expr ';'
156 bld.closeNode(); 157 bld.closeNode();
157 bld.addNode( AstNode::tScope ); 158 bld.addNode( AstNode::tScope );
158 } tokDo '{' cmpltExprList '}' { 159 } tokDo '{' cmpltExprList '}' {
159 bld.closeNode(); bld.closeNode(); 160 bld.closeNode();
161 bld.closeNode();
160 } 162 }
161 ; 163 ;
162 164
@@ -198,7 +200,7 @@ literal: tokInt { bld.addLiteral( Variable( $1 ) ); }
198 ; 200 ;
199 201
200expr: literal 202expr: literal
201 | tokIdent '(' listValues ')' 203 | tokIdent '(' funcCallParams ')' { bld.addFuncCall( *($1) ); }
202 | varRef 204 | varRef
203 | varRef '=' expr { bld.addNode( AstNode::tStore ); } 205 | varRef '=' expr { bld.addNode( AstNode::tStore ); }
204 | varRef tokPlusAssign expr { bld.addNode( AstNode::tPlusStore ); } 206 | varRef tokPlusAssign expr { bld.addNode( AstNode::tPlusStore ); }
@@ -227,6 +229,14 @@ expr: literal
227 | '-' expr %prec NEG { bld.addNode( AstNode::tNegate ); } 229 | '-' expr %prec NEG { bld.addNode( AstNode::tNegate ); }
228 ; 230 ;
229 231
232funcCallParams:
233 | expr funcCallParamsEx
234 ;
235
236funcCallParamsEx:
237 | funcCallParamsEx ',' expr
238 ;
239
230listValues: expr 240listValues: expr
231 | listValues ',' expr 241 | listValues ',' expr
232 ; 242 ;
@@ -235,12 +245,13 @@ dictValues: expr ':' expr
235 | dictValues ',' expr ':' expr 245 | dictValues ',' expr ':' expr
236 ; 246 ;
237 247
238commandDecl: tokCommand ':' tokString commandParamList '{' cmpltExprList '}' 248commandDecl: tokCommand ':' tokString { bld.beginCommand( *$3 ); }
249 commandParamList '{' cmpltExprList '}' { bld.closeCommand(); }
239 ; 250 ;
240 251
241commandParamList: 252commandParamList:
242 | commandParamList tokString 253 | commandParamList tokString { bld.addCommandLiteral( *$2 ); }
243 | commandParamList tokIdent 254 | commandParamList tokIdent { bld.addCommandParam( *$2 ); }
244 ; 255 ;
245%% 256%%
246/* 257/*