diff options
author | Eugene Sandulenko | 2016-06-21 11:50:08 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 46d60a794170489f4db8fdd3be5f8ee373b397ec (patch) | |
tree | 95b3d453e7f6f691aeab29e141bd7103b3222398 /engines | |
parent | 8fb7aaf4a0e76db7d1a2516a00d6946e6ee44693 (diff) | |
download | scummvm-rg350-46d60a794170489f4db8fdd3be5f8ee373b397ec.tar.gz scummvm-rg350-46d60a794170489f4db8fdd3be5f8ee373b397ec.tar.bz2 scummvm-rg350-46d60a794170489f4db8fdd3be5f8ee373b397ec.zip |
DIRECTOR: Lingo: Implement 'repeat while' control keyword
Diffstat (limited to 'engines')
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 26 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.cpp | 488 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.h | 42 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.y | 46 | ||||
-rw-r--r-- | engines/director/lingo/lingo-lex.cpp | 192 | ||||
-rw-r--r-- | engines/director/lingo/lingo-lex.l | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 1 |
7 files changed, 436 insertions, 361 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 11804c2dc1..85da696a40 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -247,14 +247,36 @@ void Lingo::c_le() { g_lingo->push(d1); } +void Lingo::c_whilecode(void) { + Datum d; + int savepc = g_lingo->_pc; + + int body = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc]); + int end = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 1]); + + g_lingo->execute(savepc + 2); /* condition */ + d = g_lingo->pop(); + + while (d.val) { + g_lingo->execute(body); /* body */ + if (0 /* returning */) + break; + + g_lingo->execute(savepc + 2); /* 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 */ - int then = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc]); + int then = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc]); int elsep = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 1]); - int end = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 2]); + int end = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 2]); warning("cond: %d end: %d then: %d elesp: %d", savepc + 3, end, then, elsep); diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index 7d7bf1d41c..17109efb66 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -86,15 +86,17 @@ tOF = 275, tPREVIOUS = 276, tPUT = 277, - tSET = 278, - tTHEN = 279, - tTO = 280, - tGE = 281, - tLE = 282, - tGT = 283, - tLT = 284, - tEQ = 285, - tNEQ = 286 + tREPEAT = 278, + tSET = 279, + tTHEN = 280, + tTO = 281, + tWHILE = 282, + tGE = 283, + tLE = 284, + tGT = 285, + tLT = 286, + tEQ = 287, + tNEQ = 288 }; #endif /* Tokens. */ @@ -118,15 +120,17 @@ #define tOF 275 #define tPREVIOUS 276 #define tPUT 277 -#define tSET 278 -#define tTHEN 279 -#define tTO 280 -#define tGE 281 -#define tLE 282 -#define tGT 283 -#define tLT 284 -#define tEQ 285 -#define tNEQ 286 +#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 @@ -177,7 +181,7 @@ typedef union YYSTYPE int code; } /* Line 193 of yacc.c. */ -#line 181 "engines/director/lingo/lingo-gr.cpp" +#line 185 "engines/director/lingo/lingo-gr.cpp" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -190,7 +194,7 @@ typedef union YYSTYPE /* Line 216 of yacc.c. */ -#line 194 "engines/director/lingo/lingo-gr.cpp" +#line 198 "engines/director/lingo/lingo-gr.cpp" #ifdef short # undef short @@ -403,22 +407,22 @@ union yyalloc #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 40 +#define YYFINAL 43 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 205 +#define YYLAST 178 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 43 +#define YYNTOKENS 45 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 14 +#define YYNNTS 15 /* YYNRULES -- Number of rules. */ -#define YYNRULES 56 +#define YYNRULES 58 /* YYNRULES -- Number of states. */ -#define YYNSTATES 101 +#define YYNSTATES 111 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 286 +#define YYMAXUTOK 288 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -427,12 +431,12 @@ union yyalloc static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 38, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 40, 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, 37, 2, 2, - 41, 42, 35, 33, 2, 34, 2, 36, 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, 2, 2, 2, - 40, 32, 39, 2, 2, 2, 2, 2, 2, 2, + 44, 34, 43, 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, @@ -454,7 +458,7 @@ 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 + 25, 26, 27, 28, 29, 30, 31, 32, 33 }; #if YYDEBUG @@ -463,46 +467,47 @@ 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, 46, 57, 59, 61, - 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, - 102, 105, 109, 111, 115, 119, 121, 122, 123, 126, - 129, 132, 135, 138, 140, 143, 146, 149, 152, 156, - 159, 163, 166, 169, 171, 175, 178 + 20, 21, 26, 31, 36, 38, 46, 57, 66, 68, + 72, 76, 79, 81, 82, 83, 86, 89, 91, 93, + 95, 99, 103, 107, 111, 115, 119, 123, 127, 131, + 134, 137, 141, 144, 147, 150, 152, 155, 158, 161, + 164, 168, 171, 175, 178, 181, 183, 187, 190 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 44, 0, -1, 45, 38, 44, -1, 45, -1, -1, - 53, -1, 46, -1, 47, -1, 48, -1, 1, -1, - -1, 22, 48, 14, 7, -1, 23, 7, 32, 48, - -1, 23, 7, 25, 48, -1, 48, -1, 50, 49, - 24, 52, 51, 11, 9, -1, 50, 49, 24, 52, - 51, 10, 52, 51, 11, 9, -1, 5, -1, 7, - -1, 46, -1, 48, 33, 48, -1, 48, 34, 48, - -1, 48, 35, 48, -1, 48, 36, 48, -1, 48, - 39, 48, -1, 48, 40, 48, -1, 48, 31, 48, - -1, 48, 26, 48, -1, 48, 27, 48, -1, 33, - 48, -1, 34, 48, -1, 41, 48, 42, -1, 48, - -1, 48, 32, 48, -1, 41, 49, 42, -1, 9, - -1, -1, -1, 52, 38, -1, 52, 47, -1, 16, - 8, -1, 17, 7, -1, 22, 48, -1, 54, -1, - 13, 15, -1, 13, 19, -1, 13, 21, -1, 13, - 55, -1, 13, 55, 56, -1, 13, 56, -1, 25, - 12, 8, -1, 12, 8, -1, 25, 8, -1, 8, - -1, 20, 18, 8, -1, 18, 8, -1, 25, 18, - 8, -1 + 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, 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 }; /* 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, 115, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 139, 142, 143, 144, 146, 148, 150, 151, 152, - 155, 156, 157, 158, 169, 170, 171, 172, 173, 174, - 177, 178, 179, 180, 183, 184, 185 + 100, 103, 104, 105, 108, 109, 115, 127, 135, 136, + 137, 139, 141, 143, 145, 146, 147, 150, 151, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, + 163, 164, 167, 168, 169, 170, 181, 182, 183, 184, + 185, 186, 189, 190, 191, 192, 195, 196, 197 }; #endif @@ -514,10 +519,11 @@ 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", - "tSET", "tTHEN", "tTO", "tGE", "tLE", "tGT", "tLT", "tEQ", "tNEQ", "'='", - "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'>'", "'<'", "'('", "')'", - "$accept", "program", "programline", "asgn", "stmt", "expr", "cond", - "if", "end", "stmtlist", "func", "gotofunc", "gotoframe", "gotomovie", 0 + "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 }; #endif @@ -529,31 +535,31 @@ 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, 61, 43, 45, 42, 47, 37, 10, 62, - 60, 40, 41 + 285, 286, 287, 288, 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, 43, 44, 44, 45, 45, 45, 45, 45, 45, - 45, 46, 46, 46, 47, 47, 47, 48, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 49, 49, 49, 50, 51, 52, 52, 52, - 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, - 55, 55, 55, 55, 56, 56, 56 + 0, 45, 46, 46, 47, 47, 47, 47, 47, 47, + 47, 48, 48, 48, 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 }; /* 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, 7, 10, 1, 1, 1, + 0, 4, 4, 4, 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, 1, 3, 3, 1, 0, 0, 2, 2, - 2, 2, 2, 1, 2, 2, 2, 2, 3, 2, - 3, 2, 2, 1, 3, 2, 3 + 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 @@ -561,49 +567,51 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 9, 17, 18, 35, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 19, 7, 8, 0, 5, - 43, 53, 0, 44, 0, 45, 0, 46, 0, 47, - 49, 40, 41, 0, 19, 42, 0, 29, 30, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 32, 0, 51, 55, 0, 52, 0, 0, - 0, 48, 0, 0, 0, 0, 31, 2, 27, 28, - 26, 20, 21, 22, 23, 24, 25, 0, 0, 0, - 37, 54, 50, 56, 11, 13, 12, 34, 33, 36, - 38, 39, 14, 0, 37, 0, 36, 15, 0, 0, + 0, 9, 27, 28, 22, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3, 29, 7, 0, 0, + 8, 5, 45, 55, 0, 46, 0, 47, 0, 48, + 0, 49, 51, 42, 43, 0, 29, 44, 21, 0, + 39, 40, 0, 1, 0, 0, 0, 0, 18, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 53, 57, + 0, 54, 0, 0, 0, 50, 0, 0, 0, 0, + 41, 2, 0, 0, 0, 24, 0, 37, 38, 36, + 30, 31, 32, 33, 34, 35, 56, 52, 58, 11, + 13, 12, 24, 20, 23, 19, 23, 25, 26, 0, + 14, 0, 24, 0, 0, 23, 15, 17, 0, 0, 16 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 13, 14, 34, 16, 17, 53, 18, 93, 89, - 19, 20, 29, 30 + -1, 14, 15, 36, 98, 47, 18, 19, 99, 94, + 100, 21, 22, 31, 32 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -42 +#define YYPACT_NINF -61 static const yytype_int16 yypact[] = { - 45, -42, -42, -42, -42, 107, 0, 5, 70, 9, - 70, 70, 70, 7, -7, 11, -42, 148, 90, -42, - -42, -42, 22, -42, 24, -42, 15, -42, -3, -1, - -42, -42, -42, 70, -42, -13, 19, 165, 165, 120, - -42, 45, 70, 70, 70, 70, 70, 70, 70, 70, - 70, 90, 137, 29, -42, -42, 51, -42, 52, 55, - 46, -42, -13, 58, 70, 70, -42, -42, 148, 148, - 148, 159, 159, 165, 165, 148, 148, 103, 27, 70, - -42, -42, -42, -42, -42, 148, 148, -42, 148, 67, - -42, -42, 148, 18, -42, 57, 67, -42, 59, 64, - -42 + 58, -61, -61, -61, -61, 10, 26, -5, 2, 34, + 59, 2, 2, 2, 73, 44, 1, -61, 45, 65, + 122, -61, -61, -61, 77, -61, 96, -61, 90, -61, + 15, 150, -61, -61, -61, 2, -61, 74, -61, 71, + 134, 134, 98, -61, 58, 65, 65, 88, 110, 2, + 2, 2, 2, 2, 2, 2, 2, 2, -61, -61, + 108, -61, 117, 124, 119, -61, 74, 142, 2, 2, + -61, -61, 114, 127, 86, -61, 2, 122, 122, 122, + -23, -23, 134, 134, 122, 122, -61, -61, -61, -61, + 122, 122, -61, -61, 55, 122, 55, -61, -61, 6, + 122, 141, -61, 152, 148, 55, -61, -61, 153, 163, + -61 }; /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = +static const yytype_int16 yypgoto[] = { - -42, 39, -42, 6, -41, -8, 31, -42, -12, -9, - -42, -42, -42, 62 + -61, 129, -61, 3, 4, -6, -61, -61, -13, -60, + 0, -61, -61, -61, 143 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -613,52 +621,46 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -7 static const yytype_int8 yytable[] = { - 35, 63, 37, 38, 39, 57, 15, 40, 31, 58, - 52, -6, 32, 42, 43, 59, 36, 24, 44, 26, - 45, 46, 47, 48, 60, 62, 49, 50, 94, 95, - 54, 41, 55, 56, 68, 69, 70, 71, 72, 73, - 74, 75, 76, 77, 64, -4, 1, 15, 91, -6, - 2, 65, 3, 80, 4, 91, 85, 86, 5, 81, - 82, 6, 7, 83, 59, 84, 97, 8, 9, 87, - 99, 88, 2, 100, 3, 2, 4, 3, 10, 11, - 67, 92, 78, -4, 98, 96, 12, 0, 92, 33, - 9, 61, 33, 9, 0, 2, 0, 3, 0, 0, - 10, 11, 0, 10, 11, 90, 0, 0, 12, 0, - 0, 12, 33, 9, 0, 21, 0, 0, 0, 22, - 0, 0, 23, 10, 11, 24, 25, 26, 27, 42, - 43, 51, 28, 0, 44, 79, 45, 46, 47, 48, - 0, 0, 49, 50, 0, 66, 42, 43, 0, 0, - 0, 44, 0, 45, 46, 47, 48, 0, 0, 49, - 50, 0, 66, 42, 43, 0, 0, 0, 44, 79, - 45, 46, 47, 48, 42, 43, 49, 50, 0, 44, - 0, 45, 46, 47, 48, 42, 43, 49, 50, 0, - 44, 42, 43, 0, 47, 48, 44, 0, 49, 50, - 0, 0, 0, 0, 49, 50 + 20, -6, 34, 16, 17, 49, 50, 2, 37, 3, + 51, 40, 41, 42, 54, 55, 102, 103, 23, 48, + 56, 57, 24, 61, 35, 25, 10, 62, 26, 27, + 28, 29, 96, 63, 33, 66, 30, 11, 12, 72, + 73, -6, 105, 13, 20, 48, 74, 16, 17, 77, + 78, 79, 80, 81, 82, 83, 84, 85, -4, 1, + 2, 38, 3, 2, 4, 3, 39, 4, 90, 91, + 2, 5, 3, 43, 6, 7, 95, 35, 9, 10, + 8, 9, 10, 101, 44, 58, 45, 35, 67, 10, + 11, 12, 108, 11, 12, 97, 13, 68, -4, 13, + 11, 12, 49, 50, 59, 69, 46, 51, 60, 52, + 53, 54, 55, 75, 49, 50, 86, 56, 57, 51, + 76, 52, 53, 54, 55, 87, 49, 50, 70, 56, + 57, 51, 88, 52, 53, 54, 55, 63, 49, 50, + 70, 56, 57, 51, 76, 52, 53, 54, 55, 89, + 49, 50, 104, 56, 57, 51, 92, 52, 53, 54, + 55, 106, 49, 50, 109, 56, 57, 51, 26, 93, + 28, 107, 110, 71, 65, 0, 64, 56, 57 }; static const yytype_int8 yycheck[] = { - 8, 14, 10, 11, 12, 8, 0, 0, 8, 12, - 18, 0, 7, 26, 27, 18, 7, 18, 31, 20, - 33, 34, 35, 36, 25, 33, 39, 40, 10, 11, - 8, 38, 8, 18, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 25, 0, 1, 41, 89, 38, - 5, 32, 7, 24, 9, 96, 64, 65, 13, 8, - 8, 16, 17, 8, 18, 7, 9, 22, 23, 42, - 11, 79, 5, 9, 7, 5, 9, 7, 33, 34, - 41, 89, 51, 38, 96, 94, 41, -1, 96, 22, - 23, 29, 22, 23, -1, 5, -1, 7, -1, -1, - 33, 34, -1, 33, 34, 38, -1, -1, 41, -1, - -1, 41, 22, 23, -1, 8, -1, -1, -1, 12, - -1, -1, 15, 33, 34, 18, 19, 20, 21, 26, - 27, 41, 25, -1, 31, 32, 33, 34, 35, 36, - -1, -1, 39, 40, -1, 42, 26, 27, -1, -1, - -1, 31, -1, 33, 34, 35, 36, -1, -1, 39, - 40, -1, 42, 26, 27, -1, -1, -1, 31, 32, - 33, 34, 35, 36, 26, 27, 39, 40, -1, 31, - -1, 33, 34, 35, 36, 26, 27, 39, 40, -1, - 31, 26, 27, -1, 35, 36, 31, -1, 39, 40, - -1, -1, -1, -1, 39, 40 + 0, 0, 7, 0, 0, 28, 29, 5, 8, 7, + 33, 11, 12, 13, 37, 38, 10, 11, 8, 19, + 43, 44, 12, 8, 22, 15, 24, 12, 18, 19, + 20, 21, 92, 18, 8, 35, 26, 35, 36, 45, + 46, 40, 102, 41, 44, 45, 46, 44, 44, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 0, 1, + 5, 27, 7, 5, 9, 7, 7, 9, 68, 69, + 5, 13, 7, 0, 16, 17, 76, 22, 23, 24, + 22, 23, 24, 96, 40, 8, 41, 22, 14, 24, + 35, 36, 105, 35, 36, 40, 41, 26, 40, 41, + 35, 36, 28, 29, 8, 34, 41, 33, 18, 35, + 36, 37, 38, 25, 28, 29, 8, 43, 44, 33, + 34, 35, 36, 37, 38, 8, 28, 29, 42, 43, + 44, 33, 8, 35, 36, 37, 38, 18, 28, 29, + 42, 43, 44, 33, 34, 35, 36, 37, 38, 7, + 28, 29, 11, 43, 44, 33, 42, 35, 36, 37, + 38, 9, 28, 29, 11, 43, 44, 33, 18, 42, + 20, 23, 9, 44, 31, -1, 26, 43, 44 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -666,15 +668,16 @@ static const yytype_int8 yycheck[] = static const yytype_uint8 yystos[] = { 0, 1, 5, 7, 9, 13, 16, 17, 22, 23, - 33, 34, 41, 44, 45, 46, 47, 48, 50, 53, - 54, 8, 12, 15, 18, 19, 20, 21, 25, 55, - 56, 8, 7, 22, 46, 48, 7, 48, 48, 48, - 0, 38, 26, 27, 31, 33, 34, 35, 36, 39, - 40, 41, 48, 49, 8, 8, 18, 8, 12, 18, - 25, 56, 48, 14, 25, 32, 42, 44, 48, 48, - 48, 48, 48, 48, 48, 48, 48, 48, 49, 32, - 24, 8, 8, 8, 7, 48, 48, 42, 48, 52, - 38, 47, 48, 51, 10, 11, 52, 9, 51, 11, + 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, 53, 10, 11, 11, 54, 9, 23, 53, 11, 9 }; @@ -1547,183 +1550,198 @@ yyreduce: break; case 17: -#line 125 "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); ;} +#line 127 "engines/director/lingo/lingo-gr.y" + { + inst body, end; + WRITE_LE_UINT32(&body, (yyvsp[(5) - (8)].code)); + WRITE_LE_UINT32(&end, (yyvsp[(6) - (8)].code)); + (*g_lingo->_currentScript)[(yyvsp[(1) - (8)].code) + 1] = body; /* body of loop */ + (*g_lingo->_currentScript)[(yyvsp[(1) - (8)].code) + 2] = end; ;} break; case 18: -#line 126 "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); ;} +#line 135 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(STOP); ;} break; - case 20: -#line 128 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_add); ;} + case 19: +#line 136 "engines/director/lingo/lingo-gr.y" + { g_lingo->code2(g_lingo->c_eq, STOP); ;} break; case 21: -#line 129 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_sub); ;} +#line 139 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = g_lingo->code3(g_lingo->c_whilecode, STOP, STOP); ;} break; case 22: -#line 130 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_mul); ;} +#line 141 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = g_lingo->code1(g_lingo->c_ifcode); g_lingo->code3(STOP, STOP, STOP); ;} break; case 23: -#line 131 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_div); ;} +#line 143 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(STOP); (yyval.code) = g_lingo->_currentScript->size(); ;} break; case 24: -#line 132 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_gt); ;} - break; - - case 25: -#line 133 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_lt); ;} - break; - - case 26: -#line 134 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_neq); ;} +#line 145 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = g_lingo->_currentScript->size(); ;} break; case 27: -#line 135 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_ge); ;} +#line 150 "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 28: -#line 136 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_le); ;} - break; - - case 29: -#line 137 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = (yyvsp[(2) - (2)].code); ;} +#line 151 "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 30: -#line 138 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->c_negate); ;} +#line 153 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_add); ;} break; case 31: -#line 139 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = (yyvsp[(2) - (3)].code); ;} +#line 154 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_sub); ;} break; case 32: -#line 142 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(STOP); ;} +#line 155 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_mul); ;} break; case 33: -#line 143 "engines/director/lingo/lingo-gr.y" - { g_lingo->code2(g_lingo->c_eq, STOP); ;} +#line 156 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_div); ;} + break; + + case 34: +#line 157 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_gt); ;} break; case 35: -#line 146 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = g_lingo->code1(g_lingo->c_ifcode); g_lingo->code3(STOP,STOP,STOP); ;} +#line 158 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_lt); ;} break; case 36: -#line 148 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(STOP); (yyval.code) = g_lingo->_currentScript->size(); ;} +#line 159 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_neq); ;} break; case 37: -#line 150 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = g_lingo->_currentScript->size(); ;} +#line 160 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_ge); ;} + break; + + case 38: +#line 161 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_le); ;} + break; + + case 39: +#line 162 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = (yyvsp[(2) - (2)].code); ;} break; case 40: -#line 155 "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); ;} +#line 163 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->c_negate); ;} break; case 41: -#line 156 "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); ;} +#line 164 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = (yyvsp[(2) - (3)].code); ;} break; case 42: -#line 157 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(g_lingo->c_printtop); ;} +#line 167 "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 43: +#line 168 "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 44: #line 169 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->c_printtop); ;} + break; + + case 46: +#line 181 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotoloop); ;} break; - case 45: -#line 170 "engines/director/lingo/lingo-gr.y" + case 47: +#line 182 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotonext); ;} break; - case 46: -#line 171 "engines/director/lingo/lingo-gr.y" + case 48: +#line 183 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotoprevious); ;} break; - case 47: -#line 172 "engines/director/lingo/lingo-gr.y" + case 49: +#line 184 "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 48: -#line 173 "engines/director/lingo/lingo-gr.y" + case 50: +#line 185 "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 49: -#line 174 "engines/director/lingo/lingo-gr.y" + case 51: +#line 186 "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 50: -#line 177 "engines/director/lingo/lingo-gr.y" + case 52: +#line 189 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 51: -#line 178 "engines/director/lingo/lingo-gr.y" + case 53: +#line 190 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 52: -#line 179 "engines/director/lingo/lingo-gr.y" + case 54: +#line 191 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 53: -#line 180 "engines/director/lingo/lingo-gr.y" + case 55: +#line 192 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(1) - (1)].s); ;} break; - case 54: -#line 183 "engines/director/lingo/lingo-gr.y" + case 56: +#line 195 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 55: -#line 184 "engines/director/lingo/lingo-gr.y" + case 57: +#line 196 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 56: -#line 185 "engines/director/lingo/lingo-gr.y" + case 58: +#line 197 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; /* Line 1267 of yacc.c. */ -#line 1727 "engines/director/lingo/lingo-gr.cpp" +#line 1745 "engines/director/lingo/lingo-gr.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1937,6 +1955,6 @@ yyreturn: } -#line 228 "engines/director/lingo/lingo-gr.y" +#line 236 "engines/director/lingo/lingo-gr.y" diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h index 797826974e..e3b6ea99ac 100644 --- a/engines/director/lingo/lingo-gr.h +++ b/engines/director/lingo/lingo-gr.h @@ -59,15 +59,17 @@ tOF = 275, tPREVIOUS = 276, tPUT = 277, - tSET = 278, - tTHEN = 279, - tTO = 280, - tGE = 281, - tLE = 282, - tGT = 283, - tLT = 284, - tEQ = 285, - tNEQ = 286 + tREPEAT = 278, + tSET = 279, + tTHEN = 280, + tTO = 281, + tWHILE = 282, + tGE = 283, + tLE = 284, + tGT = 285, + tLT = 286, + tEQ = 287, + tNEQ = 288 }; #endif /* Tokens. */ @@ -91,15 +93,17 @@ #define tOF 275 #define tPREVIOUS 276 #define tPUT 277 -#define tSET 278 -#define tTHEN 279 -#define tTO 280 -#define tGE 281 -#define tLE 282 -#define tGT 283 -#define tLT 284 -#define tEQ 285 -#define tNEQ 286 +#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 @@ -114,7 +118,7 @@ typedef union YYSTYPE int code; } /* Line 1529 of yacc.c. */ -#line 118 "engines/director/lingo/lingo-gr.hpp" +#line 122 "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 8d205b8ae1..8e4f96dcf9 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -74,10 +74,10 @@ using namespace Director; %token<f> FLOAT %token<s> VAR STRING %token tIF tELSE tEND tFRAME tGO tINTO tLOOP tMCI tMCIWAIT tMOVIE tNEXT tOF tPREVIOUS -%token tPUT tSET tTHEN tTO +%token tPUT tREPEAT tSET tTHEN tTO tWHILE %token tGE tLE tGT tLT tEQ tNEQ -%type<code> asgn cond expr if end stmtlist +%type<code> asgn cond expr if end stmtlist while %type<s> gotoframe gotomovie %right '=' @@ -120,6 +120,31 @@ stmt: expr { g_lingo->code1(g_lingo->c_xpop); } (*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */ (*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */ (*g_lingo->_currentScript)[$1 + 3] = end; } /* end, if cond fails */ + // repeat while (expression = TRUE) + // statements + // end repeat + // + | while '(' 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 */ + ; + +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); } + ; +if: tIF { $$ = g_lingo->code1(g_lingo->c_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 ; expr: INT { g_lingo->code1(g_lingo->c_constpush); inst i; WRITE_LE_UINT32(&i, $1); $$ = g_lingo->code1(i); }; @@ -139,19 +164,6 @@ expr: INT { g_lingo->code1(g_lingo->c_constpush); inst i; WRITE_LE_UINT32(& | '(' expr ')' { $$ = $2; } ; -cond: expr { g_lingo->code1(STOP); } - | expr '=' expr { g_lingo->code2(g_lingo->c_eq, STOP); } - | '(' cond ')' - ; -if: tIF { $$ = g_lingo->code1(g_lingo->c_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->c_mci); g_lingo->codeString($2->c_str()); delete $2; } | tMCIWAIT VAR { g_lingo->code1(g_lingo->c_mciwait); g_lingo->codeString($2->c_str()); delete $2; } | tPUT expr { g_lingo->code1(g_lingo->c_printtop); } @@ -185,10 +197,6 @@ gotomovie: tOF tMOVIE STRING { $$ = $3; } | tTO tMOVIE STRING { $$ = $3; } ; -// repeat while (expression = TRUE) -// statements -// end repeat -// // repeat with index = start to end // statements // end repeat diff --git a/engines/director/lingo/lingo-lex.cpp b/engines/director/lingo/lingo-lex.cpp index c79d281428..bf322e2ce9 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 30 -#define YY_END_OF_BUFFER 31 +#define YY_NUM_RULES 32 +#define YY_END_OF_BUFFER 33 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -373,17 +373,19 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[88] = +static yyconst flex_int16_t yy_accept[99] = { 0, - 0, 0, 31, 30, 3, 28, 30, 30, 27, 27, - 26, 27, 27, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 2, 2, 3, 28, 21, - 0, 29, 1, 25, 26, 23, 22, 24, 24, 24, - 24, 8, 4, 24, 24, 24, 24, 24, 15, 24, - 24, 24, 24, 20, 1, 25, 24, 6, 24, 24, - 24, 11, 24, 24, 24, 17, 18, 24, 5, 24, - 9, 10, 24, 24, 14, 24, 19, 7, 24, 13, - 24, 24, 24, 12, 24, 16, 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 + } ; static yyconst flex_int32_t yy_ec[256] = @@ -426,70 +428,78 @@ static yyconst flex_int32_t yy_meta[36] = 4, 4, 4, 4, 4 } ; -static yyconst flex_int16_t yy_base[91] = +static yyconst flex_int16_t yy_base[102] = { 0, - 0, 34, 109, 110, 106, 34, 94, 99, 110, 96, - 30, 91, 90, 0, 18, 73, 74, 23, 73, 28, - 80, 78, 18, 78, 24, 94, 110, 93, 49, 110, - 87, 110, 0, 82, 46, 110, 110, 0, 62, 73, - 74, 0, 0, 58, 61, 64, 53, 50, 0, 65, - 52, 51, 62, 0, 0, 69, 60, 0, 53, 50, - 48, 41, 51, 42, 39, 0, 0, 45, 0, 51, - 0, 0, 53, 49, 0, 44, 0, 0, 43, 0, - 37, 32, 27, 0, 24, 0, 110, 57, 44, 61 + 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 } ; -static yyconst flex_int16_t yy_def[91] = +static yyconst flex_int16_t yy_def[102] = { 0, - 87, 1, 87, 87, 87, 87, 87, 88, 87, 87, - 87, 87, 87, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 87, 87, 87, 87, 87, - 88, 87, 90, 87, 87, 87, 87, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 90, 87, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 89, 89, 89, 89, 0, 87, 87, 87 + 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 } ; -static yyconst flex_int16_t yy_nxt[146] = +static yyconst flex_int16_t yy_nxt[155] = { 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, 14, 24, - 25, 14, 14, 14, 14, 26, 29, 29, 27, 34, - 35, 39, 43, 40, 46, 53, 50, 38, 44, 51, - 54, 29, 29, 86, 47, 34, 35, 31, 85, 31, - 31, 55, 84, 83, 55, 82, 81, 80, 79, 78, - 77, 76, 75, 74, 73, 72, 71, 70, 69, 56, - 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, - 58, 57, 56, 32, 28, 28, 52, 49, 48, 45, - - 42, 41, 37, 36, 33, 32, 30, 28, 87, 3, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87 + 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 } ; -static yyconst flex_int16_t yy_chk[146] = +static yyconst flex_int16_t yy_chk[155] = { 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, 25, 23, 89, 18, 23, - 25, 29, 29, 85, 20, 35, 35, 88, 83, 88, - 88, 90, 82, 81, 90, 79, 76, 74, 73, 70, - 68, 65, 64, 63, 62, 61, 60, 59, 57, 56, - 53, 52, 51, 50, 48, 47, 46, 45, 44, 41, - 40, 39, 34, 31, 28, 26, 24, 22, 21, 19, - - 17, 16, 13, 12, 10, 8, 7, 5, 3, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87 + 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 } ; static yy_state_type yy_last_accepting_state; @@ -539,7 +549,7 @@ char *yytext; int yyparse(); -#line 543 "engines/director/lingo/lingo-lex.cpp" +#line 553 "engines/director/lingo/lingo-lex.cpp" #define INITIAL 0 @@ -727,7 +737,7 @@ YY_DECL #line 45 "engines/director/lingo/lingo-lex.l" -#line 731 "engines/director/lingo/lingo-lex.cpp" +#line 741 "engines/director/lingo/lingo-lex.cpp" if ( !(yy_init) ) { @@ -781,13 +791,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 >= 88 ) + if ( yy_current_state >= 99 ) 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] != 110 ); + while ( yy_base[yy_current_state] != 119 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -899,70 +909,80 @@ YY_RULE_SETUP case 18: YY_RULE_SETUP #line 65 "engines/director/lingo/lingo-lex.l" -{ return tSET; } +{ return tREPEAT; } YY_BREAK case 19: YY_RULE_SETUP #line 66 "engines/director/lingo/lingo-lex.l" -{ return tTHEN; } +{ return tSET; } YY_BREAK case 20: YY_RULE_SETUP #line 67 "engines/director/lingo/lingo-lex.l" -{ return tTO; } +{ return tTHEN; } YY_BREAK case 21: YY_RULE_SETUP -#line 69 "engines/director/lingo/lingo-lex.l" -{ return tNEQ; } +#line 68 "engines/director/lingo/lingo-lex.l" +{ return tTO; } YY_BREAK case 22: YY_RULE_SETUP -#line 70 "engines/director/lingo/lingo-lex.l" -{ return tGE; } +#line 69 "engines/director/lingo/lingo-lex.l" +{ return tWHILE; } YY_BREAK case 23: YY_RULE_SETUP #line 71 "engines/director/lingo/lingo-lex.l" -{ return tLE; } +{ return tNEQ; } YY_BREAK case 24: YY_RULE_SETUP -#line 73 "engines/director/lingo/lingo-lex.l" -{ yylval.s = new Common::String(yytext); return VAR; } +#line 72 "engines/director/lingo/lingo-lex.l" +{ return tGE; } YY_BREAK case 25: YY_RULE_SETUP -#line 74 "engines/director/lingo/lingo-lex.l" -{ yylval.f = atof(yytext); return FLOAT; } +#line 73 "engines/director/lingo/lingo-lex.l" +{ return tLE; } YY_BREAK case 26: YY_RULE_SETUP #line 75 "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 27: YY_RULE_SETUP #line 76 "engines/director/lingo/lingo-lex.l" -{ return *yytext; } +{ yylval.f = atof(yytext); return FLOAT; } YY_BREAK case 28: -/* rule 28 can match eol */ YY_RULE_SETUP #line 77 "engines/director/lingo/lingo-lex.l" -{ return '\n'; } +{ yylval.i = strtol(yytext, NULL, 10); return INT; } YY_BREAK case 29: YY_RULE_SETUP #line 78 "engines/director/lingo/lingo-lex.l" -{ yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; } +{ return *yytext; } YY_BREAK case 30: +/* rule 30 can match eol */ +YY_RULE_SETUP +#line 79 "engines/director/lingo/lingo-lex.l" +{ return '\n'; } + 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; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 82 "engines/director/lingo/lingo-lex.l" ECHO; YY_BREAK -#line 966 "engines/director/lingo/lingo-lex.cpp" +#line 986 "engines/director/lingo/lingo-lex.cpp" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1255,7 +1275,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 >= 88 ) + if ( yy_current_state >= 99 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1283,11 +1303,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 >= 88 ) + if ( yy_current_state >= 99 ) 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 == 87); + yy_is_jam = (yy_current_state == 98); return yy_is_jam ? 0 : yy_current_state; } @@ -1962,7 +1982,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 80 "engines/director/lingo/lingo-lex.l" +#line 82 "engines/director/lingo/lingo-lex.l" diff --git a/engines/director/lingo/lingo-lex.l b/engines/director/lingo/lingo-lex.l index a95303fe27..07d9a63c72 100644 --- a/engines/director/lingo/lingo-lex.l +++ b/engines/director/lingo/lingo-lex.l @@ -62,9 +62,11 @@ next { return tNEXT; } of { return tOF; } previous { return tPREVIOUS; } put { return tPUT; } +repeat { return tREPEAT; } set { return tSET; } then { return tTHEN; } to { return tTO; } +while { return tWHILE; } [!][=] { return tNEQ; } [>][=] { return tGE; } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 35ac6ae15c..4cf5b9972d 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -132,6 +132,7 @@ public: static void c_assign(); bool verify(Symbol *s); static void c_eval(); + static void c_whilecode(); static void c_ifcode(); static void c_eq(); static void c_neq(); |