aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorEugene Sandulenko2016-06-21 19:34:45 +0200
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit0f3295c98f1bf846e0e7183d4fbafb1a767de75f (patch)
tree9777d95bfdf5e69bd8fce143179dccda24524446 /engines/director
parentad9e2fd0e5aa02f5d2ff08034a40f220c604c3cf (diff)
downloadscummvm-rg350-0f3295c98f1bf846e0e7183d4fbafb1a767de75f.tar.gz
scummvm-rg350-0f3295c98f1bf846e0e7183d4fbafb1a767de75f.tar.bz2
scummvm-rg350-0f3295c98f1bf846e0e7183d4fbafb1a767de75f.zip
DIRECTOR: Lingo: Initial code for 'repeat with' control keyword
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/lingo/lingo-code.cpp28
-rw-r--r--engines/director/lingo/lingo-gr.cpp564
-rw-r--r--engines/director/lingo/lingo-gr.h90
-rw-r--r--engines/director/lingo/lingo-gr.y44
-rw-r--r--engines/director/lingo/lingo-lex.cpp237
-rw-r--r--engines/director/lingo/lingo-lex.l2
-rw-r--r--engines/director/lingo/lingo.h3
7 files changed, 534 insertions, 434 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 85da696a40..e0ec7e8471 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -247,7 +247,7 @@ void Lingo::c_le() {
g_lingo->push(d1);
}
-void Lingo::c_whilecode(void) {
+void Lingo::c_repeatwhilecode(void) {
Datum d;
int savepc = g_lingo->_pc;
@@ -270,6 +270,32 @@ void Lingo::c_whilecode(void) {
g_lingo->_pc = end; /* next stmt */
}
+void Lingo::c_repeatwithcode(void) {
+ Datum d;
+ int savepc = g_lingo->_pc;
+
+ int init = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc]);
+ int finish = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 2]);
+ int body = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 3]);
+ int end = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 4]);
+ Common::String counter((char *)&(*g_lingo->_currentScript)[savepc + 5]);
+
+ g_lingo->execute(init); /* condition */
+ d = g_lingo->pop();
+
+ while (d.val) {
+ g_lingo->execute(body); /* body */
+ if (0 /* returning */)
+ break;
+
+ g_lingo->execute(finish); /* condition */
+ d = g_lingo->pop();
+ }
+
+ //if (!returning)
+ g_lingo->_pc = end; /* next stmt */
+}
+
void Lingo::c_ifcode() {
Datum d;
int savepc = g_lingo->_pc; /* then part */
diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp
index 7b0932bfe6..d6f01b6539 100644
--- a/engines/director/lingo/lingo-gr.cpp
+++ b/engines/director/lingo/lingo-gr.cpp
@@ -72,31 +72,33 @@
FLOAT = 261,
VAR = 262,
STRING = 263,
- tIF = 264,
+ tDOWN = 264,
tELSE = 265,
tEND = 266,
tFRAME = 267,
tGO = 268,
- tINTO = 269,
- tLOOP = 270,
- tMCI = 271,
- tMCIWAIT = 272,
- tMOVIE = 273,
- tNEXT = 274,
- tOF = 275,
- tPREVIOUS = 276,
- tPUT = 277,
- tREPEAT = 278,
- tSET = 279,
- tTHEN = 280,
- tTO = 281,
- tWHILE = 282,
- tGE = 283,
- tLE = 284,
- tGT = 285,
- tLT = 286,
- tEQ = 287,
- tNEQ = 288
+ tIF = 269,
+ tINTO = 270,
+ tLOOP = 271,
+ tMCI = 272,
+ tMCIWAIT = 273,
+ tMOVIE = 274,
+ tNEXT = 275,
+ tOF = 276,
+ tPREVIOUS = 277,
+ tPUT = 278,
+ tREPEAT = 279,
+ tSET = 280,
+ tTHEN = 281,
+ tTO = 282,
+ tWITH = 283,
+ tWHILE = 284,
+ tGE = 285,
+ tLE = 286,
+ tGT = 287,
+ tLT = 288,
+ tEQ = 289,
+ tNEQ = 290
};
#endif
/* Tokens. */
@@ -106,31 +108,33 @@
#define FLOAT 261
#define VAR 262
#define STRING 263
-#define tIF 264
+#define tDOWN 264
#define tELSE 265
#define tEND 266
#define tFRAME 267
#define tGO 268
-#define tINTO 269
-#define tLOOP 270
-#define tMCI 271
-#define tMCIWAIT 272
-#define tMOVIE 273
-#define tNEXT 274
-#define tOF 275
-#define tPREVIOUS 276
-#define tPUT 277
-#define tREPEAT 278
-#define tSET 279
-#define tTHEN 280
-#define tTO 281
-#define tWHILE 282
-#define tGE 283
-#define tLE 284
-#define tGT 285
-#define tLT 286
-#define tEQ 287
-#define tNEQ 288
+#define tIF 269
+#define tINTO 270
+#define tLOOP 271
+#define tMCI 272
+#define tMCIWAIT 273
+#define tMOVIE 274
+#define tNEXT 275
+#define tOF 276
+#define tPREVIOUS 277
+#define tPUT 278
+#define tREPEAT 279
+#define tSET 280
+#define tTHEN 281
+#define tTO 282
+#define tWITH 283
+#define tWHILE 284
+#define tGE 285
+#define tLE 286
+#define tGT 287
+#define tLT 288
+#define tEQ 289
+#define tNEQ 290
@@ -181,7 +185,7 @@ typedef union YYSTYPE
int code;
}
/* Line 193 of yacc.c. */
-#line 185 "engines/director/lingo/lingo-gr.cpp"
+#line 189 "engines/director/lingo/lingo-gr.cpp"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
@@ -194,7 +198,7 @@ typedef union YYSTYPE
/* Line 216 of yacc.c. */
-#line 198 "engines/director/lingo/lingo-gr.cpp"
+#line 202 "engines/director/lingo/lingo-gr.cpp"
#ifdef short
# undef short
@@ -407,22 +411,22 @@ union yyalloc
#endif
/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 43
+#define YYFINAL 45
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 204
+#define YYLAST 226
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 45
+#define YYNTOKENS 47
/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 15
+#define YYNNTS 16
/* YYNRULES -- Number of rules. */
-#define YYNRULES 59
+#define YYNRULES 61
/* YYNRULES -- Number of states. */
-#define YYNSTATES 112
+#define YYNSTATES 123
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 288
+#define YYMAXUTOK 290
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -431,12 +435,12 @@ union yyalloc
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 40, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 42, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 39, 2, 2,
- 41, 42, 37, 35, 2, 36, 2, 38, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 41, 2, 2,
+ 43, 44, 39, 37, 2, 38, 2, 40, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 44, 34, 43, 2, 2, 2, 2, 2, 2, 2,
+ 46, 36, 45, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -458,7 +462,8 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35
};
#if YYDEBUG
@@ -468,46 +473,49 @@ static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 7, 9, 10, 12, 14, 16, 18,
20, 21, 26, 31, 36, 38, 40, 48, 59, 68,
- 70, 74, 78, 81, 83, 84, 85, 88, 91, 93,
- 95, 97, 101, 105, 109, 113, 117, 121, 125, 129,
- 133, 136, 139, 143, 146, 149, 152, 154, 157, 160,
- 163, 166, 170, 173, 177, 180, 183, 185, 189, 192
+ 78, 80, 84, 88, 91, 95, 97, 98, 99, 102,
+ 105, 107, 109, 111, 115, 119, 123, 127, 131, 135,
+ 139, 143, 147, 150, 153, 157, 160, 163, 166, 168,
+ 171, 174, 177, 180, 184, 187, 191, 194, 197, 199,
+ 203, 206
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
- 46, 0, -1, 47, 40, 46, -1, 47, -1, -1,
- 56, -1, 48, -1, 49, -1, 55, -1, 1, -1,
- -1, 22, 55, 14, 7, -1, 24, 7, 34, 55,
- -1, 24, 7, 26, 55, -1, 55, -1, 56, -1,
- 52, 50, 25, 54, 53, 11, 9, -1, 52, 50,
- 25, 54, 53, 10, 54, 53, 11, 9, -1, 51,
- 41, 50, 42, 54, 53, 11, 23, -1, 55, -1,
- 55, 34, 55, -1, 41, 50, 42, -1, 23, 27,
- -1, 9, -1, -1, -1, 54, 40, -1, 54, 49,
- -1, 5, -1, 7, -1, 48, -1, 55, 35, 55,
- -1, 55, 36, 55, -1, 55, 37, 55, -1, 55,
- 38, 55, -1, 55, 43, 55, -1, 55, 44, 55,
- -1, 55, 33, 55, -1, 55, 28, 55, -1, 55,
- 29, 55, -1, 35, 55, -1, 36, 55, -1, 41,
- 55, 42, -1, 16, 8, -1, 17, 7, -1, 22,
- 55, -1, 57, -1, 13, 15, -1, 13, 19, -1,
- 13, 21, -1, 13, 58, -1, 13, 58, 59, -1,
- 13, 59, -1, 26, 12, 8, -1, 12, 8, -1,
- 26, 8, -1, 8, -1, 20, 18, 8, -1, 18,
- 8, -1, 26, 18, 8, -1
+ 48, 0, -1, 49, 42, 48, -1, 49, -1, -1,
+ 59, -1, 50, -1, 51, -1, 58, -1, 1, -1,
+ -1, 23, 58, 15, 7, -1, 25, 7, 36, 58,
+ -1, 25, 7, 27, 58, -1, 58, -1, 59, -1,
+ 55, 52, 26, 57, 56, 11, 14, -1, 55, 52,
+ 26, 57, 56, 10, 57, 56, 11, 14, -1, 53,
+ 43, 52, 44, 57, 56, 11, 24, -1, 54, 36,
+ 58, 27, 58, 57, 56, 11, 24, -1, 58, -1,
+ 58, 36, 58, -1, 43, 52, 44, -1, 24, 29,
+ -1, 24, 28, 7, -1, 14, -1, -1, -1, 57,
+ 42, -1, 57, 51, -1, 5, -1, 7, -1, 50,
+ -1, 58, 37, 58, -1, 58, 38, 58, -1, 58,
+ 39, 58, -1, 58, 40, 58, -1, 58, 45, 58,
+ -1, 58, 46, 58, -1, 58, 35, 58, -1, 58,
+ 30, 58, -1, 58, 31, 58, -1, 37, 58, -1,
+ 38, 58, -1, 43, 58, 44, -1, 17, 8, -1,
+ 18, 7, -1, 23, 58, -1, 60, -1, 13, 16,
+ -1, 13, 20, -1, 13, 22, -1, 13, 61, -1,
+ 13, 61, 62, -1, 13, 62, -1, 27, 12, 8,
+ -1, 12, 8, -1, 27, 8, -1, 8, -1, 21,
+ 19, 8, -1, 19, 8, -1, 27, 19, 8, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
0, 90, 90, 91, 94, 95, 96, 97, 98, 99,
- 100, 103, 104, 105, 108, 109, 110, 116, 128, 136,
- 137, 138, 140, 142, 144, 146, 147, 148, 151, 152,
- 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
- 163, 164, 165, 168, 169, 170, 171, 182, 183, 184,
- 185, 186, 187, 190, 191, 192, 193, 196, 197, 198
+ 100, 103, 104, 105, 108, 109, 110, 116, 128, 143,
+ 155, 156, 157, 159, 161, 167, 169, 171, 172, 173,
+ 176, 177, 178, 179, 180, 181, 182, 183, 184, 185,
+ 186, 187, 188, 189, 190, 193, 194, 195, 196, 207,
+ 208, 209, 210, 211, 212, 215, 216, 217, 218, 221,
+ 222, 223
};
#endif
@@ -517,13 +525,13 @@ static const yytype_uint8 yyrline[] =
static const char *const yytname[] =
{
"$end", "error", "$undefined", "UNARY", "VOID", "INT", "FLOAT", "VAR",
- "STRING", "tIF", "tELSE", "tEND", "tFRAME", "tGO", "tINTO", "tLOOP",
- "tMCI", "tMCIWAIT", "tMOVIE", "tNEXT", "tOF", "tPREVIOUS", "tPUT",
- "tREPEAT", "tSET", "tTHEN", "tTO", "tWHILE", "tGE", "tLE", "tGT", "tLT",
- "tEQ", "tNEQ", "'='", "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('",
- "')'", "'>'", "'<'", "$accept", "program", "programline", "asgn", "stmt",
- "cond", "while", "if", "end", "stmtlist", "expr", "func", "gotofunc",
- "gotoframe", "gotomovie", 0
+ "STRING", "tDOWN", "tELSE", "tEND", "tFRAME", "tGO", "tIF", "tINTO",
+ "tLOOP", "tMCI", "tMCIWAIT", "tMOVIE", "tNEXT", "tOF", "tPREVIOUS",
+ "tPUT", "tREPEAT", "tSET", "tTHEN", "tTO", "tWITH", "tWHILE", "tGE",
+ "tLE", "tGT", "tLT", "tEQ", "tNEQ", "'='", "'+'", "'-'", "'*'", "'/'",
+ "'%'", "'\\n'", "'('", "')'", "'>'", "'<'", "$accept", "program",
+ "programline", "asgn", "stmt", "cond", "repeatwhile", "repeatwith", "if",
+ "end", "stmtlist", "expr", "func", "gotofunc", "gotoframe", "gotomovie", 0
};
#endif
@@ -535,31 +543,33 @@ static const yytype_uint16 yytoknum[] =
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 61, 43, 45, 42, 47, 37,
- 10, 40, 41, 62, 60
+ 285, 286, 287, 288, 289, 290, 61, 43, 45, 42,
+ 47, 37, 10, 40, 41, 62, 60
};
# endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
- 0, 45, 46, 46, 47, 47, 47, 47, 47, 47,
- 47, 48, 48, 48, 49, 49, 49, 49, 49, 50,
- 50, 50, 51, 52, 53, 54, 54, 54, 55, 55,
- 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
- 55, 55, 55, 56, 56, 56, 56, 57, 57, 57,
- 57, 57, 57, 58, 58, 58, 58, 59, 59, 59
+ 0, 47, 48, 48, 49, 49, 49, 49, 49, 49,
+ 49, 50, 50, 50, 51, 51, 51, 51, 51, 51,
+ 52, 52, 52, 53, 54, 55, 56, 57, 57, 57,
+ 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
+ 58, 58, 58, 58, 58, 59, 59, 59, 59, 60,
+ 60, 60, 60, 60, 60, 61, 61, 61, 61, 62,
+ 62, 62
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 3, 1, 0, 1, 1, 1, 1, 1,
- 0, 4, 4, 4, 1, 1, 7, 10, 8, 1,
- 3, 3, 2, 1, 0, 0, 2, 2, 1, 1,
- 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 2, 2, 3, 2, 2, 2, 1, 2, 2, 2,
- 2, 3, 2, 3, 2, 2, 1, 3, 2, 3
+ 0, 4, 4, 4, 1, 1, 7, 10, 8, 9,
+ 1, 3, 3, 2, 3, 1, 0, 0, 2, 2,
+ 1, 1, 1, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 2, 2, 3, 2, 2, 2, 1, 2,
+ 2, 2, 2, 3, 2, 3, 2, 2, 1, 3,
+ 2, 3
};
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -567,51 +577,53 @@ static const yytype_uint8 yyr2[] =
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
- 0, 9, 28, 29, 23, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 3, 30, 7, 0, 0,
- 8, 5, 46, 56, 0, 47, 0, 48, 0, 49,
- 0, 50, 52, 43, 44, 0, 30, 45, 22, 0,
- 40, 41, 0, 1, 0, 0, 0, 0, 19, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 54, 58,
- 0, 55, 0, 0, 0, 51, 0, 0, 0, 0,
- 42, 2, 0, 0, 0, 25, 0, 38, 39, 37,
- 31, 32, 33, 34, 35, 36, 57, 53, 59, 11,
- 13, 12, 25, 21, 24, 20, 24, 26, 27, 0,
- 14, 15, 0, 25, 0, 0, 24, 16, 18, 0,
- 0, 17
+ 0, 9, 30, 31, 0, 25, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 3, 32, 7, 0, 0,
+ 0, 8, 5, 48, 58, 0, 49, 0, 50, 0,
+ 51, 0, 52, 54, 45, 46, 0, 32, 47, 0,
+ 23, 0, 42, 43, 0, 1, 0, 0, 0, 0,
+ 0, 20, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 56, 60, 0, 57, 0, 0, 0, 53, 0,
+ 0, 24, 0, 0, 44, 2, 0, 0, 0, 0,
+ 27, 0, 40, 41, 39, 33, 34, 35, 36, 37,
+ 38, 59, 55, 61, 11, 13, 12, 27, 0, 22,
+ 26, 21, 26, 27, 28, 29, 0, 14, 15, 0,
+ 26, 27, 0, 0, 0, 26, 16, 18, 0, 0,
+ 19, 0, 17
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
- -1, 14, 15, 36, 98, 47, 18, 19, 99, 94,
- 100, 101, 22, 31, 32
+ -1, 14, 15, 37, 105, 50, 18, 19, 20, 106,
+ 100, 107, 108, 23, 32, 33
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
-#define YYPACT_NINF -77
+#define YYPACT_NINF -97
static const yytype_int16 yypact[] =
{
- 65, -77, -77, -77, -77, 10, -6, 8, 2, -10,
- 27, 2, 2, 2, 39, 24, 1, -77, 30, 89,
- 148, -77, -77, -77, 34, -77, 71, -77, 62, -77,
- 55, 57, -77, -77, -77, 2, -77, 100, -77, 6,
- -23, -23, 124, -77, 65, 89, 89, 59, 136, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, -77, -77,
- 77, -77, 78, 82, 74, -77, 100, 90, 2, 2,
- -77, -77, 56, 70, 112, -77, 2, 148, 148, 148,
- 160, 160, -23, -23, 148, 148, -77, -77, -77, -77,
- 148, 148, -77, -77, 86, 148, 86, -77, -77, 49,
- 148, -77, 93, -77, 98, 92, 86, -77, -77, 105,
- 108, -77
+ 62, -97, -97, -97, 10, -97, 30, 16, 2, -26,
+ 34, 2, 2, 2, 44, 22, 1, -97, 27, 29,
+ 85, 168, -97, -97, -97, 63, -97, 69, -97, 59,
+ -97, 9, 47, -97, -97, -97, 2, -97, 103, 76,
+ -97, 6, 180, 180, 144, -97, 62, 85, 2, 85,
+ 65, 156, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, -97, -97, 80, -97, 81, 87, 74, -97, 103,
+ 94, -97, 2, 2, -97, -97, 53, 120, 67, 132,
+ -97, 2, 168, 168, 168, 90, 90, 180, 180, 168,
+ 168, -97, -97, -97, -97, 168, 168, -97, 2, -97,
+ 89, 168, 89, 168, -97, -97, 24, 168, -97, 98,
+ 89, -97, 101, 92, 106, 89, -97, -97, 95, 113,
+ -97, 123, -97
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
- -77, 75, -77, 3, 4, 16, -77, -77, -73, -76,
- 0, 14, -77, -77, 87
+ -97, 93, -97, 4, 5, 35, -97, -97, -97, -96,
+ -87, 0, 15, -97, -97, 112
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@@ -621,70 +633,75 @@ static const yytype_int8 yypgoto[] =
#define YYTABLE_NINF -7
static const yytype_int8 yytable[] =
{
- 20, -6, 33, 16, 17, 49, 50, 2, 37, 3,
- 51, 40, 41, 42, 21, 34, 96, 38, 23, 48,
- 56, 57, 24, 102, 35, 25, 10, 106, 26, 27,
- 28, 29, 68, 109, 39, 66, 30, 11, 12, 43,
- 69, -6, 58, 13, 20, 48, 74, 16, 17, 77,
- 78, 79, 80, 81, 82, 83, 84, 85, 21, 103,
- 104, 72, 73, 61, 44, -4, 1, 62, 90, 91,
- 2, 45, 3, 63, 4, 26, 95, 28, 5, 59,
- 60, 6, 7, 64, 75, 86, 87, 8, 9, 10,
- 88, 2, 63, 3, 2, 4, 3, 89, 92, 5,
- 11, 12, 6, 7, 105, -4, 13, 107, 8, 9,
- 10, 35, 93, 10, 67, 108, 110, 111, 65, 71,
- 0, 11, 12, 0, 11, 12, 97, 13, 49, 50,
- 46, 0, 0, 51, 0, 52, 53, 54, 55, 0,
- 49, 50, 0, 56, 57, 51, 76, 52, 53, 54,
- 55, 0, 49, 50, 70, 56, 57, 51, 0, 52,
- 53, 54, 55, 0, 49, 50, 70, 56, 57, 51,
- 76, 52, 53, 54, 55, 0, 49, 50, 0, 56,
- 57, 51, 0, 52, 53, 54, 55, 0, 49, 50,
- 0, 56, 57, 51, 0, 0, 0, 54, 55, 0,
- 0, 0, 0, 56, 57
+ 21, -6, 39, 40, 16, 17, 109, 2, 38, 3,
+ 102, 42, 43, 44, 114, 22, 110, 64, 24, 119,
+ 51, 65, 25, 35, 115, 36, 26, 10, 66, 27,
+ 28, 29, 30, 72, 111, 112, 69, 31, 34, 11,
+ 12, 41, 73, -6, 45, 13, 21, 51, 77, 79,
+ 16, 17, 82, 83, 84, 85, 86, 87, 88, 89,
+ 90, 22, -4, 1, 46, 48, 27, 2, 29, 3,
+ 47, 61, 95, 96, 67, 4, 5, 62, 63, 6,
+ 7, 101, 76, 71, 78, 8, 9, 10, 91, 92,
+ 2, 80, 3, 66, 2, 93, 3, 97, 103, 11,
+ 12, 94, 4, 5, -4, 13, 6, 7, 36, 113,
+ 10, 99, 8, 9, 10, 116, 117, 118, 70, 120,
+ 52, 53, 11, 12, 121, 54, 11, 12, 49, 57,
+ 58, 104, 13, 52, 53, 59, 60, 122, 54, 75,
+ 55, 56, 57, 58, 68, 0, 0, 98, 59, 60,
+ 52, 53, 0, 0, 0, 54, 0, 55, 56, 57,
+ 58, 0, 52, 53, 0, 59, 60, 54, 81, 55,
+ 56, 57, 58, 0, 52, 53, 74, 59, 60, 54,
+ 0, 55, 56, 57, 58, 0, 52, 53, 74, 59,
+ 60, 54, 81, 55, 56, 57, 58, 0, 52, 53,
+ 0, 59, 60, 54, 0, 55, 56, 57, 58, 0,
+ 52, 53, 0, 59, 60, 54, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 59, 60
};
static const yytype_int8 yycheck[] =
{
- 0, 0, 8, 0, 0, 28, 29, 5, 8, 7,
- 33, 11, 12, 13, 0, 7, 92, 27, 8, 19,
- 43, 44, 12, 96, 22, 15, 24, 103, 18, 19,
- 20, 21, 26, 106, 7, 35, 26, 35, 36, 0,
- 34, 40, 8, 41, 44, 45, 46, 44, 44, 49,
- 50, 51, 52, 53, 54, 55, 56, 57, 44, 10,
- 11, 45, 46, 8, 40, 0, 1, 12, 68, 69,
- 5, 41, 7, 18, 9, 18, 76, 20, 13, 8,
- 18, 16, 17, 26, 25, 8, 8, 22, 23, 24,
- 8, 5, 18, 7, 5, 9, 7, 7, 42, 13,
- 35, 36, 16, 17, 11, 40, 41, 9, 22, 23,
- 24, 22, 42, 24, 14, 23, 11, 9, 31, 44,
- -1, 35, 36, -1, 35, 36, 40, 41, 28, 29,
- 41, -1, -1, 33, -1, 35, 36, 37, 38, -1,
- 28, 29, -1, 43, 44, 33, 34, 35, 36, 37,
- 38, -1, 28, 29, 42, 43, 44, 33, -1, 35,
- 36, 37, 38, -1, 28, 29, 42, 43, 44, 33,
- 34, 35, 36, 37, 38, -1, 28, 29, -1, 43,
- 44, 33, -1, 35, 36, 37, 38, -1, 28, 29,
- -1, 43, 44, 33, -1, -1, -1, 37, 38, -1,
- -1, -1, -1, 43, 44
+ 0, 0, 28, 29, 0, 0, 102, 5, 8, 7,
+ 97, 11, 12, 13, 110, 0, 103, 8, 8, 115,
+ 20, 12, 12, 7, 111, 23, 16, 25, 19, 19,
+ 20, 21, 22, 27, 10, 11, 36, 27, 8, 37,
+ 38, 7, 36, 42, 0, 43, 46, 47, 48, 49,
+ 46, 46, 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 46, 0, 1, 42, 36, 19, 5, 21, 7,
+ 43, 8, 72, 73, 27, 13, 14, 8, 19, 17,
+ 18, 81, 47, 7, 49, 23, 24, 25, 8, 8,
+ 5, 26, 7, 19, 5, 8, 7, 44, 98, 37,
+ 38, 7, 13, 14, 42, 43, 17, 18, 23, 11,
+ 25, 44, 23, 24, 25, 14, 24, 11, 15, 24,
+ 30, 31, 37, 38, 11, 35, 37, 38, 43, 39,
+ 40, 42, 43, 30, 31, 45, 46, 14, 35, 46,
+ 37, 38, 39, 40, 32, -1, -1, 27, 45, 46,
+ 30, 31, -1, -1, -1, 35, -1, 37, 38, 39,
+ 40, -1, 30, 31, -1, 45, 46, 35, 36, 37,
+ 38, 39, 40, -1, 30, 31, 44, 45, 46, 35,
+ -1, 37, 38, 39, 40, -1, 30, 31, 44, 45,
+ 46, 35, 36, 37, 38, 39, 40, -1, 30, 31,
+ -1, 45, 46, 35, -1, 37, 38, 39, 40, -1,
+ 30, 31, -1, 45, 46, 35, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 45, 46
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
- 0, 1, 5, 7, 9, 13, 16, 17, 22, 23,
- 24, 35, 36, 41, 46, 47, 48, 49, 51, 52,
- 55, 56, 57, 8, 12, 15, 18, 19, 20, 21,
- 26, 58, 59, 8, 7, 22, 48, 55, 27, 7,
- 55, 55, 55, 0, 40, 41, 41, 50, 55, 28,
- 29, 33, 35, 36, 37, 38, 43, 44, 8, 8,
- 18, 8, 12, 18, 26, 59, 55, 14, 26, 34,
- 42, 46, 50, 50, 55, 25, 34, 55, 55, 55,
- 55, 55, 55, 55, 55, 55, 8, 8, 8, 7,
- 55, 55, 42, 42, 54, 55, 54, 40, 49, 53,
- 55, 56, 53, 10, 11, 11, 54, 9, 23, 53,
- 11, 9
+ 0, 1, 5, 7, 13, 14, 17, 18, 23, 24,
+ 25, 37, 38, 43, 48, 49, 50, 51, 53, 54,
+ 55, 58, 59, 60, 8, 12, 16, 19, 20, 21,
+ 22, 27, 61, 62, 8, 7, 23, 50, 58, 28,
+ 29, 7, 58, 58, 58, 0, 42, 43, 36, 43,
+ 52, 58, 30, 31, 35, 37, 38, 39, 40, 45,
+ 46, 8, 8, 19, 8, 12, 19, 27, 62, 58,
+ 15, 7, 27, 36, 44, 48, 52, 58, 52, 58,
+ 26, 36, 58, 58, 58, 58, 58, 58, 58, 58,
+ 58, 8, 8, 8, 7, 58, 58, 44, 27, 44,
+ 57, 58, 57, 58, 42, 51, 56, 58, 59, 56,
+ 57, 10, 11, 11, 56, 57, 14, 24, 11, 56,
+ 24, 11, 14
};
#define yyerrok (yyerrstatus = 0)
@@ -1566,188 +1583,211 @@ yyreduce:
break;
case 19:
-#line 136 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(STOP); ;}
+#line 143 "engines/director/lingo/lingo-gr.y"
+ {
+ inst init, finish, body, end;
+ WRITE_LE_UINT32(&init, (yyvsp[(3) - (9)].code));
+ WRITE_LE_UINT32(&finish, (yyvsp[(5) - (9)].code));
+ WRITE_LE_UINT32(&body, (yyvsp[(6) - (9)].code));
+ WRITE_LE_UINT32(&end, (yyvsp[(7) - (9)].code));
+ (*g_lingo->_currentScript)[(yyvsp[(1) - (9)].code) + 1] = init; /* initial count value */
+ (*g_lingo->_currentScript)[(yyvsp[(1) - (9)].code) + 2] = finish;/* final count value */
+ (*g_lingo->_currentScript)[(yyvsp[(1) - (9)].code) + 3] = body; /* body of loop */
+ (*g_lingo->_currentScript)[(yyvsp[(1) - (9)].code) + 4] = end; ;}
break;
case 20:
-#line 137 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code2(g_lingo->c_eq, STOP); ;}
+#line 155 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(STOP); ;}
break;
- case 22:
-#line 140 "engines/director/lingo/lingo-gr.y"
- { (yyval.code) = g_lingo->code3(g_lingo->c_whilecode, STOP, STOP); ;}
+ case 21:
+#line 156 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code2(g_lingo->c_eq, STOP); ;}
break;
case 23:
-#line 142 "engines/director/lingo/lingo-gr.y"
- { (yyval.code) = g_lingo->code1(g_lingo->c_ifcode); g_lingo->code3(STOP, STOP, STOP); ;}
+#line 159 "engines/director/lingo/lingo-gr.y"
+ { (yyval.code) = g_lingo->code3(g_lingo->c_repeatwhilecode, STOP, STOP); ;}
break;
case 24:
-#line 144 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(STOP); (yyval.code) = g_lingo->_currentScript->size(); ;}
+#line 161 "engines/director/lingo/lingo-gr.y"
+ {
+ (yyval.code) = g_lingo->code3(g_lingo->c_repeatwithcode, STOP, STOP);
+ g_lingo->code2(STOP, STOP);
+ g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str());
+ delete (yyvsp[(3) - (3)].s); ;}
break;
case 25:
-#line 146 "engines/director/lingo/lingo-gr.y"
+#line 167 "engines/director/lingo/lingo-gr.y"
+ { (yyval.code) = g_lingo->code1(g_lingo->c_ifcode); g_lingo->code3(STOP, STOP, STOP); ;}
+ break;
+
+ case 26:
+#line 169 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(STOP); (yyval.code) = g_lingo->_currentScript->size(); ;}
+ break;
+
+ case 27:
+#line 171 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = g_lingo->_currentScript->size(); ;}
break;
- case 28:
-#line 151 "engines/director/lingo/lingo-gr.y"
+ case 30:
+#line 176 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_constpush); inst i; WRITE_LE_UINT32(&i, (yyvsp[(1) - (1)].i)); (yyval.code) = g_lingo->code1(i); ;}
break;
- case 29:
-#line 152 "engines/director/lingo/lingo-gr.y"
+ case 31:
+#line 177 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); (yyval.code) = g_lingo->code1(g_lingo->c_eval); delete (yyvsp[(1) - (1)].s); ;}
break;
- case 31:
-#line 154 "engines/director/lingo/lingo-gr.y"
+ case 33:
+#line 179 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_add); ;}
break;
- case 32:
-#line 155 "engines/director/lingo/lingo-gr.y"
+ case 34:
+#line 180 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_sub); ;}
break;
- case 33:
-#line 156 "engines/director/lingo/lingo-gr.y"
+ case 35:
+#line 181 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_mul); ;}
break;
- case 34:
-#line 157 "engines/director/lingo/lingo-gr.y"
+ case 36:
+#line 182 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_div); ;}
break;
- case 35:
-#line 158 "engines/director/lingo/lingo-gr.y"
+ case 37:
+#line 183 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_gt); ;}
break;
- case 36:
-#line 159 "engines/director/lingo/lingo-gr.y"
+ case 38:
+#line 184 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_lt); ;}
break;
- case 37:
-#line 160 "engines/director/lingo/lingo-gr.y"
+ case 39:
+#line 185 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_neq); ;}
break;
- case 38:
-#line 161 "engines/director/lingo/lingo-gr.y"
+ case 40:
+#line 186 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_ge); ;}
break;
- case 39:
-#line 162 "engines/director/lingo/lingo-gr.y"
+ case 41:
+#line 187 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_le); ;}
break;
- case 40:
-#line 163 "engines/director/lingo/lingo-gr.y"
+ case 42:
+#line 188 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = (yyvsp[(2) - (2)].code); ;}
break;
- case 41:
-#line 164 "engines/director/lingo/lingo-gr.y"
+ case 43:
+#line 189 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->c_negate); ;}
break;
- case 42:
-#line 165 "engines/director/lingo/lingo-gr.y"
+ case 44:
+#line 190 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = (yyvsp[(2) - (3)].code); ;}
break;
- case 43:
-#line 168 "engines/director/lingo/lingo-gr.y"
+ case 45:
+#line 193 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_mci); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
break;
- case 44:
-#line 169 "engines/director/lingo/lingo-gr.y"
+ case 46:
+#line 194 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_mciwait); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
break;
- case 45:
-#line 170 "engines/director/lingo/lingo-gr.y"
+ case 47:
+#line 195 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_printtop); ;}
break;
- case 47:
-#line 182 "engines/director/lingo/lingo-gr.y"
+ case 49:
+#line 207 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_gotoloop); ;}
break;
- case 48:
-#line 183 "engines/director/lingo/lingo-gr.y"
+ case 50:
+#line 208 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_gotonext); ;}
break;
- case 49:
-#line 184 "engines/director/lingo/lingo-gr.y"
+ case 51:
+#line 209 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_gotoprevious); ;}
break;
- case 50:
-#line 185 "engines/director/lingo/lingo-gr.y"
+ case 52:
+#line 210 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_goto); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); g_lingo->codeString(""); delete (yyvsp[(2) - (2)].s); ;}
break;
- case 51:
-#line 186 "engines/director/lingo/lingo-gr.y"
+ case 53:
+#line 211 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_goto); g_lingo->codeString((yyvsp[(2) - (3)].s)->c_str()); g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str()); delete (yyvsp[(2) - (3)].s); delete (yyvsp[(3) - (3)].s); ;}
break;
- case 52:
-#line 187 "engines/director/lingo/lingo-gr.y"
+ case 54:
+#line 212 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_goto); g_lingo->codeString(""); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
break;
- case 53:
-#line 190 "engines/director/lingo/lingo-gr.y"
+ case 55:
+#line 215 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(3) - (3)].s); ;}
break;
- case 54:
-#line 191 "engines/director/lingo/lingo-gr.y"
+ case 56:
+#line 216 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(2) - (2)].s); ;}
break;
- case 55:
-#line 192 "engines/director/lingo/lingo-gr.y"
+ case 57:
+#line 217 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(2) - (2)].s); ;}
break;
- case 56:
-#line 193 "engines/director/lingo/lingo-gr.y"
+ case 58:
+#line 218 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(1) - (1)].s); ;}
break;
- case 57:
-#line 196 "engines/director/lingo/lingo-gr.y"
+ case 59:
+#line 221 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(3) - (3)].s); ;}
break;
- case 58:
-#line 197 "engines/director/lingo/lingo-gr.y"
+ case 60:
+#line 222 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(2) - (2)].s); ;}
break;
- case 59:
-#line 198 "engines/director/lingo/lingo-gr.y"
+ case 61:
+#line 223 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(3) - (3)].s); ;}
break;
/* Line 1267 of yacc.c. */
-#line 1751 "engines/director/lingo/lingo-gr.cpp"
+#line 1791 "engines/director/lingo/lingo-gr.cpp"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1961,6 +2001,6 @@ yyreturn:
}
-#line 237 "engines/director/lingo/lingo-gr.y"
+#line 253 "engines/director/lingo/lingo-gr.y"
diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h
index e3b6ea99ac..732f08426d 100644
--- a/engines/director/lingo/lingo-gr.h
+++ b/engines/director/lingo/lingo-gr.h
@@ -45,31 +45,33 @@
FLOAT = 261,
VAR = 262,
STRING = 263,
- tIF = 264,
+ tDOWN = 264,
tELSE = 265,
tEND = 266,
tFRAME = 267,
tGO = 268,
- tINTO = 269,
- tLOOP = 270,
- tMCI = 271,
- tMCIWAIT = 272,
- tMOVIE = 273,
- tNEXT = 274,
- tOF = 275,
- tPREVIOUS = 276,
- tPUT = 277,
- tREPEAT = 278,
- tSET = 279,
- tTHEN = 280,
- tTO = 281,
- tWHILE = 282,
- tGE = 283,
- tLE = 284,
- tGT = 285,
- tLT = 286,
- tEQ = 287,
- tNEQ = 288
+ tIF = 269,
+ tINTO = 270,
+ tLOOP = 271,
+ tMCI = 272,
+ tMCIWAIT = 273,
+ tMOVIE = 274,
+ tNEXT = 275,
+ tOF = 276,
+ tPREVIOUS = 277,
+ tPUT = 278,
+ tREPEAT = 279,
+ tSET = 280,
+ tTHEN = 281,
+ tTO = 282,
+ tWITH = 283,
+ tWHILE = 284,
+ tGE = 285,
+ tLE = 286,
+ tGT = 287,
+ tLT = 288,
+ tEQ = 289,
+ tNEQ = 290
};
#endif
/* Tokens. */
@@ -79,31 +81,33 @@
#define FLOAT 261
#define VAR 262
#define STRING 263
-#define tIF 264
+#define tDOWN 264
#define tELSE 265
#define tEND 266
#define tFRAME 267
#define tGO 268
-#define tINTO 269
-#define tLOOP 270
-#define tMCI 271
-#define tMCIWAIT 272
-#define tMOVIE 273
-#define tNEXT 274
-#define tOF 275
-#define tPREVIOUS 276
-#define tPUT 277
-#define tREPEAT 278
-#define tSET 279
-#define tTHEN 280
-#define tTO 281
-#define tWHILE 282
-#define tGE 283
-#define tLE 284
-#define tGT 285
-#define tLT 286
-#define tEQ 287
-#define tNEQ 288
+#define tIF 269
+#define tINTO 270
+#define tLOOP 271
+#define tMCI 272
+#define tMCIWAIT 273
+#define tMOVIE 274
+#define tNEXT 275
+#define tOF 276
+#define tPREVIOUS 277
+#define tPUT 278
+#define tREPEAT 279
+#define tSET 280
+#define tTHEN 281
+#define tTO 282
+#define tWITH 283
+#define tWHILE 284
+#define tGE 285
+#define tLE 286
+#define tGT 287
+#define tLT 288
+#define tEQ 289
+#define tNEQ 290
@@ -118,7 +122,7 @@ typedef union YYSTYPE
int code;
}
/* Line 1529 of yacc.c. */
-#line 122 "engines/director/lingo/lingo-gr.hpp"
+#line 126 "engines/director/lingo/lingo-gr.hpp"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y
index 179359c87e..eb584609d0 100644
--- a/engines/director/lingo/lingo-gr.y
+++ b/engines/director/lingo/lingo-gr.y
@@ -73,11 +73,11 @@ using namespace Director;
%token<i> INT
%token<f> FLOAT
%token<s> VAR STRING
-%token tIF tELSE tEND tFRAME tGO tINTO tLOOP tMCI tMCIWAIT tMOVIE tNEXT tOF tPREVIOUS
-%token tPUT tREPEAT tSET tTHEN tTO tWHILE
+%token tDOWN tELSE tEND tFRAME tGO tIF tINTO tLOOP tMCI tMCIWAIT tMOVIE tNEXT
+%token tOF tPREVIOUS tPUT tREPEAT tSET tTHEN tTO tWITH tWHILE
%token tGE tLE tGT tLT tEQ tNEQ
-%type<code> asgn cond expr if end stmtlist while
+%type<code> asgn cond end expr if repeatwhile repeatwith stmtlist
%type<s> gotoframe gotomovie
%right '='
@@ -125,19 +125,44 @@ stmt: expr { g_lingo->code1(g_lingo->c_xpop); }
// statements
// end repeat
//
- | while '(' cond ')' stmtlist end tEND tREPEAT {
+ | repeatwhile '(' cond ')' stmtlist end tEND tREPEAT {
inst body, end;
WRITE_LE_UINT32(&body, $5);
WRITE_LE_UINT32(&end, $6);
(*g_lingo->_currentScript)[$1 + 1] = body; /* body of loop */
(*g_lingo->_currentScript)[$1 + 2] = end; } /* end, if cond fails */
;
+ // repeat with index = start to end
+ // statements
+ // end repeat
+ //
+ // repeat with index = high down to low
+ // statements
+ // end repeat
+ //
+ | repeatwith '=' expr tTO expr stmtlist end tEND tREPEAT {
+ inst init, finish, body, end;
+ WRITE_LE_UINT32(&init, $3);
+ WRITE_LE_UINT32(&finish, $5);
+ WRITE_LE_UINT32(&body, $6);
+ WRITE_LE_UINT32(&end, $7);
+ (*g_lingo->_currentScript)[$1 + 1] = init; /* initial count value */
+ (*g_lingo->_currentScript)[$1 + 2] = finish;/* final count value */
+ (*g_lingo->_currentScript)[$1 + 3] = body; /* body of loop */
+ (*g_lingo->_currentScript)[$1 + 4] = end; } /* end, if cond fails */
+ ;
cond: expr { g_lingo->code1(STOP); }
| expr '=' expr { g_lingo->code2(g_lingo->c_eq, STOP); }
| '(' cond ')'
;
-while: tREPEAT tWHILE { $$ = g_lingo->code3(g_lingo->c_whilecode, STOP, STOP); }
+repeatwhile: tREPEAT tWHILE { $$ = g_lingo->code3(g_lingo->c_repeatwhilecode, STOP, STOP); }
+ ;
+repeatwith: tREPEAT tWITH VAR {
+ $$ = g_lingo->code3(g_lingo->c_repeatwithcode, STOP, STOP);
+ g_lingo->code2(STOP, STOP);
+ g_lingo->codeString($3->c_str());
+ delete $3; }
;
if: tIF { $$ = g_lingo->code1(g_lingo->c_ifcode); g_lingo->code3(STOP, STOP, STOP); }
;
@@ -198,15 +223,6 @@ gotomovie: tOF tMOVIE STRING { $$ = $3; }
| tTO tMOVIE STRING { $$ = $3; }
;
-// repeat with index = start to end
-// statements
-// end repeat
-//
-// repeat with index = high down to low
-// statements
-// end repeat
-//
-
// macro
//
// Special Note The macro keyword is retained in Director 3.0 to maintain compatibility
diff --git a/engines/director/lingo/lingo-lex.cpp b/engines/director/lingo/lingo-lex.cpp
index bf322e2ce9..bbaf7dcee6 100644
--- a/engines/director/lingo/lingo-lex.cpp
+++ b/engines/director/lingo/lingo-lex.cpp
@@ -364,8 +364,8 @@ static void yy_fatal_error (yyconst char msg[] );
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
-#define YY_NUM_RULES 32
-#define YY_END_OF_BUFFER 33
+#define YY_NUM_RULES 34
+#define YY_END_OF_BUFFER 35
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -373,19 +373,20 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[99] =
+static yyconst flex_int16_t yy_accept[106] =
{ 0,
- 0, 0, 33, 32, 3, 30, 32, 32, 29, 29,
- 28, 29, 29, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 2, 2, 3,
- 30, 23, 0, 31, 1, 27, 28, 25, 24, 26,
- 26, 26, 26, 8, 4, 26, 26, 26, 26, 26,
- 15, 26, 26, 26, 26, 26, 21, 26, 1, 27,
- 26, 6, 26, 26, 26, 11, 26, 26, 26, 17,
- 26, 19, 26, 26, 5, 26, 9, 10, 26, 26,
- 14, 26, 26, 20, 26, 7, 26, 13, 26, 26,
- 22, 26, 26, 18, 12, 26, 16, 0
-
+ 0, 0, 35, 34, 3, 32, 34, 34, 31, 31,
+ 30, 31, 31, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 2, 2,
+ 3, 32, 25, 0, 33, 1, 29, 30, 27, 26,
+ 28, 28, 28, 28, 28, 9, 5, 28, 28, 28,
+ 28, 28, 16, 28, 28, 28, 28, 28, 22, 28,
+ 28, 1, 29, 28, 28, 7, 28, 28, 28, 12,
+ 28, 28, 28, 18, 28, 20, 28, 28, 28, 4,
+ 6, 28, 10, 11, 28, 28, 15, 28, 28, 21,
+ 28, 23, 8, 28, 14, 28, 28, 24, 28, 28,
+
+ 19, 13, 28, 17, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -428,78 +429,78 @@ static yyconst flex_int32_t yy_meta[36] =
4, 4, 4, 4, 4
} ;
-static yyconst flex_int16_t yy_base[102] =
+static yyconst flex_int16_t yy_base[109] =
{ 0,
- 0, 34, 118, 119, 115, 34, 103, 108, 119, 105,
- 30, 100, 99, 0, 18, 82, 83, 23, 82, 28,
- 89, 87, 18, 87, 86, 24, 82, 101, 119, 100,
- 49, 119, 94, 119, 0, 89, 46, 119, 119, 0,
- 69, 80, 81, 0, 0, 65, 68, 71, 60, 57,
- 0, 72, 59, 61, 57, 68, 0, 63, 0, 74,
- 65, 0, 58, 55, 53, 46, 56, 47, 44, 0,
- 57, 0, 49, 50, 0, 54, 0, 0, 56, 52,
- 0, 47, 53, 0, 49, 0, 44, 0, 39, 33,
- 0, 32, 27, 0, 0, 24, 0, 119, 57, 44,
-
- 61
+ 0, 34, 124, 125, 121, 34, 109, 114, 125, 111,
+ 30, 106, 105, 0, 90, 18, 87, 88, 23, 87,
+ 28, 94, 92, 18, 92, 91, 24, 30, 107, 125,
+ 106, 53, 125, 100, 125, 0, 95, 48, 125, 125,
+ 0, 71, 74, 85, 86, 0, 0, 70, 73, 76,
+ 65, 62, 0, 77, 64, 66, 62, 73, 0, 68,
+ 59, 0, 78, 62, 68, 0, 61, 58, 56, 49,
+ 59, 50, 47, 0, 60, 0, 52, 53, 54, 0,
+ 0, 56, 0, 0, 58, 54, 0, 49, 55, 0,
+ 51, 0, 0, 46, 0, 41, 35, 0, 34, 29,
+
+ 0, 0, 24, 0, 125, 59, 44, 63
} ;
-static yyconst flex_int16_t yy_def[102] =
+static yyconst flex_int16_t yy_def[109] =
{ 0,
- 98, 1, 98, 98, 98, 98, 98, 99, 98, 98,
- 98, 98, 98, 100, 100, 100, 100, 100, 100, 100,
- 100, 100, 100, 100, 100, 100, 100, 98, 98, 98,
- 98, 98, 99, 98, 101, 98, 98, 98, 98, 100,
- 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
- 100, 100, 100, 100, 100, 100, 100, 100, 101, 98,
- 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
- 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
- 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
- 100, 100, 100, 100, 100, 100, 100, 0, 98, 98,
-
- 98
+ 105, 1, 105, 105, 105, 105, 105, 106, 105, 105,
+ 105, 105, 105, 107, 107, 107, 107, 107, 107, 107,
+ 107, 107, 107, 107, 107, 107, 107, 107, 105, 105,
+ 105, 105, 105, 106, 105, 108, 105, 105, 105, 105,
+ 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
+ 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
+ 107, 108, 105, 107, 107, 107, 107, 107, 107, 107,
+ 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
+ 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
+ 107, 107, 107, 107, 107, 107, 107, 107, 107, 107,
+
+ 107, 107, 107, 107, 0, 105, 105, 105
} ;
-static yyconst flex_int16_t yy_nxt[155] =
+static yyconst flex_int16_t yy_nxt[161] =
{ 0,
4, 5, 6, 6, 4, 7, 8, 9, 10, 4,
- 11, 12, 9, 13, 14, 14, 14, 14, 15, 16,
- 17, 14, 18, 19, 20, 21, 22, 23, 24, 25,
- 26, 14, 14, 27, 14, 28, 31, 31, 29, 36,
- 37, 41, 45, 42, 48, 56, 52, 40, 46, 53,
- 57, 31, 31, 97, 49, 36, 37, 33, 96, 33,
- 33, 59, 95, 94, 59, 93, 92, 91, 90, 89,
- 88, 87, 86, 85, 84, 83, 82, 81, 80, 79,
- 78, 77, 76, 75, 60, 74, 73, 72, 71, 70,
- 69, 68, 67, 66, 65, 64, 63, 62, 61, 60,
-
- 34, 30, 30, 58, 55, 54, 51, 50, 47, 44,
- 43, 39, 38, 35, 34, 32, 30, 98, 3, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98
+ 11, 12, 9, 13, 14, 14, 14, 15, 16, 17,
+ 18, 14, 19, 20, 21, 22, 23, 24, 25, 26,
+ 27, 14, 14, 28, 14, 29, 32, 32, 30, 37,
+ 38, 43, 47, 44, 50, 58, 54, 41, 48, 55,
+ 59, 60, 61, 104, 51, 32, 32, 37, 38, 34,
+ 103, 34, 34, 62, 102, 101, 62, 100, 99, 98,
+ 97, 96, 95, 94, 93, 92, 91, 90, 89, 88,
+ 87, 86, 85, 84, 83, 82, 81, 80, 63, 79,
+ 78, 77, 76, 75, 74, 73, 72, 71, 70, 69,
+
+ 68, 67, 66, 65, 64, 63, 35, 31, 31, 57,
+ 56, 53, 52, 49, 46, 45, 42, 40, 39, 36,
+ 35, 33, 31, 105, 3, 105, 105, 105, 105, 105,
+ 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
+ 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
+ 105, 105, 105, 105, 105, 105, 105, 105, 105, 105
} ;
-static yyconst flex_int16_t yy_chk[155] =
+static yyconst flex_int16_t yy_chk[161] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 2, 6, 6, 2, 11,
- 11, 15, 18, 15, 20, 26, 23, 100, 18, 23,
- 26, 31, 31, 96, 20, 37, 37, 99, 93, 99,
- 99, 101, 92, 90, 101, 89, 87, 85, 83, 82,
- 80, 79, 76, 74, 73, 71, 69, 68, 67, 66,
- 65, 64, 63, 61, 60, 58, 56, 55, 54, 53,
- 52, 50, 49, 48, 47, 46, 43, 42, 41, 36,
-
- 33, 30, 28, 27, 25, 24, 22, 21, 19, 17,
- 16, 13, 12, 10, 8, 7, 5, 3, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
- 98, 98, 98, 98
+ 11, 16, 19, 16, 21, 27, 24, 107, 19, 24,
+ 27, 28, 28, 103, 21, 32, 32, 38, 38, 106,
+ 100, 106, 106, 108, 99, 97, 108, 96, 94, 91,
+ 89, 88, 86, 85, 82, 79, 78, 77, 75, 73,
+ 72, 71, 70, 69, 68, 67, 65, 64, 63, 61,
+ 60, 58, 57, 56, 55, 54, 52, 51, 50, 49,
+
+ 48, 45, 44, 43, 42, 37, 34, 31, 29, 26,
+ 25, 23, 22, 20, 18, 17, 15, 13, 12, 10,
+ 8, 7, 5, 3, 105, 105, 105, 105, 105, 105,
+ 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
+ 105, 105, 105, 105, 105, 105, 105, 105, 105, 105,
+ 105, 105, 105, 105, 105, 105, 105, 105, 105, 105
} ;
static yy_state_type yy_last_accepting_state;
@@ -549,7 +550,7 @@ char *yytext;
int yyparse();
-#line 553 "engines/director/lingo/lingo-lex.cpp"
+#line 554 "engines/director/lingo/lingo-lex.cpp"
#define INITIAL 0
@@ -737,7 +738,7 @@ YY_DECL
#line 45 "engines/director/lingo/lingo-lex.l"
-#line 741 "engines/director/lingo/lingo-lex.cpp"
+#line 742 "engines/director/lingo/lingo-lex.cpp"
if ( !(yy_init) )
{
@@ -791,13 +792,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 99 )
+ if ( yy_current_state >= 106 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 119 );
+ while ( yy_base[yy_current_state] != 125 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -839,150 +840,160 @@ YY_RULE_SETUP
case 4:
YY_RULE_SETUP
#line 51 "engines/director/lingo/lingo-lex.l"
-{ return tIF; }
+{ return tDOWN; }
YY_BREAK
case 5:
YY_RULE_SETUP
#line 52 "engines/director/lingo/lingo-lex.l"
-{ return tELSE; }
+{ return tIF; }
YY_BREAK
case 6:
YY_RULE_SETUP
#line 53 "engines/director/lingo/lingo-lex.l"
-{ return tEND; }
+{ return tELSE; }
YY_BREAK
case 7:
YY_RULE_SETUP
#line 54 "engines/director/lingo/lingo-lex.l"
-{ return tFRAME; }
+{ return tEND; }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 55 "engines/director/lingo/lingo-lex.l"
-{ return tGO; }
+{ return tFRAME; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 56 "engines/director/lingo/lingo-lex.l"
-{ return tINTO; }
+{ return tGO; }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 57 "engines/director/lingo/lingo-lex.l"
-{ return tLOOP; }
+{ return tINTO; }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 58 "engines/director/lingo/lingo-lex.l"
-{ return tMCI; }
+{ return tLOOP; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 59 "engines/director/lingo/lingo-lex.l"
-{ return tMCIWAIT; }
+{ return tMCI; }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 60 "engines/director/lingo/lingo-lex.l"
-{ return tMOVIE; }
+{ return tMCIWAIT; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 61 "engines/director/lingo/lingo-lex.l"
-{ return tNEXT; }
+{ return tMOVIE; }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 62 "engines/director/lingo/lingo-lex.l"
-{ return tOF; }
+{ return tNEXT; }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 63 "engines/director/lingo/lingo-lex.l"
-{ return tPREVIOUS; }
+{ return tOF; }
YY_BREAK
case 17:
YY_RULE_SETUP
#line 64 "engines/director/lingo/lingo-lex.l"
-{ return tPUT; }
+{ return tPREVIOUS; }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 65 "engines/director/lingo/lingo-lex.l"
-{ return tREPEAT; }
+{ return tPUT; }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 66 "engines/director/lingo/lingo-lex.l"
-{ return tSET; }
+{ return tREPEAT; }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 67 "engines/director/lingo/lingo-lex.l"
-{ return tTHEN; }
+{ return tSET; }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 68 "engines/director/lingo/lingo-lex.l"
-{ return tTO; }
+{ return tTHEN; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 69 "engines/director/lingo/lingo-lex.l"
-{ return tWHILE; }
+{ return tTO; }
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 71 "engines/director/lingo/lingo-lex.l"
-{ return tNEQ; }
+#line 70 "engines/director/lingo/lingo-lex.l"
+{ return tWITH; }
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 72 "engines/director/lingo/lingo-lex.l"
-{ return tGE; }
+#line 71 "engines/director/lingo/lingo-lex.l"
+{ return tWHILE; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 73 "engines/director/lingo/lingo-lex.l"
-{ return tLE; }
+{ return tNEQ; }
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 75 "engines/director/lingo/lingo-lex.l"
-{ yylval.s = new Common::String(yytext); return VAR; }
+#line 74 "engines/director/lingo/lingo-lex.l"
+{ return tGE; }
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 76 "engines/director/lingo/lingo-lex.l"
-{ yylval.f = atof(yytext); return FLOAT; }
+#line 75 "engines/director/lingo/lingo-lex.l"
+{ return tLE; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 77 "engines/director/lingo/lingo-lex.l"
-{ yylval.i = strtol(yytext, NULL, 10); return INT; }
+{ yylval.s = new Common::String(yytext); return VAR; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 78 "engines/director/lingo/lingo-lex.l"
-{ return *yytext; }
+{ yylval.f = atof(yytext); return FLOAT; }
YY_BREAK
case 30:
-/* rule 30 can match eol */
YY_RULE_SETUP
#line 79 "engines/director/lingo/lingo-lex.l"
-{ return '\n'; }
+{ yylval.i = strtol(yytext, NULL, 10); return INT; }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 80 "engines/director/lingo/lingo-lex.l"
-{ yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; }
+{ return *yytext; }
YY_BREAK
case 32:
+/* rule 32 can match eol */
+YY_RULE_SETUP
+#line 81 "engines/director/lingo/lingo-lex.l"
+{ return '\n'; }
+ YY_BREAK
+case 33:
YY_RULE_SETUP
#line 82 "engines/director/lingo/lingo-lex.l"
+{ yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; }
+ YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 84 "engines/director/lingo/lingo-lex.l"
ECHO;
YY_BREAK
-#line 986 "engines/director/lingo/lingo-lex.cpp"
+#line 997 "engines/director/lingo/lingo-lex.cpp"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -1275,7 +1286,7 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 99 )
+ if ( yy_current_state >= 106 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1303,11 +1314,11 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 99 )
+ if ( yy_current_state >= 106 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 98);
+ yy_is_jam = (yy_current_state == 105);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -1982,7 +1993,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables"
-#line 82 "engines/director/lingo/lingo-lex.l"
+#line 84 "engines/director/lingo/lingo-lex.l"
diff --git a/engines/director/lingo/lingo-lex.l b/engines/director/lingo/lingo-lex.l
index 07d9a63c72..2ae996094f 100644
--- a/engines/director/lingo/lingo-lex.l
+++ b/engines/director/lingo/lingo-lex.l
@@ -48,6 +48,7 @@ whitespace [\t ]
^{whitespace}
[\t]+ { return ' '; }
+down { return tDOWN; }
if { return tIF; }
else { return tELSE; }
end { return tEND; }
@@ -66,6 +67,7 @@ repeat { return tREPEAT; }
set { return tSET; }
then { return tTHEN; }
to { return tTO; }
+with { return tWITH; }
while { return tWHILE; }
[!][=] { return tNEQ; }
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index f167e28720..cca423a838 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -132,7 +132,8 @@ public:
static void c_assign();
bool verify(Symbol *s);
static void c_eval();
- static void c_whilecode();
+ static void c_repeatwhilecode();
+ static void c_repeatwithcode();
static void c_ifcode();
static void c_eq();
static void c_neq();