mirror of
https://github.com/scummvm/scummvm.git
synced 2026-11-18 21:34:48 +00:00
DIRECTOR: LINGO: Rewrite 'if' statement fully. Improve line counting
Still one particular testcase fails, but this is a major improvement in terms of clarity. The execution is temporarily broken.
This commit is contained in:
1 parent
9606b75482
commit
2432018f2f
6 files changed
+2711
-2439
No files matched your search
+2019
-1876
File diff suppressed because it is too large.
Load diff
+207
-129
@@ -1,14 +1,14 @@
|
||||
/* A Bison parser, made by GNU Bison 3.4. */
|
||||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
|
||||
Inc.
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -16,7 +16,9 @@
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
@@ -31,123 +33,203 @@
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* Undocumented macros, especially those whose name start with YY_,
|
||||
are private implementation details. Do not rely on them. */
|
||||
|
||||
#ifndef YY_YY_ENGINES_DIRECTOR_LINGO_LINGO_GR_HPP_INCLUDED
|
||||
# define YY_YY_ENGINES_DIRECTOR_LINGO_LINGO_GR_HPP_INCLUDED
|
||||
/* Debug traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 1
|
||||
#endif
|
||||
#if YYDEBUG
|
||||
extern int yydebug;
|
||||
#endif
|
||||
|
||||
/* Token type. */
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
enum yytokentype
|
||||
{
|
||||
UNARY = 258,
|
||||
CASTREF = 259,
|
||||
VOID = 260,
|
||||
VAR = 261,
|
||||
POINT = 262,
|
||||
RECT = 263,
|
||||
ARRAY = 264,
|
||||
OBJECT = 265,
|
||||
REFERENCE = 266,
|
||||
INT = 267,
|
||||
ARGC = 268,
|
||||
ARGCNORET = 269,
|
||||
THEENTITY = 270,
|
||||
THEENTITYWITHID = 271,
|
||||
FLOAT = 272,
|
||||
BLTIN = 273,
|
||||
BLTINNOARGS = 274,
|
||||
BLTINNOARGSORONE = 275,
|
||||
BLTINONEARG = 276,
|
||||
BLTINARGLIST = 277,
|
||||
TWOWORDBUILTIN = 278,
|
||||
FBLTIN = 279,
|
||||
FBLTINNOARGS = 280,
|
||||
FBLTINONEARG = 281,
|
||||
FBLTINARGLIST = 282,
|
||||
RBLTIN = 283,
|
||||
RBLTINONEARG = 284,
|
||||
ID = 285,
|
||||
STRING = 286,
|
||||
HANDLER = 287,
|
||||
SYMBOL = 288,
|
||||
ENDCLAUSE = 289,
|
||||
tPLAYACCEL = 290,
|
||||
tDOWN = 291,
|
||||
tELSE = 292,
|
||||
tNLELSIF = 293,
|
||||
tEXIT = 294,
|
||||
tFRAME = 295,
|
||||
tGLOBAL = 296,
|
||||
tGO = 297,
|
||||
tIF = 298,
|
||||
tINTO = 299,
|
||||
tLOOP = 300,
|
||||
tMACRO = 301,
|
||||
tMOVIE = 302,
|
||||
tNEXT = 303,
|
||||
tOF = 304,
|
||||
tPREVIOUS = 305,
|
||||
tPUT = 306,
|
||||
tREPEAT = 307,
|
||||
tSET = 308,
|
||||
tTHEN = 309,
|
||||
tTHENNL = 310,
|
||||
tTO = 311,
|
||||
tWHEN = 312,
|
||||
tWITH = 313,
|
||||
tWHILE = 314,
|
||||
tNLELSE = 315,
|
||||
tFACTORY = 316,
|
||||
tMETHOD = 317,
|
||||
tOPEN = 318,
|
||||
tPLAY = 319,
|
||||
tDONE = 320,
|
||||
tINSTANCE = 321,
|
||||
tGE = 322,
|
||||
tLE = 323,
|
||||
tGT = 324,
|
||||
tLT = 325,
|
||||
tEQ = 326,
|
||||
tNEQ = 327,
|
||||
tAND = 328,
|
||||
tOR = 329,
|
||||
tNOT = 330,
|
||||
tMOD = 331,
|
||||
tAFTER = 332,
|
||||
tBEFORE = 333,
|
||||
tCONCAT = 334,
|
||||
tCONTAINS = 335,
|
||||
tSTARTS = 336,
|
||||
tCHAR = 337,
|
||||
tITEM = 338,
|
||||
tLINE = 339,
|
||||
tWORD = 340,
|
||||
tSPRITE = 341,
|
||||
tINTERSECTS = 342,
|
||||
tWITHIN = 343,
|
||||
tTELL = 344,
|
||||
tPROPERTY = 345,
|
||||
tON = 346,
|
||||
tME = 347
|
||||
};
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
UNARY = 258,
|
||||
CASTREF = 259,
|
||||
VOID = 260,
|
||||
VAR = 261,
|
||||
POINT = 262,
|
||||
RECT = 263,
|
||||
ARRAY = 264,
|
||||
OBJECT = 265,
|
||||
REFERENCE = 266,
|
||||
INT = 267,
|
||||
ARGC = 268,
|
||||
ARGCNORET = 269,
|
||||
THEENTITY = 270,
|
||||
THEENTITYWITHID = 271,
|
||||
FLOAT = 272,
|
||||
BLTIN = 273,
|
||||
BLTINNOARGS = 274,
|
||||
BLTINNOARGSORONE = 275,
|
||||
BLTINONEARG = 276,
|
||||
BLTINARGLIST = 277,
|
||||
TWOWORDBUILTIN = 278,
|
||||
FBLTIN = 279,
|
||||
FBLTINNOARGS = 280,
|
||||
FBLTINONEARG = 281,
|
||||
FBLTINARGLIST = 282,
|
||||
RBLTIN = 283,
|
||||
RBLTINONEARG = 284,
|
||||
ID = 285,
|
||||
STRING = 286,
|
||||
HANDLER = 287,
|
||||
SYMBOL = 288,
|
||||
ENDCLAUSE = 289,
|
||||
tPLAYACCEL = 290,
|
||||
tDOWN = 291,
|
||||
tELSE = 292,
|
||||
tNLELSIF = 293,
|
||||
tEXIT = 294,
|
||||
tFRAME = 295,
|
||||
tGLOBAL = 296,
|
||||
tGO = 297,
|
||||
tIF = 298,
|
||||
tINTO = 299,
|
||||
tLOOP = 300,
|
||||
tMACRO = 301,
|
||||
tMOVIE = 302,
|
||||
tNEXT = 303,
|
||||
tOF = 304,
|
||||
tPREVIOUS = 305,
|
||||
tPUT = 306,
|
||||
tREPEAT = 307,
|
||||
tSET = 308,
|
||||
tTHEN = 309,
|
||||
tTHENNL = 310,
|
||||
tTO = 311,
|
||||
tWHEN = 312,
|
||||
tWITH = 313,
|
||||
tWHILE = 314,
|
||||
tNLELSE = 315,
|
||||
tFACTORY = 316,
|
||||
tMETHOD = 317,
|
||||
tOPEN = 318,
|
||||
tPLAY = 319,
|
||||
tDONE = 320,
|
||||
tINSTANCE = 321,
|
||||
tGE = 322,
|
||||
tLE = 323,
|
||||
tGT = 324,
|
||||
tLT = 325,
|
||||
tEQ = 326,
|
||||
tNEQ = 327,
|
||||
tAND = 328,
|
||||
tOR = 329,
|
||||
tNOT = 330,
|
||||
tMOD = 331,
|
||||
tAFTER = 332,
|
||||
tBEFORE = 333,
|
||||
tCONCAT = 334,
|
||||
tCONTAINS = 335,
|
||||
tSTARTS = 336,
|
||||
tCHAR = 337,
|
||||
tITEM = 338,
|
||||
tLINE = 339,
|
||||
tWORD = 340,
|
||||
tSPRITE = 341,
|
||||
tINTERSECTS = 342,
|
||||
tWITHIN = 343,
|
||||
tTELL = 344,
|
||||
tPROPERTY = 345,
|
||||
tON = 346,
|
||||
tME = 347
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
#define UNARY 258
|
||||
#define CASTREF 259
|
||||
#define VOID 260
|
||||
#define VAR 261
|
||||
#define POINT 262
|
||||
#define RECT 263
|
||||
#define ARRAY 264
|
||||
#define OBJECT 265
|
||||
#define REFERENCE 266
|
||||
#define INT 267
|
||||
#define ARGC 268
|
||||
#define ARGCNORET 269
|
||||
#define THEENTITY 270
|
||||
#define THEENTITYWITHID 271
|
||||
#define FLOAT 272
|
||||
#define BLTIN 273
|
||||
#define BLTINNOARGS 274
|
||||
#define BLTINNOARGSORONE 275
|
||||
#define BLTINONEARG 276
|
||||
#define BLTINARGLIST 277
|
||||
#define TWOWORDBUILTIN 278
|
||||
#define FBLTIN 279
|
||||
#define FBLTINNOARGS 280
|
||||
#define FBLTINONEARG 281
|
||||
#define FBLTINARGLIST 282
|
||||
#define RBLTIN 283
|
||||
#define RBLTINONEARG 284
|
||||
#define ID 285
|
||||
#define STRING 286
|
||||
#define HANDLER 287
|
||||
#define SYMBOL 288
|
||||
#define ENDCLAUSE 289
|
||||
#define tPLAYACCEL 290
|
||||
#define tDOWN 291
|
||||
#define tELSE 292
|
||||
#define tNLELSIF 293
|
||||
#define tEXIT 294
|
||||
#define tFRAME 295
|
||||
#define tGLOBAL 296
|
||||
#define tGO 297
|
||||
#define tIF 298
|
||||
#define tINTO 299
|
||||
#define tLOOP 300
|
||||
#define tMACRO 301
|
||||
#define tMOVIE 302
|
||||
#define tNEXT 303
|
||||
#define tOF 304
|
||||
#define tPREVIOUS 305
|
||||
#define tPUT 306
|
||||
#define tREPEAT 307
|
||||
#define tSET 308
|
||||
#define tTHEN 309
|
||||
#define tTHENNL 310
|
||||
#define tTO 311
|
||||
#define tWHEN 312
|
||||
#define tWITH 313
|
||||
#define tWHILE 314
|
||||
#define tNLELSE 315
|
||||
#define tFACTORY 316
|
||||
#define tMETHOD 317
|
||||
#define tOPEN 318
|
||||
#define tPLAY 319
|
||||
#define tDONE 320
|
||||
#define tINSTANCE 321
|
||||
#define tGE 322
|
||||
#define tLE 323
|
||||
#define tGT 324
|
||||
#define tLT 325
|
||||
#define tEQ 326
|
||||
#define tNEQ 327
|
||||
#define tAND 328
|
||||
#define tOR 329
|
||||
#define tNOT 330
|
||||
#define tMOD 331
|
||||
#define tAFTER 332
|
||||
#define tBEFORE 333
|
||||
#define tCONCAT 334
|
||||
#define tCONTAINS 335
|
||||
#define tSTARTS 336
|
||||
#define tCHAR 337
|
||||
#define tITEM 338
|
||||
#define tLINE 339
|
||||
#define tWORD 340
|
||||
#define tSPRITE 341
|
||||
#define tINTERSECTS 342
|
||||
#define tWITHIN 343
|
||||
#define tTELL 344
|
||||
#define tPROPERTY 345
|
||||
#define tON 346
|
||||
#define tME 347
|
||||
|
||||
|
||||
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
union YYSTYPE
|
||||
{
|
||||
typedef union YYSTYPE
|
||||
#line 79 "engines/director/lingo/lingo-gr.y"
|
||||
|
||||
{
|
||||
Common::String *s;
|
||||
int i;
|
||||
double f;
|
||||
@@ -155,18 +237,14 @@ union YYSTYPE
|
||||
int code;
|
||||
int narg; /* number of arguments */
|
||||
Common::Array<double> *arr;
|
||||
|
||||
#line 160 "engines/director/lingo/lingo-gr.hpp"
|
||||
|
||||
};
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
}
|
||||
/* Line 1529 of yacc.c. */
|
||||
#line 243 "engines/director/lingo/lingo-gr.hpp"
|
||||
YYSTYPE;
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
#endif /* !YY_YY_ENGINES_DIRECTOR_LINGO_LINGO_GR_HPP_INCLUDED */
|
||||
+116
-113
@@ -103,7 +103,7 @@ void checkEnd(Common::String *token, const char *expect, bool required) {
|
||||
%token tSPRITE tINTERSECTS tWITHIN tTELL tPROPERTY
|
||||
%token tON tME
|
||||
|
||||
%type<code> asgn begin elseif elsestmtoneliner end expr if when repeatwhile
|
||||
%type<code> asgn begin elseif end expr if when repeatwhile
|
||||
%type<code> repeatwith stmtlist tell reference simpleexpr
|
||||
%type<narg> argdef arglist nonemptyarglist
|
||||
%type<s> on
|
||||
@@ -117,29 +117,9 @@ void checkEnd(Common::String *token, const char *expect, bool required) {
|
||||
|
||||
%%
|
||||
|
||||
program: program nl programline
|
||||
program: program '\n' programline
|
||||
| programline
|
||||
| error nl { yyerrok; }
|
||||
;
|
||||
|
||||
nl: '\n' {
|
||||
g_lingo->_linenumber++;
|
||||
g_lingo->_colnumber = 1; }
|
||||
;
|
||||
|
||||
thennl: tTHENNL {
|
||||
g_lingo->_linenumber++;
|
||||
g_lingo->_colnumber = 1; }
|
||||
;
|
||||
|
||||
nlelse: tNLELSE {
|
||||
g_lingo->_linenumber++;
|
||||
g_lingo->_colnumber = 5; }
|
||||
;
|
||||
|
||||
nlelsif: tNLELSIF {
|
||||
g_lingo->_linenumber++;
|
||||
g_lingo->_colnumber = 8; }
|
||||
| error '\n' { yyerrok; }
|
||||
;
|
||||
|
||||
programline: /* empty */
|
||||
@@ -259,7 +239,7 @@ stmt: stmtoneliner
|
||||
WRITE_UINT32(&end, $3 - $1);
|
||||
g_lingo->code1(STOP);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = end; }
|
||||
| tell expr nl stmtlist end ENDCLAUSE {
|
||||
| tell expr '\n' stmtlist end ENDCLAUSE {
|
||||
warning("STUB: TELL is not implemented");
|
||||
checkEnd($6, "tell", true); }
|
||||
| tell expr tTO expr {
|
||||
@@ -267,88 +247,8 @@ stmt: stmtoneliner
|
||||
}
|
||||
;
|
||||
|
||||
ifstmt: if expr thennl stmtlist end ENDCLAUSE {
|
||||
inst then = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&end, $5 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
checkEnd($6, "if", true);
|
||||
|
||||
g_lingo->processIf(0, 0); }
|
||||
| if expr thennl stmtlist end nlelse stmtlist end ENDCLAUSE {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $7 - $1);
|
||||
WRITE_UINT32(&end, $8 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
checkEnd($9, "if", true);
|
||||
|
||||
g_lingo->processIf(0, 0); }
|
||||
| if expr thennl stmtlist end begin elseifstmt end ENDCLAUSE {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $6 - $1);
|
||||
WRITE_UINT32(&end, $8 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
checkEnd($9, "if", true);
|
||||
|
||||
g_lingo->processIf(0, $8 - $1); }
|
||||
| if expr thennl stmtlist end nlelse begin stmtoneliner end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $7 - $1);
|
||||
WRITE_UINT32(&end, $9 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, $9 - $1); }
|
||||
| if expr tTHEN begin stmtoneliner end elseifstmtoneliner end elsestmtoneliner end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $6 - $1);
|
||||
WRITE_UINT32(&end, $10 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, $10 - $1); }
|
||||
| if expr tTHEN begin stmtoneliner end nlelse begin stmtoneliner end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $8 - $1);
|
||||
WRITE_UINT32(&end, $10 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, 0); }
|
||||
| if expr tTHEN begin stmtoneliner end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, 0);
|
||||
WRITE_UINT32(&end, $6 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, 0); }
|
||||
;
|
||||
|
||||
elsestmtoneliner: /* nothing */ { $$ = 0; }
|
||||
| nlelse begin stmtoneliner { $$ = $2; }
|
||||
;
|
||||
|
||||
elseifstmt: elseifstmt elseifstmt1
|
||||
| elseifstmt1
|
||||
| elseifstmt1
|
||||
;
|
||||
|
||||
elseifstmtoneliner: elseifstmtoneliner elseifstmtoneliner1
|
||||
@@ -370,7 +270,7 @@ elseifstmt1: elseifstmtoneliner
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
|
||||
g_lingo->codeLabel($1); }
|
||||
| elseif expr thennl begin stmtlist end {
|
||||
| elseif expr tTHENNL begin stmtlist end {
|
||||
inst then = 0;
|
||||
WRITE_UINT32(&then, $5 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
@@ -378,6 +278,109 @@ elseifstmt1: elseifstmtoneliner
|
||||
g_lingo->codeLabel($1); }
|
||||
;
|
||||
|
||||
ifstmt: if expr tTHENNL stmtlist end ENDCLAUSE {
|
||||
inst then = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&end, $5 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
checkEnd($6, "if", true);
|
||||
|
||||
g_lingo->processIf(0, 0); }
|
||||
| if expr tTHEN begin stmtoneliner end tELSE stmtoneliner end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $6 - $1);
|
||||
WRITE_UINT32(&end, $9 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, $9 - $1); }
|
||||
|
||||
| if expr tTHEN begin stmtoneliner end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, 0);
|
||||
WRITE_UINT32(&end, $6 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, 0); }
|
||||
| if expr tTHEN begin stmtoneliner end elseifstmt end endifstmt end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $6 - $1);
|
||||
WRITE_UINT32(&end, $10 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, $10 - $1); }
|
||||
| if expr tTHENNL stmtlist end elseifstmt end endifstmt end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $7 - $1);
|
||||
WRITE_UINT32(&end, $9 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, 0); }
|
||||
| if expr tTHEN begin stmtoneliner end endifstmt end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $6 - $1);
|
||||
WRITE_UINT32(&end, $8 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, $8 - $1); }
|
||||
| if expr tTHENNL stmtlist end endifstmt end {
|
||||
inst then = 0, else1 = 0, end = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
WRITE_UINT32(&else1, $7 - $1);
|
||||
WRITE_UINT32(&end, $7 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
|
||||
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
|
||||
|
||||
g_lingo->processIf(0, 0); }
|
||||
|
||||
;
|
||||
|
||||
|
||||
endifstmt: elseif expr tTHEN begin stmtoneliner end tELSE stmtoneliner end {
|
||||
inst then = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
|
||||
g_lingo->codeLabel($1); }
|
||||
| elseif expr tTHEN begin stmtoneliner end {
|
||||
inst then = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
|
||||
g_lingo->codeLabel($1); }
|
||||
| elseif expr tTHENNL begin stmtlist end ENDCLAUSE {
|
||||
inst then = 0;
|
||||
WRITE_UINT32(&then, $4 - $1);
|
||||
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
|
||||
|
||||
g_lingo->codeLabel($1);
|
||||
|
||||
checkEnd($7, "if", true); }
|
||||
| tNLELSE begin stmtlist end ENDCLAUSE {
|
||||
g_lingo->codeLabel($2);
|
||||
|
||||
checkEnd($5, "if", true); }
|
||||
| tNLELSE begin stmtoneliner end {
|
||||
g_lingo->codeLabel($2); }
|
||||
;
|
||||
|
||||
repeatwhile: tREPEAT tWHILE { $$ = g_lingo->code3(g_lingo->c_repeatwhilecode, STOP, STOP); }
|
||||
;
|
||||
|
||||
@@ -395,7 +398,7 @@ if: tIF {
|
||||
g_lingo->codeLabel(0); } // Mark beginning of the if() statement
|
||||
;
|
||||
|
||||
elseif: nlelsif {
|
||||
elseif: tNLELSIF {
|
||||
inst skipEnd;
|
||||
WRITE_UINT32(&skipEnd, 1); // We have to skip end to avoid multiple executions
|
||||
$$ = g_lingo->code1(g_lingo->c_ifcode);
|
||||
@@ -410,7 +413,7 @@ end: /* nothing */ { g_lingo->code1(STOP); $$ = g_lingo->_currentScript->size
|
||||
;
|
||||
|
||||
stmtlist: begin { $$ = g_lingo->_currentScript->size(); }
|
||||
| stmtlist nl
|
||||
| stmtlist '\n'
|
||||
| stmtlist stmt
|
||||
;
|
||||
|
||||
@@ -629,24 +632,24 @@ playfunc: tPLAY tDONE { g_lingo->code1(g_lingo->c_playdone); }
|
||||
// See also:
|
||||
// on keyword
|
||||
defn: tMACRO ID { g_lingo->_indef = true; g_lingo->_currentFactory.clear(); }
|
||||
begin argdef nl argstore stmtlist {
|
||||
begin argdef '\n' argstore stmtlist {
|
||||
g_lingo->code1(g_lingo->c_procret);
|
||||
g_lingo->define(*$2, $4, $5);
|
||||
g_lingo->_indef = false; }
|
||||
| tFACTORY ID { g_lingo->codeFactory(*$2); }
|
||||
| tMETHOD ID { g_lingo->_indef = true; }
|
||||
begin argdef nl argstore stmtlist {
|
||||
begin argdef '\n' argstore stmtlist {
|
||||
g_lingo->code1(g_lingo->c_procret);
|
||||
g_lingo->define(*$2, $4, $5 + 1, &g_lingo->_currentFactory);
|
||||
g_lingo->_indef = false; }
|
||||
| on begin argdef nl argstore stmtlist ENDCLAUSE endargdef { // D3
|
||||
| on begin argdef '\n' argstore stmtlist ENDCLAUSE endargdef { // D3
|
||||
g_lingo->code1(g_lingo->c_procret);
|
||||
g_lingo->define(*$1, $2, $3);
|
||||
g_lingo->_indef = false;
|
||||
g_lingo->_ignoreMe = false;
|
||||
|
||||
checkEnd($7, $1->c_str(), false); }
|
||||
| on begin argdef nl argstore stmtlist { // D4. No 'end' clause
|
||||
| on begin argdef '\n' argstore stmtlist { // D4. No 'end' clause
|
||||
g_lingo->code1(g_lingo->c_procret);
|
||||
g_lingo->define(*$1, $2, $3);
|
||||
g_lingo->_indef = false;
|
||||
@@ -657,7 +660,7 @@ on: tON ID { $$ = $2; g_lingo->_indef = true; g_lingo->_currentFactory.clear();
|
||||
argdef: /* nothing */ { $$ = 0; }
|
||||
| ID { g_lingo->codeArg($1); $$ = 1; }
|
||||
| argdef ',' ID { g_lingo->codeArg($3); $$ = $1 + 1; }
|
||||
| argdef nl ',' ID { g_lingo->codeArg($4); $$ = $1 + 1; }
|
||||
| argdef '\n' ',' ID { g_lingo->codeArg($4); $$ = $1 + 1; }
|
||||
;
|
||||
|
||||
endargdef: /* nothing */
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -38,20 +38,27 @@
|
||||
using namespace Director;
|
||||
|
||||
int yyparse();
|
||||
|
||||
static void count() {
|
||||
if (debugChannelSet(-1, kDebugLingoParse))
|
||||
debug("LEXER: Read '%s' at %d:%d", yytext, g_lingo->_linenumber, g_lingo->_colnumber);
|
||||
|
||||
g_lingo->_colnumber += strlen(yytext);
|
||||
}
|
||||
|
||||
static void countnl() {
|
||||
char *p = yytext;
|
||||
|
||||
while(*p == '\n' || *p == '\r')
|
||||
while (*p && *p != '\n' && *p != '\r') {
|
||||
p++;
|
||||
g_lingo->_colnumber++;
|
||||
}
|
||||
|
||||
while (*p == '\n' || *p == '\r') {
|
||||
if (*p == '\n') {
|
||||
g_lingo->_linenumber++;
|
||||
g_lingo->_colnumber = 0;
|
||||
}
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
g_lingo->_linenumber++;
|
||||
g_lingo->_colnumber = strlen(p);
|
||||
}
|
||||
|
||||
@@ -77,7 +84,7 @@ whitespace [\t ]
|
||||
|
||||
%%
|
||||
|
||||
{whitespace}*\xC2[\r\n] { g_lingo->_linenumber++; g_lingo->_colnumber = 0; }
|
||||
{whitespace}*\xC2[\r\n] { count(); }
|
||||
--[^\r\n]*
|
||||
^{whitespace}+ { count(); }
|
||||
[\t]+ { count(); return ' '; }
|
||||
@@ -92,8 +99,8 @@ whitespace [\t ]
|
||||
(?i:done) { count(); return tDONE; }
|
||||
(?i:down) { count(); return tDOWN; }
|
||||
(?i:if) { count(); return tIF; }
|
||||
(?i:[\n\r]+[\t ]*else[\t ]+if) { countnl(); return tNLELSIF; }
|
||||
(?i:[\n\r]+[\t ]*else) { countnl(); return tNLELSE; }
|
||||
(?i:[\n\r]+[\t ]*else[\t ]+if) { count(); return tNLELSIF; }
|
||||
(?i:[\n\r]+[\t ]*else) { count(); return tNLELSE; }
|
||||
(?i:else) { count(); return tELSE; }
|
||||
(?i:end)([\t ]*{identifier})? {
|
||||
count();
|
||||
@@ -314,7 +321,7 @@ whitespace [\t ]
|
||||
{constfloat} { count(); yylval.f = atof(yytext); return FLOAT; }
|
||||
{constinteger} { count(); yylval.i = strtol(yytext, NULL, 10); return INT; }
|
||||
{operator} { count(); return *yytext; }
|
||||
{newline} { return '\n'; }
|
||||
{newline} { count(); return '\n'; }
|
||||
{conststring} { count(); yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; }
|
||||
. { count(); }
|
||||
|
||||
|
||||
@@ -50,6 +50,52 @@ else
|
||||
put FALSE
|
||||
end if
|
||||
|
||||
if the selection = the text of cast A31 then
|
||||
go to frame "sEnd"
|
||||
exit
|
||||
else if whichTry = 1 then go to frame "sTell"
|
||||
else if whichTry = 2 then go to frame "sShow"
|
||||
else if whichTry = 3 then go to frame "sDo"
|
||||
|
||||
if the selection = the text of cast A31 then
|
||||
go to frame "sEnd"
|
||||
exit
|
||||
else if whichTry = 1 then
|
||||
go to frame "sTell"
|
||||
else if whichTry = 2 then
|
||||
put 5
|
||||
go to frame "sShow"
|
||||
else if whichTry = 3 then go to frame "sDo"
|
||||
else put 6
|
||||
|
||||
if the selection = the text of cast A31 then go to frame "sEnd" else put 7
|
||||
|
||||
if the selection = the text of cast A31 then go to frame "sEnd"
|
||||
else if whichTry = 1 then
|
||||
go to frame "sTell"
|
||||
else if whichTry = 2 then
|
||||
put 5
|
||||
go to frame "sShow"
|
||||
else if whichTry = 3 then go to frame "sDo"
|
||||
else
|
||||
put 6
|
||||
put 7
|
||||
end if
|
||||
|
||||
if the selection = the text of cast A31 then go to frame "sEnd"
|
||||
else if whichTry = 1 then
|
||||
go to frame "sTell"
|
||||
else if whichTry = 2 then
|
||||
put 5
|
||||
go to frame "sShow"
|
||||
else if whichTry = 3 then go to frame "sDo"
|
||||
|
||||
if rollOver(2) then
|
||||
put "The cursor is INSIDE the square." into field "Cursor Status"
|
||||
else
|
||||
put "The cursor is OUTSIDE the square." into field "Cursor Status"
|
||||
end if
|
||||
|
||||
macro WindowHorzP X
|
||||
set X1 = constrainH( 14, X )
|
||||
if X1 = X then return( TRUE )
|
||||
|
||||
Reference in new issue
Block a user