diff options
author | Eugene Sandulenko | 2016-07-06 12:47:39 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | a6ded367c831152252138ba2981be88f48401886 (patch) | |
tree | c4260c9508f362c26bbec845b47f2c54e5398728 /engines/director | |
parent | 7710390ab4e2d46bff7e0c7a43e30d6ca6378ca9 (diff) | |
download | scummvm-rg350-a6ded367c831152252138ba2981be88f48401886.tar.gz scummvm-rg350-a6ded367c831152252138ba2981be88f48401886.tar.bz2 scummvm-rg350-a6ded367c831152252138ba2981be88f48401886.zip |
DIRECTOR: Lingo: Further work on one-liner ifs
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/director.cpp | 7 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.cpp | 82 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.y | 4 |
3 files changed, 47 insertions, 46 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index a39894e50c..cc39573f99 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -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\ @@ -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); diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index 25b242a0bd..c647d59883 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -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. */ @@ -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. */ @@ -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, @@ -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, @@ -1709,10 +1709,10 @@ yyreduce: #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; diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index e7b42860c0..b337912a5d 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -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); @@ -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); |