Skip to content

Commit

Permalink
DIRECTOR: Lingo: Further work on one-liner ifs
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent 7710390 commit a6ded36
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 46 deletions.
7 changes: 4 additions & 3 deletions engines/director/director.cpp
Expand Up @@ -109,8 +109,9 @@ Common::Error DirectorEngine::run() {
_currentScore = nullptr;

_lingo->addCode("--\n\
--repeat with x = 1 to 5\n\
set x = 4\n\
set x = 1\n\
if 5 then exit\n\
repeat with x = 1 to 5\n\
if x = 1 then\n\
put 1\n\
else if x = 2 then\n\
Expand All @@ -120,7 +121,7 @@ Common::Error DirectorEngine::run() {
end if\n\
if x = 4 then put 4\n\
else put 5\n\
--end repeat\n\
end repeat\n\
", kMovieScript, 2);

_lingo->executeScript(kMovieScript, 2);
Expand Down
82 changes: 41 additions & 41 deletions engines/director/lingo/lingo-gr.cpp
Expand Up @@ -490,14 +490,14 @@ static const yytype_uint16 yyprhs[] =
{
0, 0, 3, 7, 9, 10, 12, 14, 16, 18,
20, 22, 27, 32, 37, 39, 41, 43, 52, 64,
77, 86, 93, 105, 118, 130, 133, 135, 143, 149,
151, 155, 159, 162, 166, 168, 170, 171, 172, 173,
176, 179, 181, 183, 188, 193, 195, 197, 201, 205,
209, 213, 217, 221, 225, 229, 233, 236, 239, 243,
246, 249, 252, 254, 256, 259, 261, 265, 268, 271,
274, 277, 281, 284, 288, 291, 294, 296, 300, 303,
307, 308, 317, 318, 320, 324, 329, 330, 334, 335,
337
77, 86, 94, 106, 119, 131, 134, 136, 144, 150,
152, 156, 160, 163, 167, 169, 171, 172, 173, 174,
177, 180, 182, 184, 189, 194, 196, 198, 202, 206,
210, 214, 218, 222, 226, 230, 234, 237, 240, 244,
247, 250, 253, 255, 257, 260, 262, 266, 269, 272,
275, 278, 282, 285, 289, 292, 295, 297, 301, 304,
308, 309, 318, 319, 321, 325, 330, 331, 335, 336,
338
};

/* YYRHS -- A `-1'-separated list of the rules' RHS. */
Expand All @@ -512,32 +512,32 @@ static const yytype_int8 yyrhs[] =
70, 16, 32, -1, 66, 44, 72, 70, 13, 35,
72, 70, 71, 70, 16, 32, -1, 67, 64, 34,
50, 71, 70, 16, 21, -1, 67, 64, 34, 69,
60, 70, -1, 67, 64, 34, 50, 71, 70, 14,
71, 70, 16, 21, -1, 67, 64, 34, 69, 60,
70, 50, 14, 69, 60, 70, 50, -1, 67, 64,
34, 50, 71, 70, 69, 62, 70, 16, 21, -1,
62, 63, -1, 63, -1, 68, 64, 34, 69, 60,
70, 50, -1, 68, 64, 34, 71, 70, -1, 72,
-1, 72, 44, 72, -1, 51, 64, 52, -1, 32,
37, -1, 32, 36, 10, -1, 21, -1, 15, -1,
-1, -1, -1, 71, 50, -1, 71, 60, -1, 7,
-1, 8, -1, 9, 51, 83, 52, -1, 10, 51,
83, 52, -1, 10, -1, 59, -1, 72, 45, 72,
-1, 72, 46, 72, -1, 72, 47, 72, -1, 72,
48, 72, -1, 72, 53, 72, -1, 72, 54, 72,
-1, 72, 43, 72, -1, 72, 38, 72, -1, 72,
39, 72, -1, 45, 72, -1, 46, 72, -1, 51,
72, 52, -1, 25, 11, -1, 26, 10, -1, 31,
72, -1, 75, -1, 17, -1, 19, 74, -1, 10,
-1, 74, 55, 10, -1, 20, 23, -1, 20, 28,
-1, 20, 30, -1, 20, 76, -1, 20, 76, 77,
-1, 20, 77, -1, 35, 18, 11, -1, 18, 11,
-1, 35, 11, -1, 11, -1, 29, 27, 11, -1,
27, 11, -1, 35, 27, 11, -1, -1, 24, 10,
79, 69, 80, 50, 81, 71, -1, -1, 10, -1,
80, 55, 10, -1, 80, 50, 55, 10, -1, -1,
10, 69, 83, -1, -1, 72, -1, 83, 55, 72,
-1
60, 70, 50, -1, 67, 64, 34, 50, 71, 70,
14, 71, 70, 16, 21, -1, 67, 64, 34, 69,
60, 70, 50, 14, 69, 60, 70, 50, -1, 67,
64, 34, 50, 71, 70, 69, 62, 70, 16, 21,
-1, 62, 63, -1, 63, -1, 68, 64, 34, 69,
60, 70, 50, -1, 68, 64, 34, 71, 70, -1,
72, -1, 72, 44, 72, -1, 51, 64, 52, -1,
32, 37, -1, 32, 36, 10, -1, 21, -1, 15,
-1, -1, -1, -1, 71, 50, -1, 71, 60, -1,
7, -1, 8, -1, 9, 51, 83, 52, -1, 10,
51, 83, 52, -1, 10, -1, 59, -1, 72, 45,
72, -1, 72, 46, 72, -1, 72, 47, 72, -1,
72, 48, 72, -1, 72, 53, 72, -1, 72, 54,
72, -1, 72, 43, 72, -1, 72, 38, 72, -1,
72, 39, 72, -1, 45, 72, -1, 46, 72, -1,
51, 72, 52, -1, 25, 11, -1, 26, 10, -1,
31, 72, -1, 75, -1, 17, -1, 19, 74, -1,
10, -1, 74, 55, 10, -1, 20, 23, -1, 20,
28, -1, 20, 30, -1, 20, 76, -1, 20, 76,
77, -1, 20, 77, -1, 35, 18, 11, -1, 18,
11, -1, 35, 11, -1, 11, -1, 29, 27, 11,
-1, 27, 11, -1, 35, 27, 11, -1, -1, 24,
10, 79, 69, 80, 50, 81, 71, -1, -1, 10,
-1, 80, 55, 10, -1, 80, 50, 55, 10, -1,
-1, 10, 69, 83, -1, -1, 72, -1, 83, 55,
72, -1
};

/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Expand Down Expand Up @@ -609,7 +609,7 @@ static const yytype_uint8 yyr2[] =
{
0, 2, 3, 1, 0, 1, 1, 1, 1, 1,
1, 4, 4, 4, 1, 1, 1, 8, 11, 12,
8, 6, 11, 12, 11, 2, 1, 7, 5, 1,
8, 7, 11, 12, 11, 2, 1, 7, 5, 1,
3, 3, 2, 3, 1, 1, 0, 0, 0, 2,
2, 1, 1, 4, 4, 1, 1, 3, 3, 3,
3, 3, 3, 3, 3, 3, 2, 2, 3, 2,
Expand Down Expand Up @@ -638,8 +638,8 @@ static const yytype_uint8 yydefact[] =
51, 52, 43, 0, 44, 66, 77, 73, 79, 82,
11, 13, 12, 38, 0, 31, 38, 0, 30, 90,
83, 0, 37, 0, 0, 37, 37, 15, 86, 0,
39, 40, 0, 0, 37, 36, 21, 0, 38, 84,
0, 37, 38, 38, 0, 0, 0, 85, 81, 17,
39, 40, 0, 0, 37, 36, 0, 0, 38, 84,
0, 37, 38, 38, 0, 0, 21, 85, 81, 17,
38, 37, 37, 20, 35, 37, 26, 0, 36, 37,
0, 0, 25, 0, 0, 0, 0, 0, 0, 0,
36, 37, 0, 18, 22, 24, 0, 37, 0, 19,
Expand Down Expand Up @@ -1709,10 +1709,10 @@ yyparse ()
#line 181 "engines/director/lingo/lingo-gr.y"
{
inst then = 0, end = 0;
WRITE_UINT32(&then, (yyvsp[(4) - (6)].code));
WRITE_UINT32(&end, (yyvsp[(6) - (6)].code));
(*g_lingo->_currentScript)[(yyvsp[(1) - (6)].code) + 1] = then; /* thenpart */
(*g_lingo->_currentScript)[(yyvsp[(1) - (6)].code) + 3] = end; /* end, if cond fails */
WRITE_UINT32(&then, (yyvsp[(4) - (7)].code));
WRITE_UINT32(&end, (yyvsp[(6) - (7)].code));
(*g_lingo->_currentScript)[(yyvsp[(1) - (7)].code) + 1] = then; /* thenpart */
(*g_lingo->_currentScript)[(yyvsp[(1) - (7)].code) + 3] = end; /* end, if cond fails */

g_lingo->processIf(0, 0); ;}
break;
Expand Down
4 changes: 2 additions & 2 deletions engines/director/lingo/lingo-gr.y
Expand Up @@ -178,7 +178,7 @@ ifstmt: if cond tTHEN '\n' stmtlist end tEND tIF {
(*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
g_lingo->processIf(0, 0); }
| if cond tTHEN begin stmt end {
| if cond tTHEN begin stmt end '\n' {
inst then = 0, end = 0;
WRITE_UINT32(&then, $4);
WRITE_UINT32(&end, $6);
Expand All @@ -195,7 +195,7 @@ ifstmt: if cond tTHEN '\n' stmtlist end tEND tIF {
(*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */
(*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */
g_lingo->processIf(0, 0); }
| if cond tTHEN begin stmt end '\n' tELSE begin stmt end '\n' {
| if cond tTHEN begin stmt end '\n' tELSE begin stmt end '\n' {
inst then = 0, else1 = 0, end = 0;
WRITE_UINT32(&then, $4);
WRITE_UINT32(&else1, $9);
Expand Down

0 comments on commit a6ded36

Please sign in to comment.