diff options
Diffstat (limited to 'engines/director/lingo/lingo-gr.y')
-rw-r--r-- | engines/director/lingo/lingo-gr.y | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index ea66bc6fd9..f74244e5fd 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -90,7 +90,7 @@ void yyerror(char *s) { %token tCONCAT tCONTAINS tSTARTS %token tSPRITE tINTERSECTS tWITHIN -%type<code> asgn begin elseif elsestmtoneliner end expr if repeatwhile repeatwith stmtlist +%type<code> asgn begin elseif elsestmtoneliner end expr if when repeatwhile repeatwith stmtlist %type<narg> argdef arglist %right '=' @@ -217,8 +217,11 @@ stmt: stmtoneliner (*g_lingo->_currentScript)[$1 + 3] = body; /* body of loop */ (*g_lingo->_currentScript)[$1 + 4] = inc; /* increment */ (*g_lingo->_currentScript)[$1 + 5] = end; } /* end, if cond fails */ - | tWHEN ID tTHEN expr { - g_lingo->code1(g_lingo->c_ifcode); + | when expr end { + inst end = 0; + WRITE_UINT32(&end, $3); + g_lingo->code1(STOP); + (*g_lingo->_currentScript)[$1 + 1] = end; } ; @@ -341,6 +344,12 @@ stmtlist: /* nothing */ { $$ = g_lingo->_currentScript->size(); } | stmtlist stmt ; +when: tWHEN ID tTHEN { + $$ = g_lingo->code1(g_lingo->c_whencode); + g_lingo->code1(STOP); + g_lingo->codeString($2->c_str()); + delete $2; } + expr: INT { $$ = g_lingo->codeConst($1); } | FLOAT { $$ = g_lingo->code1(g_lingo->c_fconstpush); @@ -498,7 +507,7 @@ defn: tMACRO ID { g_lingo->_indef = true; g_lingo->_currentFactory.clear(); } } | tMETHOD ID { g_lingo->_indef = true; } begin argdef nl argstore stmtlist { - g_lingo->code1(STOP); + g_lingo->code1(g_lingo->c_procret); g_lingo->define(*$2, $4, $5 + 1, &g_lingo->_currentFactory); g_lingo->_indef = false; } ; argdef: /* nothing */ { $$ = 0; } |