aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/director/director.cpp3
-rw-r--r--engines/director/lingo/lingo-funcs.cpp39
-rw-r--r--engines/director/lingo/lingo-gr.cpp386
-rw-r--r--engines/director/lingo/lingo-gr.h60
-rw-r--r--engines/director/lingo/lingo-gr.y28
-rw-r--r--engines/director/lingo/lingo-lex.cpp206
-rw-r--r--engines/director/lingo/lingo-lex.l3
-rw-r--r--engines/director/lingo/lingo.cpp7
-rw-r--r--engines/director/lingo/lingo.h12
9 files changed, 438 insertions, 306 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 86de72d20e..b184716b1e 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -81,7 +81,8 @@ go \"CARDBACK\"\n\
go movie \"BAR 1\"\n\
go to \"Open23\" of movie \"OpenCabin23\"\n\
go to \"Chair\"\n\
- ", kMovieScript, 2);
+set x = 2 + 3 * (4 / 2)\n\
+x ", kMovieScript, 2);
_lingo->executeScript(kMovieScript, 2);
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp
index cfcf46f1dd..8144270c56 100644
--- a/engines/director/lingo/lingo-funcs.cpp
+++ b/engines/director/lingo/lingo-funcs.cpp
@@ -193,6 +193,13 @@ void Lingo::exec_goto(Common::String &frame, Common::String &movie) {
warning("STUB: go to %s movie %s", frame.c_str(), movie.c_str());
}
+void Lingo::execute(int pc) {
+ for(_pc = pc; (*_currentScript)[_pc] != STOP;) {
+ _pc++;
+ (*((*_currentScript)[_pc - 1]))();
+ }
+}
+
void Lingo::push(Datum d) {
_stack.push_back(d);
}
@@ -219,7 +226,7 @@ void Lingo::func_printtop(void) {
void Lingo::func_constpush() {
Datum d;
- inst i = *g_lingo->_pc++;
+ inst i = (*g_lingo->_currentScript)[g_lingo->_pc++];
d.val = READ_LE_UINT32(&i);
g_lingo->push(d);
}
@@ -227,7 +234,7 @@ void Lingo::func_constpush() {
void Lingo::func_varpush() {
Datum d;
Symbol *sym;
- char *name = (char *)g_lingo->_pc;
+ char *name = (char *)(*g_lingo->_currentScript)[g_lingo->_pc];
if (!g_lingo->_vars.contains(name)) { // Create variable if it was not defined
sym = new Symbol;
@@ -334,8 +341,28 @@ void Lingo::func_negate() {
g_lingo->push(d);
}
+void Lingo::func_ifcode() {
+ Datum d;
+ int savepc = g_lingo->_pc; /* then part */
+
+ g_lingo->execute(savepc + 3); /* condition */
+
+ d = g_lingo->pop();
+
+ if (d.val)
+ g_lingo->execute(savepc);
+ else if ((*g_lingo->_currentScript)[savepc + 1]) /* else part? */
+ g_lingo->execute(savepc + 1);
+
+ //if (!returning)
+ g_lingo->_pc = savepc + 2; /* next stmt */
+}
+
+//************************
+// Built-in functions
+//************************
void Lingo::func_mci() {
- Common::String s((char *)g_lingo->_pc);
+ Common::String s((char *)&(*g_lingo->_currentScript)[g_lingo->_pc]);
g_lingo->exec_mci(s);
@@ -343,7 +370,7 @@ void Lingo::func_mci() {
}
void Lingo::func_mciwait() {
- Common::String s((char *)g_lingo->_pc);
+ Common::String s((char *)&(*g_lingo->_currentScript)[g_lingo->_pc]);
g_lingo->exec_mciwait(s);
@@ -351,10 +378,10 @@ void Lingo::func_mciwait() {
}
void Lingo::func_goto() {
- Common::String frame((char *)g_lingo->_pc);
+ Common::String frame((char *)&(*g_lingo->_currentScript)[g_lingo->_pc]);
g_lingo->_pc += g_lingo->calcStringAlignment(frame.c_str());
- Common::String movie((char *)g_lingo->_pc);
+ Common::String movie((char *)&(*g_lingo->_currentScript)[g_lingo->_pc]);
g_lingo->_pc += g_lingo->calcStringAlignment(movie.c_str());
g_lingo->exec_goto(frame, movie);
diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp
index 5d3406d65a..9f971cba28 100644
--- a/engines/director/lingo/lingo-gr.cpp
+++ b/engines/director/lingo/lingo-gr.cpp
@@ -72,19 +72,22 @@
FLOAT = 261,
VAR = 262,
STRING = 263,
- tFRAME = 264,
- tGO = 265,
- tINTO = 266,
- tLOOP = 267,
- tMCI = 268,
- tMCIWAIT = 269,
- tMOVIE = 270,
- tNEXT = 271,
- tOF = 272,
- tPREVIOUS = 273,
- tPUT = 274,
- tSET = 275,
- tTO = 276
+ tIF = 264,
+ tEND = 265,
+ tFRAME = 266,
+ tGO = 267,
+ tINTO = 268,
+ tLOOP = 269,
+ tMCI = 270,
+ tMCIWAIT = 271,
+ tMOVIE = 272,
+ tNEXT = 273,
+ tOF = 274,
+ tPREVIOUS = 275,
+ tPUT = 276,
+ tSET = 277,
+ tTHEN = 278,
+ tTO = 279
};
#endif
/* Tokens. */
@@ -94,19 +97,22 @@
#define FLOAT 261
#define VAR 262
#define STRING 263
-#define tFRAME 264
-#define tGO 265
-#define tINTO 266
-#define tLOOP 267
-#define tMCI 268
-#define tMCIWAIT 269
-#define tMOVIE 270
-#define tNEXT 271
-#define tOF 272
-#define tPREVIOUS 273
-#define tPUT 274
-#define tSET 275
-#define tTO 276
+#define tIF 264
+#define tEND 265
+#define tFRAME 266
+#define tGO 267
+#define tINTO 268
+#define tLOOP 269
+#define tMCI 270
+#define tMCIWAIT 271
+#define tMOVIE 272
+#define tNEXT 273
+#define tOF 274
+#define tPREVIOUS 275
+#define tPUT 276
+#define tSET 277
+#define tTHEN 278
+#define tTO 279
@@ -157,7 +163,7 @@ typedef union YYSTYPE
int code;
}
/* Line 193 of yacc.c. */
-#line 161 "engines/director/lingo/lingo-gr.cpp"
+#line 167 "engines/director/lingo/lingo-gr.cpp"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
@@ -170,7 +176,7 @@ typedef union YYSTYPE
/* Line 216 of yacc.c. */
-#line 174 "engines/director/lingo/lingo-gr.cpp"
+#line 180 "engines/director/lingo/lingo-gr.cpp"
#ifdef short
# undef short
@@ -383,22 +389,22 @@ union yyalloc
#endif
/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 36
+#define YYFINAL 38
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 75
+#define YYLAST 89
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 31
+#define YYNTOKENS 34
/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 10
+#define YYNNTS 14
/* YYNRULES -- Number of rules. */
-#define YYNRULES 39
+#define YYNRULES 46
/* YYNRULES -- Number of states. */
-#define YYNSTATES 65
+#define YYNSTATES 77
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 276
+#define YYMAXUTOK 279
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -407,12 +413,12 @@ union yyalloc
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 28, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 31, 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, 27, 2, 2,
- 29, 30, 25, 23, 2, 24, 2, 26, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 30, 2, 2,
+ 32, 33, 28, 26, 2, 27, 2, 29, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 22, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 25, 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, 2,
@@ -433,7 +439,7 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
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
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
};
#if YYDEBUG
@@ -442,35 +448,39 @@ static const yytype_uint8 yytranslate[] =
static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 7, 9, 10, 12, 14, 16, 18,
- 20, 21, 26, 31, 36, 38, 40, 42, 46, 50,
- 54, 58, 61, 64, 68, 71, 74, 76, 79, 82,
- 85, 88, 92, 95, 99, 102, 105, 107, 111, 114
+ 20, 21, 26, 31, 36, 38, 46, 48, 50, 54,
+ 58, 62, 66, 69, 72, 76, 78, 80, 81, 82,
+ 85, 88, 91, 94, 96, 99, 102, 105, 108, 112,
+ 115, 119, 122, 125, 127, 131, 134
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
- 32, 0, -1, 33, 28, 32, -1, 33, -1, -1,
- 37, -1, 34, -1, 35, -1, 36, -1, 1, -1,
- -1, 19, 36, 11, 7, -1, 20, 7, 22, 36,
- -1, 20, 7, 21, 36, -1, 36, -1, 5, -1,
- 7, -1, 36, 23, 36, -1, 36, 24, 36, -1,
- 36, 25, 36, -1, 36, 26, 36, -1, 23, 36,
- -1, 24, 36, -1, 29, 36, 30, -1, 13, 8,
- -1, 14, 7, -1, 38, -1, 10, 12, -1, 10,
- 16, -1, 10, 18, -1, 10, 39, -1, 10, 39,
- 40, -1, 10, 40, -1, 21, 9, 8, -1, 9,
- 8, -1, 21, 8, -1, 8, -1, 17, 15, 8,
- -1, 15, 8, -1, 21, 15, 8, -1
+ 35, 0, -1, 36, 31, 35, -1, 36, -1, -1,
+ 44, -1, 37, -1, 38, -1, 39, -1, 1, -1,
+ -1, 21, 39, 13, 7, -1, 22, 7, 25, 39,
+ -1, 22, 7, 24, 39, -1, 39, -1, 41, 40,
+ 23, 43, 42, 10, 9, -1, 5, -1, 7, -1,
+ 39, 26, 39, -1, 39, 27, 39, -1, 39, 28,
+ 39, -1, 39, 29, 39, -1, 26, 39, -1, 27,
+ 39, -1, 32, 39, 33, -1, 39, -1, 9, -1,
+ -1, -1, 43, 31, -1, 43, 38, -1, 15, 8,
+ -1, 16, 7, -1, 45, -1, 12, 14, -1, 12,
+ 18, -1, 12, 20, -1, 12, 46, -1, 12, 46,
+ 47, -1, 12, 47, -1, 24, 11, 8, -1, 11,
+ 8, -1, 24, 8, -1, 8, -1, 19, 17, 8,
+ -1, 17, 8, -1, 24, 17, 8, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
- 0, 88, 88, 89, 92, 93, 94, 95, 96, 97,
- 98, 101, 102, 103, 106, 109, 110, 111, 112, 113,
- 114, 115, 116, 117, 120, 121, 122, 133, 134, 135,
- 136, 137, 138, 141, 142, 143, 144, 147, 148, 149
+ 0, 89, 89, 90, 93, 94, 95, 96, 97, 98,
+ 99, 102, 103, 104, 107, 108, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 127, 129, 131, 133, 134,
+ 135, 138, 139, 140, 151, 152, 153, 154, 155, 156,
+ 159, 160, 161, 162, 165, 166, 167
};
#endif
@@ -480,11 +490,12 @@ static const yytype_uint8 yyrline[] =
static const char *const yytname[] =
{
"$end", "error", "$undefined", "UNARY", "UNDEF", "INT", "FLOAT", "VAR",
- "STRING", "tFRAME", "tGO", "tINTO", "tLOOP", "tMCI", "tMCIWAIT",
- "tMOVIE", "tNEXT", "tOF", "tPREVIOUS", "tPUT", "tSET", "tTO", "'='",
- "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('", "')'", "$accept",
- "program", "programline", "assign", "statement", "expr", "func",
- "gotofunc", "gotoframe", "gotomovie", 0
+ "STRING", "tIF", "tEND", "tFRAME", "tGO", "tINTO", "tLOOP", "tMCI",
+ "tMCIWAIT", "tMOVIE", "tNEXT", "tOF", "tPREVIOUS", "tPUT", "tSET",
+ "tTHEN", "tTO", "'='", "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('",
+ "')'", "$accept", "program", "programline", "assign", "stmt", "expr",
+ "cond", "if", "end", "stmtlist", "func", "gotofunc", "gotoframe",
+ "gotomovie", 0
};
#endif
@@ -495,27 +506,29 @@ 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, 61, 43, 45, 42, 47, 37, 10, 40,
- 41
+ 275, 276, 277, 278, 279, 61, 43, 45, 42, 47,
+ 37, 10, 40, 41
};
# endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
- 0, 31, 32, 32, 33, 33, 33, 33, 33, 33,
- 33, 34, 34, 34, 35, 36, 36, 36, 36, 36,
- 36, 36, 36, 36, 37, 37, 37, 38, 38, 38,
- 38, 38, 38, 39, 39, 39, 39, 40, 40, 40
+ 0, 34, 35, 35, 36, 36, 36, 36, 36, 36,
+ 36, 37, 37, 37, 38, 38, 39, 39, 39, 39,
+ 39, 39, 39, 39, 39, 40, 41, 42, 43, 43,
+ 43, 44, 44, 44, 45, 45, 45, 45, 45, 45,
+ 46, 46, 46, 46, 47, 47, 47
};
/* 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, 1, 3, 3, 3,
- 3, 2, 2, 3, 2, 2, 1, 2, 2, 2,
- 2, 3, 2, 3, 2, 2, 1, 3, 2, 3
+ 0, 4, 4, 4, 1, 7, 1, 1, 3, 3,
+ 3, 3, 2, 2, 3, 1, 1, 0, 0, 2,
+ 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
@@ -523,39 +536,43 @@ static const yytype_uint8 yyr2[] =
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
- 0, 9, 15, 16, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 3, 6, 7, 8, 5, 26, 36,
- 0, 27, 0, 28, 0, 29, 0, 30, 32, 24,
- 25, 0, 0, 21, 22, 0, 1, 0, 0, 0,
- 0, 0, 34, 38, 0, 35, 0, 0, 0, 31,
- 0, 0, 0, 23, 2, 17, 18, 19, 20, 37,
- 33, 39, 11, 13, 12
+ 0, 9, 16, 17, 26, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 3, 6, 7, 8, 0, 5,
+ 33, 43, 0, 34, 0, 35, 0, 36, 0, 37,
+ 39, 31, 32, 0, 0, 22, 23, 0, 1, 0,
+ 0, 0, 0, 0, 25, 0, 41, 45, 0, 42,
+ 0, 0, 0, 38, 0, 0, 0, 24, 2, 18,
+ 19, 20, 21, 28, 44, 40, 46, 11, 13, 12,
+ 27, 29, 30, 14, 0, 0, 15
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
- -1, 12, 13, 14, 15, 16, 17, 18, 27, 28
+ -1, 13, 14, 15, 16, 17, 45, 18, 74, 70,
+ 19, 20, 29, 30
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
-#define YYPACT_NINF -11
+#define YYPACT_NINF -19
static const yytype_int8 yypact[] =
{
- 36, -11, -11, -11, 54, 1, 15, 0, 21, 0,
- 0, 0, 30, 7, -11, -11, 28, -11, -11, -11,
- 32, -11, 34, -11, 33, -11, 2, -9, -11, -11,
- -11, -10, 5, -11, -11, -5, -11, 36, 0, 0,
- 0, 0, -11, -11, 39, -11, 49, 50, 46, -11,
- 60, 0, 0, -11, -11, 13, 13, -11, -11, -11,
- -11, -11, -11, 28, 28
+ 37, -19, -19, -19, -19, 5, -7, 8, 4, 13,
+ 4, 4, 4, 12, -10, -19, -19, 60, 4, -19,
+ -19, -19, 18, -19, 19, -19, 11, -19, -3, 61,
+ -19, -19, -19, 44, -18, -19, -19, 48, -19, 37,
+ 4, 4, 4, 4, 60, 17, -19, -19, 42, -19,
+ 43, 46, 28, -19, 49, 4, 4, -19, -19, -11,
+ -11, -19, -19, -19, -19, -19, -19, -19, 60, 60,
+ 34, -19, -19, 60, 45, 58, -19
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
- -11, 31, -11, -11, -11, -7, -11, -11, -11, 47
+ -19, 40, -19, -19, 14, -8, -19, -19, -19, -19,
+ -19, -19, -19, 53
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@@ -565,39 +582,42 @@ static const yytype_int8 yypgoto[] =
#define YYTABLE_NINF -5
static const yytype_int8 yytable[] =
{
- 31, 50, 33, 34, 35, 2, 22, 3, 24, 29,
- 45, 46, 48, 38, 39, 40, 41, 47, 38, 39,
- 40, 41, 30, 9, 10, 53, 51, 52, 32, 11,
- 36, 55, 56, 57, 58, 37, -4, 1, 40, 41,
- 42, 2, 43, 3, 63, 64, 4, 59, 44, 5,
- 6, 38, 39, 40, 41, 7, 8, 60, 61, 9,
- 10, 47, 19, 20, -4, 11, 21, 62, 54, 22,
- 23, 24, 25, 0, 49, 26
+ 33, 31, 35, 36, 37, 49, 55, 56, 50, 2,
+ 44, 3, 38, 21, 51, 32, 22, 42, 43, 23,
+ 34, 39, 24, 25, 26, 27, 46, 47, 48, 28,
+ 10, 11, 59, 60, 61, 62, 12, -4, 1, 2,
+ 63, 3, 2, 4, 3, 51, 4, 68, 69, 5,
+ 64, 65, 6, 7, 66, 75, 67, 54, 8, 9,
+ 10, 11, 73, 10, 11, 71, 12, 76, -4, 12,
+ 40, 41, 42, 43, 40, 41, 42, 43, 24, 58,
+ 26, 57, 53, 0, 72, 52, 40, 41, 42, 43
};
static const yytype_int8 yycheck[] =
{
- 7, 11, 9, 10, 11, 5, 15, 7, 17, 8,
- 8, 9, 21, 23, 24, 25, 26, 15, 23, 24,
- 25, 26, 7, 23, 24, 30, 21, 22, 7, 29,
- 0, 38, 39, 40, 41, 28, 0, 1, 25, 26,
- 8, 5, 8, 7, 51, 52, 10, 8, 15, 13,
- 14, 23, 24, 25, 26, 19, 20, 8, 8, 23,
- 24, 15, 8, 9, 28, 29, 12, 7, 37, 15,
- 16, 17, 18, -1, 27, 21
+ 8, 8, 10, 11, 12, 8, 24, 25, 11, 5,
+ 18, 7, 0, 8, 17, 7, 11, 28, 29, 14,
+ 7, 31, 17, 18, 19, 20, 8, 8, 17, 24,
+ 26, 27, 40, 41, 42, 43, 32, 0, 1, 5,
+ 23, 7, 5, 9, 7, 17, 9, 55, 56, 12,
+ 8, 8, 15, 16, 8, 10, 7, 13, 21, 22,
+ 26, 27, 70, 26, 27, 31, 32, 9, 31, 32,
+ 26, 27, 28, 29, 26, 27, 28, 29, 17, 39,
+ 19, 33, 29, -1, 70, 24, 26, 27, 28, 29
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
- 0, 1, 5, 7, 10, 13, 14, 19, 20, 23,
- 24, 29, 32, 33, 34, 35, 36, 37, 38, 8,
- 9, 12, 15, 16, 17, 18, 21, 39, 40, 8,
- 7, 36, 7, 36, 36, 36, 0, 28, 23, 24,
- 25, 26, 8, 8, 15, 8, 9, 15, 21, 40,
- 11, 21, 22, 30, 32, 36, 36, 36, 36, 8,
- 8, 8, 7, 36, 36
+ 0, 1, 5, 7, 9, 12, 15, 16, 21, 22,
+ 26, 27, 32, 35, 36, 37, 38, 39, 41, 44,
+ 45, 8, 11, 14, 17, 18, 19, 20, 24, 46,
+ 47, 8, 7, 39, 7, 39, 39, 39, 0, 31,
+ 26, 27, 28, 29, 39, 40, 8, 8, 17, 8,
+ 11, 17, 24, 47, 13, 24, 25, 33, 35, 39,
+ 39, 39, 39, 23, 8, 8, 8, 7, 39, 39,
+ 43, 31, 38, 39, 42, 10, 9
};
#define yyerrok (yyerrstatus = 0)
@@ -1412,163 +1432,193 @@ yyreduce:
switch (yyn)
{
case 6:
-#line 94 "engines/director/lingo/lingo-gr.y"
+#line 95 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_xpop); ;}
break;
case 8:
-#line 96 "engines/director/lingo/lingo-gr.y"
+#line 97 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_printtop); ;}
break;
case 9:
-#line 97 "engines/director/lingo/lingo-gr.y"
+#line 98 "engines/director/lingo/lingo-gr.y"
{ yyerrok; ;}
break;
case 11:
-#line 101 "engines/director/lingo/lingo-gr.y"
+#line 102 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(4) - (4)].s)->c_str()); g_lingo->code1(g_lingo->func_assign); (yyval.code) = (yyvsp[(2) - (4)].code); delete (yyvsp[(4) - (4)].s); ;}
break;
case 12:
-#line 102 "engines/director/lingo/lingo-gr.y"
+#line 103 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); g_lingo->code1(g_lingo->func_assign); (yyval.code) = (yyvsp[(4) - (4)].code); delete (yyvsp[(2) - (4)].s); ;}
break;
case 13:
-#line 103 "engines/director/lingo/lingo-gr.y"
+#line 104 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); g_lingo->code1(g_lingo->func_assign); (yyval.code) = (yyvsp[(4) - (4)].code); delete (yyvsp[(2) - (4)].s); ;}
break;
case 14:
-#line 106 "engines/director/lingo/lingo-gr.y"
+#line 107 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_xpop); ;}
break;
case 15:
-#line 109 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(g_lingo->func_constpush); inst i; WRITE_LE_UINT32(&i, (yyvsp[(1) - (1)].i)); (yyval.code) = g_lingo->code1(i); ;}
+#line 108 "engines/director/lingo/lingo-gr.y"
+ {
+ inst then, end;
+ WRITE_LE_UINT32(&then, (yyvsp[(4) - (7)].code));
+ WRITE_LE_UINT32(&end, (yyvsp[(5) - (7)].code));
+ (*g_lingo->_currentScript)[(yyvsp[(1) - (7)].code) + 1] = then; /* thenpart */
+ (*g_lingo->_currentScript)[(yyvsp[(1) - (7)].code) + 3] = end; ;}
break;
case 16:
-#line 110 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); (yyval.code) = g_lingo->code1(g_lingo->func_eval); delete (yyvsp[(1) - (1)].s); ;}
+#line 116 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(g_lingo->func_constpush); inst i; WRITE_LE_UINT32(&i, (yyvsp[(1) - (1)].i)); (yyval.code) = g_lingo->code1(i); ;}
break;
case 17:
-#line 111 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(g_lingo->func_add); ;}
+#line 117 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); (yyval.code) = g_lingo->code1(g_lingo->func_eval); delete (yyvsp[(1) - (1)].s); ;}
break;
case 18:
-#line 112 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(g_lingo->func_sub); ;}
+#line 118 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(g_lingo->func_add); ;}
break;
case 19:
-#line 113 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(g_lingo->func_mul); ;}
+#line 119 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(g_lingo->func_sub); ;}
break;
case 20:
-#line 114 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(g_lingo->func_div); ;}
+#line 120 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(g_lingo->func_mul); ;}
break;
case 21:
-#line 115 "engines/director/lingo/lingo-gr.y"
- { (yyval.code) = (yyvsp[(2) - (2)].code); ;}
+#line 121 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(g_lingo->func_div); ;}
break;
case 22:
-#line 116 "engines/director/lingo/lingo-gr.y"
- { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->func_negate); ;}
+#line 122 "engines/director/lingo/lingo-gr.y"
+ { (yyval.code) = (yyvsp[(2) - (2)].code); ;}
break;
case 23:
-#line 117 "engines/director/lingo/lingo-gr.y"
- { (yyval.code) = (yyvsp[(2) - (3)].code); ;}
+#line 123 "engines/director/lingo/lingo-gr.y"
+ { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->func_negate); ;}
break;
case 24:
-#line 120 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(g_lingo->func_mci); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
+#line 124 "engines/director/lingo/lingo-gr.y"
+ { (yyval.code) = (yyvsp[(2) - (3)].code); ;}
break;
case 25:
-#line 121 "engines/director/lingo/lingo-gr.y"
- { g_lingo->code1(g_lingo->func_mciwait); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
+#line 127 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(STOP); ;}
+ break;
+
+ case 26:
+#line 129 "engines/director/lingo/lingo-gr.y"
+ { (yyval.code) = g_lingo->code1(g_lingo->func_ifcode); g_lingo->code3(STOP,STOP,STOP); ;}
break;
case 27:
+#line 131 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(STOP); (yyval.code) = g_lingo->_currentScript->size(); ;}
+ break;
+
+ case 28:
#line 133 "engines/director/lingo/lingo-gr.y"
+ { (yyval.code) = g_lingo->_currentScript->size(); ;}
+ break;
+
+ case 31:
+#line 138 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(g_lingo->func_mci); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
+ break;
+
+ case 32:
+#line 139 "engines/director/lingo/lingo-gr.y"
+ { g_lingo->code1(g_lingo->func_mciwait); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
+ break;
+
+ case 34:
+#line 151 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_gotoloop); ;}
break;
- case 28:
-#line 134 "engines/director/lingo/lingo-gr.y"
+ case 35:
+#line 152 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_gotonext); ;}
break;
- case 29:
-#line 135 "engines/director/lingo/lingo-gr.y"
+ case 36:
+#line 153 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_gotoprevious); ;}
break;
- case 30:
-#line 136 "engines/director/lingo/lingo-gr.y"
+ case 37:
+#line 154 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_goto); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); g_lingo->codeString(""); delete (yyvsp[(2) - (2)].s); ;}
break;
- case 31:
-#line 137 "engines/director/lingo/lingo-gr.y"
+ case 38:
+#line 155 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_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 32:
-#line 138 "engines/director/lingo/lingo-gr.y"
+ case 39:
+#line 156 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_goto); g_lingo->codeString(""); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
break;
- case 33:
-#line 141 "engines/director/lingo/lingo-gr.y"
+ case 40:
+#line 159 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(3) - (3)].s); ;}
break;
- case 34:
-#line 142 "engines/director/lingo/lingo-gr.y"
+ case 41:
+#line 160 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(2) - (2)].s); ;}
break;
- case 35:
-#line 143 "engines/director/lingo/lingo-gr.y"
+ case 42:
+#line 161 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(2) - (2)].s); ;}
break;
- case 36:
-#line 144 "engines/director/lingo/lingo-gr.y"
+ case 43:
+#line 162 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(1) - (1)].s); ;}
break;
- case 37:
-#line 147 "engines/director/lingo/lingo-gr.y"
+ case 44:
+#line 165 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(3) - (3)].s); ;}
break;
- case 38:
-#line 148 "engines/director/lingo/lingo-gr.y"
+ case 45:
+#line 166 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(2) - (2)].s); ;}
break;
- case 39:
-#line 149 "engines/director/lingo/lingo-gr.y"
+ case 46:
+#line 167 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(3) - (3)].s); ;}
break;
/* Line 1267 of yacc.c. */
-#line 1572 "engines/director/lingo/lingo-gr.cpp"
+#line 1622 "engines/director/lingo/lingo-gr.cpp"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1782,6 +1832,6 @@ yyreturn:
}
-#line 179 "engines/director/lingo/lingo-gr.y"
+#line 197 "engines/director/lingo/lingo-gr.y"
diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h
index eb90b75b77..6261f6ce91 100644
--- a/engines/director/lingo/lingo-gr.h
+++ b/engines/director/lingo/lingo-gr.h
@@ -45,19 +45,22 @@
FLOAT = 261,
VAR = 262,
STRING = 263,
- tFRAME = 264,
- tGO = 265,
- tINTO = 266,
- tLOOP = 267,
- tMCI = 268,
- tMCIWAIT = 269,
- tMOVIE = 270,
- tNEXT = 271,
- tOF = 272,
- tPREVIOUS = 273,
- tPUT = 274,
- tSET = 275,
- tTO = 276
+ tIF = 264,
+ tEND = 265,
+ tFRAME = 266,
+ tGO = 267,
+ tINTO = 268,
+ tLOOP = 269,
+ tMCI = 270,
+ tMCIWAIT = 271,
+ tMOVIE = 272,
+ tNEXT = 273,
+ tOF = 274,
+ tPREVIOUS = 275,
+ tPUT = 276,
+ tSET = 277,
+ tTHEN = 278,
+ tTO = 279
};
#endif
/* Tokens. */
@@ -67,19 +70,22 @@
#define FLOAT 261
#define VAR 262
#define STRING 263
-#define tFRAME 264
-#define tGO 265
-#define tINTO 266
-#define tLOOP 267
-#define tMCI 268
-#define tMCIWAIT 269
-#define tMOVIE 270
-#define tNEXT 271
-#define tOF 272
-#define tPREVIOUS 273
-#define tPUT 274
-#define tSET 275
-#define tTO 276
+#define tIF 264
+#define tEND 265
+#define tFRAME 266
+#define tGO 267
+#define tINTO 268
+#define tLOOP 269
+#define tMCI 270
+#define tMCIWAIT 271
+#define tMOVIE 272
+#define tNEXT 273
+#define tOF 274
+#define tPREVIOUS 275
+#define tPUT 276
+#define tSET 277
+#define tTHEN 278
+#define tTO 279
@@ -94,7 +100,7 @@ typedef union YYSTYPE
int code;
}
/* Line 1529 of yacc.c. */
-#line 98 "engines/director/lingo/lingo-gr.hpp"
+#line 104 "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 0781bf8e29..21f3b4404d 100644
--- a/engines/director/lingo/lingo-gr.y
+++ b/engines/director/lingo/lingo-gr.y
@@ -42,7 +42,7 @@
// IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
// THIS SOFTWARE.
-
+
%debug
@@ -73,9 +73,10 @@ using namespace Director;
%token<i> INT
%token<f> FLOAT
%token<s> VAR STRING
-%token tFRAME tGO tINTO tLOOP tMCI tMCIWAIT tMOVIE tNEXT tOF tPREVIOUS tPUT tSET tTO
+%token tIF tEND tFRAME tGO tINTO tLOOP tMCI tMCIWAIT tMOVIE tNEXT tOF tPREVIOUS
+%token tPUT tSET tTHEN tTO
-%type<code> assign expr
+%type<code> assign cond expr if end stmtlist
%type<s> gotoframe gotomovie
%right '='
@@ -92,7 +93,7 @@ program: programline '\n' program
programline:
| func
| assign { g_lingo->code1(g_lingo->func_xpop); }
- | statement
+ | stmt
| expr { g_lingo->code1(g_lingo->func_printtop); }
| error { yyerrok; }
| /* empty */
@@ -103,7 +104,13 @@ assign: tPUT expr tINTO VAR { g_lingo->code1(g_lingo->func_varpush); g_lingo->c
| tSET VAR tTO expr { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString($2->c_str()); g_lingo->code1(g_lingo->func_assign); $$ = $4; delete $2; }
;
-statement: expr { g_lingo->code1(g_lingo->func_xpop); }
+stmt: expr { g_lingo->code1(g_lingo->func_xpop); }
+ | if cond tTHEN stmtlist end tEND tIF {
+ inst then, end;
+ WRITE_LE_UINT32(&then, $4);
+ WRITE_LE_UINT32(&end, $5);
+ (*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
+ (*g_lingo->_currentScript)[$1 + 3] = end; } /* end, if cond fails */
;
expr: INT { g_lingo->code1(g_lingo->func_constpush); inst i; WRITE_LE_UINT32(&i, $1); $$ = g_lingo->code1(i); };
@@ -117,6 +124,17 @@ expr: INT { g_lingo->code1(g_lingo->func_constpush); inst i; WRITE_LE_UINT3
| '(' expr ')' { $$ = $2; }
;
+cond: expr { g_lingo->code1(STOP); }
+ ;
+if: tIF { $$ = g_lingo->code1(g_lingo->func_ifcode); g_lingo->code3(STOP,STOP,STOP); }
+ ;
+end: /* nothing */ { g_lingo->code1(STOP); $$ = g_lingo->_currentScript->size(); }
+ ;
+stmtlist: /* nothing */ { $$ = g_lingo->_currentScript->size(); }
+ | stmtlist '\n'
+ | stmtlist stmt
+ ;
+
func: tMCI STRING { g_lingo->code1(g_lingo->func_mci); g_lingo->codeString($2->c_str()); delete $2; }
| tMCIWAIT VAR { g_lingo->code1(g_lingo->func_mciwait); g_lingo->codeString($2->c_str()); delete $2; }
| gotofunc
diff --git a/engines/director/lingo/lingo-lex.cpp b/engines/director/lingo/lingo-lex.cpp
index 8383d0c385..ef0fe50832 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 23
-#define YY_END_OF_BUFFER 24
+#define YY_NUM_RULES 26
+#define YY_END_OF_BUFFER 27
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -373,16 +373,16 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[72] =
+static yyconst flex_int16_t yy_accept[79] =
{ 0,
- 0, 0, 24, 23, 3, 21, 23, 20, 20, 19,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 2, 2, 3, 21, 0, 22, 1, 18, 19,
- 17, 17, 5, 17, 17, 17, 17, 17, 12, 17,
- 17, 17, 16, 1, 18, 17, 17, 17, 8, 17,
- 17, 17, 14, 15, 17, 6, 7, 17, 17, 11,
- 17, 4, 17, 10, 17, 17, 17, 9, 17, 13,
- 0
+ 0, 0, 27, 26, 3, 24, 26, 23, 23, 22,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 2, 2, 3, 24, 0, 25, 1, 21,
+ 22, 20, 20, 20, 7, 4, 20, 20, 20, 20,
+ 20, 14, 20, 20, 20, 20, 19, 1, 21, 5,
+ 20, 20, 20, 10, 20, 20, 20, 16, 17, 20,
+ 20, 8, 9, 20, 20, 13, 20, 18, 6, 20,
+ 12, 20, 20, 20, 11, 20, 15, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -396,10 +396,10 @@ static yyconst flex_int32_t yy_ec[256] =
7, 1, 1, 1, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 1, 1, 1, 7, 11, 1, 12, 11, 13, 11,
+ 1, 1, 1, 7, 11, 1, 12, 11, 13, 14,
- 14, 15, 16, 11, 17, 11, 11, 18, 19, 20,
- 21, 22, 11, 23, 24, 25, 26, 27, 28, 29,
+ 15, 16, 17, 18, 19, 11, 11, 20, 21, 22,
+ 23, 24, 11, 25, 26, 27, 28, 29, 30, 31,
11, 11, 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,
@@ -417,71 +417,76 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst flex_int32_t yy_meta[30] =
+static yyconst flex_int32_t yy_meta[32] =
{ 0,
1, 1, 2, 3, 1, 1, 1, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4
} ;
-static yyconst flex_int16_t yy_base[75] =
+static yyconst flex_int16_t yy_base[82] =
{ 0,
- 0, 28, 91, 92, 88, 28, 83, 92, 80, 25,
- 0, 64, 65, 65, 63, 23, 69, 67, 14, 67,
- 59, 77, 92, 76, 35, 71, 92, 0, 66, 32,
- 0, 63, 0, 49, 52, 55, 44, 41, 0, 55,
- 43, 42, 0, 0, 56, 46, 43, 41, 34, 44,
- 35, 32, 0, 0, 44, 0, 0, 45, 42, 0,
- 38, 0, 37, 0, 32, 26, 24, 0, 22, 0,
- 92, 44, 39, 48
+ 0, 30, 99, 100, 96, 30, 91, 100, 88, 27,
+ 0, 73, 69, 70, 22, 69, 26, 76, 74, 15,
+ 74, 23, 86, 100, 85, 44, 80, 100, 0, 75,
+ 41, 0, 70, 71, 0, 0, 55, 58, 61, 50,
+ 47, 0, 62, 49, 48, 59, 0, 0, 63, 0,
+ 51, 48, 46, 39, 49, 40, 37, 0, 0, 43,
+ 49, 0, 0, 51, 47, 0, 42, 0, 0, 41,
+ 0, 35, 30, 25, 0, 19, 0, 100, 51, 38,
+ 55
} ;
-static yyconst flex_int16_t yy_def[75] =
+static yyconst flex_int16_t yy_def[82] =
{ 0,
- 71, 1, 71, 71, 71, 71, 72, 71, 71, 71,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 71, 71, 71, 71, 72, 71, 74, 71, 71,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 74, 71, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
- 0, 71, 71, 71
+ 78, 1, 78, 78, 78, 78, 79, 78, 78, 78,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 78, 78, 78, 78, 79, 78, 81, 78,
+ 78, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 81, 78, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 0, 78, 78,
+ 78
} ;
-static yyconst flex_int16_t yy_nxt[122] =
+static yyconst flex_int16_t yy_nxt[132] =
{ 0,
4, 5, 6, 6, 4, 7, 8, 9, 4, 10,
- 11, 11, 11, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 11, 20, 21, 11, 11, 11, 11, 22,
- 25, 25, 23, 29, 30, 36, 40, 25, 25, 41,
- 29, 30, 31, 37, 26, 70, 26, 26, 44, 69,
- 68, 44, 67, 66, 65, 64, 63, 62, 61, 60,
- 59, 58, 57, 56, 55, 45, 54, 53, 52, 51,
- 50, 49, 48, 47, 46, 45, 27, 24, 24, 43,
- 42, 39, 38, 35, 34, 33, 32, 28, 27, 24,
- 71, 3, 71, 71, 71, 71, 71, 71, 71, 71,
-
- 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
- 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
- 71
+ 11, 11, 11, 11, 12, 13, 14, 11, 15, 16,
+ 17, 18, 19, 20, 11, 21, 22, 11, 11, 11,
+ 11, 23, 26, 26, 24, 30, 31, 36, 39, 43,
+ 46, 32, 44, 37, 77, 47, 26, 26, 40, 30,
+ 31, 27, 76, 27, 27, 48, 75, 74, 48, 73,
+ 72, 71, 70, 69, 68, 67, 66, 65, 64, 63,
+ 62, 61, 49, 60, 59, 58, 57, 56, 55, 54,
+ 53, 52, 51, 50, 49, 28, 25, 25, 45, 42,
+ 41, 38, 35, 34, 33, 29, 28, 25, 78, 3,
+
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78
} ;
-static yyconst flex_int16_t yy_chk[122] =
+static yyconst flex_int16_t yy_chk[132] =
{ 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, 2,
- 6, 6, 2, 10, 10, 16, 19, 25, 25, 19,
- 30, 30, 73, 16, 72, 69, 72, 72, 74, 67,
- 66, 74, 65, 63, 61, 59, 58, 55, 52, 51,
- 50, 49, 48, 47, 46, 45, 42, 41, 40, 38,
- 37, 36, 35, 34, 32, 29, 26, 24, 22, 21,
- 20, 18, 17, 15, 14, 13, 12, 9, 7, 5,
- 3, 71, 71, 71, 71, 71, 71, 71, 71, 71,
-
- 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
- 71, 71, 71, 71, 71, 71, 71, 71, 71, 71,
- 71
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 6, 6, 2, 10, 10, 15, 17, 20,
+ 22, 80, 20, 15, 76, 22, 26, 26, 17, 31,
+ 31, 79, 74, 79, 79, 81, 73, 72, 81, 70,
+ 67, 65, 64, 61, 60, 57, 56, 55, 54, 53,
+ 52, 51, 49, 46, 45, 44, 43, 41, 40, 39,
+ 38, 37, 34, 33, 30, 27, 25, 23, 21, 19,
+ 18, 16, 14, 13, 12, 9, 7, 5, 3, 78,
+
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78
} ;
static yy_state_type yy_last_accepting_state;
@@ -531,7 +536,7 @@ char *yytext;
int yyparse();
-#line 535 "engines/director/lingo/lingo-lex.cpp"
+#line 540 "engines/director/lingo/lingo-lex.cpp"
#define INITIAL 0
@@ -719,7 +724,7 @@ YY_DECL
#line 45 "engines/director/lingo/lingo-lex.l"
-#line 723 "engines/director/lingo/lingo-lex.cpp"
+#line 728 "engines/director/lingo/lingo-lex.cpp"
if ( !(yy_init) )
{
@@ -773,13 +778,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 >= 72 )
+ if ( yy_current_state >= 79 )
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] != 92 );
+ while ( yy_base[yy_current_state] != 100 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -821,105 +826,120 @@ YY_RULE_SETUP
case 4:
YY_RULE_SETUP
#line 51 "engines/director/lingo/lingo-lex.l"
-{ return tFRAME; }
+{ return tIF; }
YY_BREAK
case 5:
YY_RULE_SETUP
#line 52 "engines/director/lingo/lingo-lex.l"
-{ return tGO; }
+{ return tEND; }
YY_BREAK
case 6:
YY_RULE_SETUP
#line 53 "engines/director/lingo/lingo-lex.l"
-{ return tINTO; }
+{ return tFRAME; }
YY_BREAK
case 7:
YY_RULE_SETUP
#line 54 "engines/director/lingo/lingo-lex.l"
-{ return tLOOP; }
+{ return tGO; }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 55 "engines/director/lingo/lingo-lex.l"
-{ return tMCI; }
+{ return tINTO; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 56 "engines/director/lingo/lingo-lex.l"
-{ return tMCIWAIT; }
+{ return tLOOP; }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 57 "engines/director/lingo/lingo-lex.l"
-{ return tMOVIE; }
+{ return tMCI; }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 58 "engines/director/lingo/lingo-lex.l"
-{ return tNEXT; }
+{ return tMCIWAIT; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 59 "engines/director/lingo/lingo-lex.l"
-{ return tOF; }
+{ return tMOVIE; }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 60 "engines/director/lingo/lingo-lex.l"
-{ return tPREVIOUS; }
+{ return tNEXT; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 61 "engines/director/lingo/lingo-lex.l"
-{ return tPUT; }
+{ return tOF; }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 62 "engines/director/lingo/lingo-lex.l"
-{ return tSET; }
+{ return tPREVIOUS; }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 63 "engines/director/lingo/lingo-lex.l"
-{ return tTO; }
+{ return tPUT; }
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 65 "engines/director/lingo/lingo-lex.l"
-{ yylval.s = new Common::String(yytext); return VAR; }
+#line 64 "engines/director/lingo/lingo-lex.l"
+{ return tSET; }
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 66 "engines/director/lingo/lingo-lex.l"
-{ yylval.f = atof(yytext); return FLOAT; }
+#line 65 "engines/director/lingo/lingo-lex.l"
+{ return tTHEN; }
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 67 "engines/director/lingo/lingo-lex.l"
-{ yylval.i = strtol(yytext, NULL, 10); return INT; }
+#line 66 "engines/director/lingo/lingo-lex.l"
+{ return tTO; }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 68 "engines/director/lingo/lingo-lex.l"
-{ return *yytext; }
+{ yylval.s = new Common::String(yytext); return VAR; }
YY_BREAK
case 21:
-/* rule 21 can match eol */
YY_RULE_SETUP
#line 69 "engines/director/lingo/lingo-lex.l"
-{ return '\n'; }
+{ yylval.f = atof(yytext); return FLOAT; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 70 "engines/director/lingo/lingo-lex.l"
-{ yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; }
+{ yylval.i = strtol(yytext, NULL, 10); return INT; }
YY_BREAK
case 23:
YY_RULE_SETUP
+#line 71 "engines/director/lingo/lingo-lex.l"
+{ return *yytext; }
+ YY_BREAK
+case 24:
+/* rule 24 can match eol */
+YY_RULE_SETUP
#line 72 "engines/director/lingo/lingo-lex.l"
+{ return '\n'; }
+ YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 73 "engines/director/lingo/lingo-lex.l"
+{ yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; }
+ YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 75 "engines/director/lingo/lingo-lex.l"
ECHO;
YY_BREAK
-#line 923 "engines/director/lingo/lingo-lex.cpp"
+#line 943 "engines/director/lingo/lingo-lex.cpp"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -1212,7 +1232,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 >= 72 )
+ if ( yy_current_state >= 79 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1240,11 +1260,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 >= 72 )
+ if ( yy_current_state >= 79 )
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 == 71);
+ yy_is_jam = (yy_current_state == 78);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -1919,7 +1939,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables"
-#line 72 "engines/director/lingo/lingo-lex.l"
+#line 75 "engines/director/lingo/lingo-lex.l"
diff --git a/engines/director/lingo/lingo-lex.l b/engines/director/lingo/lingo-lex.l
index 5823a36160..a6e644a5e5 100644
--- a/engines/director/lingo/lingo-lex.l
+++ b/engines/director/lingo/lingo-lex.l
@@ -48,6 +48,8 @@ whitespace [\t ]
^{whitespace}
[\t]+ { return ' '; }
+if { return tIF; }
+end { return tEND; }
frame { return tFRAME; }
go { return tGO; }
into { return tINTO; }
@@ -60,6 +62,7 @@ of { return tOF; }
previous { return tPREVIOUS; }
put { return tPUT; }
set { return tSET; }
+then { return tTHEN; }
to { return tTO; }
{variable} { yylval.s = new Common::String(yytext); return VAR; }
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 1572685bc3..25b449591e 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -130,9 +130,10 @@ void Lingo::executeScript(ScriptType type, uint16 id) {
return;
}
- for(_pc = &_scripts[type][id]->front(); *_pc != STOP;) {
- (*((++_pc)[-1]))();
- }
+ _currentScript = _scripts[type][id];
+ _pc = 0;
+
+ execute(_pc);
}
void Lingo::processEvent(LEvent event, int entityId) {
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 5341aff75f..d4a119053d 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -107,7 +107,7 @@ public:
void processEvent(LEvent event, int entityId);
- int code1(inst code) { _currentScript->push_back(code); return _currentScript->size(); }
+ int code1(inst code) { _currentScript->push_back(code); return _currentScript->size() - 1; }
int code2(inst code_1, inst code_2) { code1(code_1); return code1(code_2); }
int code3(inst code_1, inst code_2, inst code_3) { code1(code_1); code1(code_2); return code1(code_3); }
int codeString(const char *s);
@@ -118,6 +118,8 @@ public:
}
public:
+ void execute(int pc);
+
static void func_xpop();
static void func_printtop();
static void func_add();
@@ -130,6 +132,8 @@ public:
static void func_assign();
bool verify(Symbol *s);
static void func_eval();
+ static void func_ifcode();
+
static void func_mci();
static void func_mciwait();
static void func_goto();
@@ -141,6 +145,9 @@ public:
void exec_mciwait(Common::String &s);
void exec_goto(Common::String &frame, Common::String &movie);
+public:
+ ScriptData *_currentScript;
+
private:
int parse(const char *code);
void push(Datum d);
@@ -150,11 +157,10 @@ private:
Common::HashMap<Common::String, Audio::AudioStream *> _audioAliases;
ScriptHash _scripts[kMaxScriptType + 1];
- ScriptData *_currentScript;
Common::HashMap<Common::String, Symbol *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _vars;
- inst *_pc;
+ int _pc;
StackData _stack;