45 |
|
|
46 |
%type <nEventHandlers> script eventhandlers |
%type <nEventHandlers> script eventhandlers |
47 |
%type <nEventHandler> eventhandler |
%type <nEventHandler> eventhandler |
48 |
%type <nStatements> statements body |
%type <nStatements> statements opt_statements |
49 |
%type <nStatement> statement assignment |
%type <nStatement> statement assignment |
50 |
%type <nFunctionCall> functioncall |
%type <nFunctionCall> functioncall |
51 |
%type <nArgs> args |
%type <nArgs> args |
73 |
} |
} |
74 |
|
|
75 |
eventhandler: |
eventhandler: |
76 |
ON NOTE body END ON { |
ON NOTE opt_statements END ON { |
77 |
if (context->onNote) |
if (context->onNote) |
78 |
PARSE_ERR(@2, "Redeclaration of 'note' event handler."); |
PARSE_ERR(@2, "Redeclaration of 'note' event handler."); |
79 |
context->onNote = new OnNote($3); |
context->onNote = new OnNote($3); |
80 |
$$ = context->onNote; |
$$ = context->onNote; |
81 |
} |
} |
82 |
| ON INIT body END ON { |
| ON INIT opt_statements END ON { |
83 |
if (context->onInit) |
if (context->onInit) |
84 |
PARSE_ERR(@2, "Redeclaration of 'init' event handler."); |
PARSE_ERR(@2, "Redeclaration of 'init' event handler."); |
85 |
context->onInit = new OnInit($3); |
context->onInit = new OnInit($3); |
86 |
$$ = context->onInit; |
$$ = context->onInit; |
87 |
} |
} |
88 |
| ON RELEASE body END ON { |
| ON RELEASE opt_statements END ON { |
89 |
if (context->onRelease) |
if (context->onRelease) |
90 |
PARSE_ERR(@2, "Redeclaration of 'release' event handler."); |
PARSE_ERR(@2, "Redeclaration of 'release' event handler."); |
91 |
context->onRelease = new OnRelease($3); |
context->onRelease = new OnRelease($3); |
92 |
$$ = context->onRelease; |
$$ = context->onRelease; |
93 |
} |
} |
94 |
| ON CONTROLLER body END ON { |
| ON CONTROLLER opt_statements END ON { |
95 |
if (context->onController) |
if (context->onController) |
96 |
PARSE_ERR(@2, "Redeclaration of 'controller' event handler."); |
PARSE_ERR(@2, "Redeclaration of 'controller' event handler."); |
97 |
context->onController = new OnController($3); |
context->onController = new OnController($3); |
98 |
$$ = context->onController; |
$$ = context->onController; |
99 |
} |
} |
100 |
|
|
101 |
body: |
opt_statements: |
102 |
/* epsilon (empty argument) */ { |
/* epsilon (empty argument) */ { |
103 |
$$ = new Statements(); |
$$ = new Statements(); |
104 |
} |
} |
289 |
| assignment { |
| assignment { |
290 |
$$ = $1; |
$$ = $1; |
291 |
} |
} |
292 |
| WHILE '(' expr ')' statements END WHILE { |
| WHILE '(' expr ')' opt_statements END WHILE { |
293 |
if ($3->exprType() == INT_EXPR) { |
if ($3->exprType() == INT_EXPR) { |
294 |
$$ = new While($3, $5); |
$$ = new While($3, $5); |
295 |
} else { |
} else { |
297 |
$$ = new While(new IntLiteral(0), $5); |
$$ = new While(new IntLiteral(0), $5); |
298 |
} |
} |
299 |
} |
} |
300 |
| IF '(' expr ')' statements ELSE statements END IF { |
| IF '(' expr ')' opt_statements ELSE opt_statements END IF { |
301 |
$$ = new If($3, $5, $7); |
$$ = new If($3, $5, $7); |
302 |
} |
} |
303 |
| IF '(' expr ')' statements END IF { |
| IF '(' expr ')' opt_statements END IF { |
304 |
$$ = new If($3, $5); |
$$ = new If($3, $5); |
305 |
} |
} |
306 |
| SELECT expr caseclauses END SELECT { |
| SELECT expr caseclauses END SELECT { |
323 |
} |
} |
324 |
|
|
325 |
caseclause: |
caseclause: |
326 |
CASE INTEGER statements { |
CASE INTEGER opt_statements { |
327 |
$$ = CaseBranch(); |
$$ = CaseBranch(); |
328 |
$$.from = new IntLiteral($2); |
$$.from = new IntLiteral($2); |
329 |
$$.statements = $3; |
$$.statements = $3; |
330 |
} |
} |
331 |
| CASE INTEGER TO INTEGER statements { |
| CASE INTEGER TO INTEGER opt_statements { |
332 |
$$ = CaseBranch(); |
$$ = CaseBranch(); |
333 |
$$.from = new IntLiteral($2); |
$$.from = new IntLiteral($2); |
334 |
$$.to = new IntLiteral($4); |
$$.to = new IntLiteral($4); |