Skip to content

Commit

Permalink
DIRECTOR: Lingo: Eat all leading whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent 22f72fc commit 2dba612
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 112 deletions.
24 changes: 13 additions & 11 deletions engines/director/director.cpp
Expand Up @@ -92,20 +92,22 @@ Common::Error DirectorEngine::run() {
_lingo = new Lingo(this);
_soundManager = new DirectorSound();

#if 0
#if 1
_lingo->addCode("--\n\
if 5 then\n\
exit\n\
else if 6 then\n\
put x\n\
exit\n\
else if 7 then exit\n\
end if\n\
if 5 then exit\n\
else exit\n\
-- repeat with x = 1 to 5\n\
if x = 1 then\n\
put 1\n\
else if x = 2 then\n\
put 2.1\n\
put 2.2\n\
else if x = 3 then put 3\n\
end if\n\
if x = 4 then put 4\n\
else put 5\n\
-- end repeat\n\
", kMovieScript, 2);

//_lingo->executeScript(kMovieScript, 2);
_lingo->executeScript(kMovieScript, 2);

return Common::kNoError;

Expand Down
200 changes: 101 additions & 99 deletions engines/director/lingo/lingo-lex.cpp
Expand Up @@ -373,22 +373,22 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[124] =
static yyconst flex_int16_t yy_accept[126] =
{ 0,
0, 0, 40, 38, 3, 36, 36, 38, 38, 38,
35, 35, 34, 35, 35, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
2, 2, 3, 36, 0, 29, 0, 37, 1, 33,
34, 31, 30, 32, 32, 32, 32, 32, 32, 32,
12, 5, 32, 32, 32, 32, 32, 32, 20, 32,
32, 32, 32, 32, 26, 32, 32, 1, 33, 32,
32, 8, 32, 32, 32, 32, 32, 32, 16, 32,
32, 32, 22, 32, 24, 32, 32, 32, 4, 7,
9, 32, 32, 13, 14, 32, 32, 32, 19, 32,

32, 25, 32, 27, 0, 10, 32, 15, 32, 18,
32, 32, 28, 0, 11, 32, 32, 23, 6, 17,
32, 21, 0
32, 32, 32, 32, 26, 32, 32, 2, 2, 1,
33, 32, 32, 8, 32, 32, 32, 32, 32, 32,
16, 32, 32, 32, 22, 32, 24, 32, 32, 32,
4, 7, 9, 32, 32, 13, 14, 32, 32, 32,

19, 32, 32, 25, 32, 27, 0, 10, 32, 15,
32, 18, 32, 32, 28, 0, 11, 32, 32, 23,
6, 17, 32, 21, 0
} ;

static yyconst flex_int32_t yy_ec[256] =
Expand Down Expand Up @@ -433,43 +433,43 @@ static yyconst flex_int32_t yy_meta[58] =
4, 4, 4, 4, 4, 4, 4
} ;

static yyconst flex_int16_t yy_base[127] =
static yyconst flex_int16_t yy_base[129] =
{ 0,
0, 56, 250, 287, 60, 56, 63, 66, 236, 241,
287, 236, 62, 228, 203, 0, 46, 50, 46, 53,
0, 56, 218, 295, 60, 56, 63, 66, 199, 167,
295, 164, 62, 158, 157, 0, 46, 50, 46, 53,
62, 51, 75, 64, 64, 78, 68, 72, 93, 94,
123, 131, 141, 90, 145, 287, 161, 287, 0, 147,
108, 287, 287, 0, 45, 89, 112, 108, 125, 123,
123, 131, 141, 90, 145, 295, 161, 295, 0, 147,
108, 295, 295, 0, 45, 89, 112, 108, 125, 123,
0, 0, 122, 127, 139, 134, 125, 124, 0, 142,
131, 135, 133, 147, 0, 144, 137, 0, 112, 143,
152, 0, 141, 148, 161, 154, 158, 162, 161, 174,
168, 167, 0, 179, 0, 175, 179, 183, 0, 83,
0, 187, 192, 0, 0, 181, 195, 192, 0, 189,

199, 0, 196, 0, 233, 0, 193, 0, 201, 0,
198, 199, 0, 220, 0, 210, 210, 0, 287, 0,
213, 0, 287, 278, 118, 282
131, 135, 133, 147, 0, 144, 137, 189, 193, 0,
112, 155, 158, 0, 155, 174, 185, 176, 176, 176,
172, 179, 177, 176, 0, 192, 0, 186, 189, 193,
0, 83, 0, 197, 202, 0, 0, 191, 205, 203,

0, 206, 217, 0, 217, 0, 241, 0, 216, 0,
222, 0, 219, 216, 0, 229, 0, 220, 220, 0,
295, 0, 224, 0, 295, 286, 118, 290
} ;

static yyconst flex_int16_t yy_def[127] =
static yyconst flex_int16_t yy_def[129] =
{ 0,
123, 1, 123, 123, 123, 123, 123, 123, 123, 124,
123, 123, 123, 123, 123, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
123, 123, 123, 123, 123, 123, 124, 123, 126, 123,
123, 123, 123, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 126, 123, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,

125, 125, 125, 125, 123, 125, 125, 125, 125, 125,
125, 125, 125, 123, 125, 125, 125, 125, 123, 125,
125, 125, 0, 123, 123, 123
125, 1, 125, 125, 125, 125, 125, 125, 125, 126,
125, 125, 125, 125, 125, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
125, 125, 125, 125, 125, 125, 126, 125, 128, 125,
125, 125, 125, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 125, 125, 128,
125, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
127, 127, 127, 127, 127, 127, 127, 127, 127, 127,

127, 127, 127, 127, 127, 127, 125, 127, 127, 127,
127, 127, 127, 127, 127, 125, 127, 127, 127, 127,
125, 127, 127, 127, 0, 125, 125, 125
} ;

static yyconst flex_int16_t yy_nxt[345] =
static yyconst flex_int16_t yy_nxt[353] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 4,
13, 14, 11, 15, 16, 16, 16, 17, 18, 19,
Expand All @@ -478,40 +478,41 @@ static yyconst flex_int16_t yy_nxt[345] =
18, 19, 20, 16, 21, 22, 23, 24, 25, 26,
27, 28, 29, 16, 16, 30, 16, 31, 34, 34,
32, 33, 34, 34, 35, 34, 34, 35, 34, 34,
35, 40, 41, 45, 46, 49, 47, 50, 54, 70,
51, 52, 58, 59, 105, 48, 62, 105, 53, 55,
35, 40, 41, 45, 46, 49, 47, 50, 54, 72,
51, 52, 58, 59, 107, 48, 62, 107, 53, 55,
63, 56, 34, 34, 45, 46, 49, 47, 50, 54,

70, 51, 57, 52, 58, 59, 48, 60, 62, 53,
61, 55, 63, 56, 64, 66, 67, 40, 41, 71,
65, 44, 69, 57, 33, 34, 34, 35, 60, 72,
73, 61, 35, 34, 34, 35, 64, 66, 67, 74,
71, 65, 33, 34, 34, 35, 35, 34, 34, 35,
75, 72, 73, 76, 77, 78, 79, 69, 80, 81,
82, 74, 83, 84, 85, 86, 87, 38, 88, 89,
90, 75, 91, 92, 76, 77, 93, 78, 79, 80,
81, 94, 82, 83, 84, 85, 95, 86, 87, 88,
89, 96, 90, 91, 92, 97, 98, 101, 93, 99,

100, 102, 94, 103, 104, 106, 107, 95, 108, 109,
110, 111, 96, 112, 113, 43, 97, 115, 98, 101,
99, 100, 102, 116, 103, 117, 104, 106, 107, 108,
118, 109, 110, 111, 105, 112, 113, 105, 115, 119,
42, 120, 121, 122, 39, 116, 117, 38, 36, 123,
123, 118, 123, 123, 123, 114, 123, 123, 123, 123,
123, 119, 120, 121, 122, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 114, 37, 123,
37, 37, 68, 123, 123, 68, 3, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123,

123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123
72, 51, 57, 52, 58, 59, 48, 60, 62, 53,
61, 55, 63, 56, 64, 66, 67, 40, 41, 73,
65, 44, 71, 57, 68, 34, 34, 69, 60, 74,
75, 61, 69, 34, 34, 69, 64, 66, 67, 76,
73, 65, 33, 34, 34, 35, 35, 34, 34, 35,
77, 74, 75, 78, 79, 80, 81, 71, 82, 83,
84, 76, 85, 86, 87, 88, 89, 38, 90, 43,
42, 77, 39, 38, 78, 79, 92, 80, 81, 82,
83, 91, 84, 85, 86, 87, 93, 88, 89, 90,
68, 34, 34, 69, 69, 34, 34, 69, 92, 94,

95, 100, 91, 96, 97, 98, 99, 93, 101, 102,
103, 36, 104, 105, 106, 108, 109, 125, 110, 111,
94, 112, 95, 100, 96, 97, 98, 99, 113, 101,
102, 114, 103, 104, 105, 115, 106, 108, 109, 110,
117, 111, 107, 112, 118, 107, 119, 120, 121, 125,
113, 122, 123, 114, 124, 125, 125, 115, 125, 125,
125, 117, 125, 116, 125, 125, 118, 119, 120, 125,
121, 125, 122, 123, 125, 124, 125, 125, 125, 125,
125, 125, 125, 125, 125, 116, 37, 125, 37, 37,
70, 125, 125, 70, 3, 125, 125, 125, 125, 125,

125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125
} ;

static yyconst flex_int16_t yy_chk[345] =
static yyconst flex_int16_t yy_chk[353] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Expand All @@ -521,36 +522,37 @@ static yyconst flex_int16_t yy_chk[345] =
1, 1, 1, 1, 1, 1, 1, 2, 6, 6,
2, 5, 5, 5, 5, 7, 7, 8, 8, 8,
8, 13, 13, 17, 18, 19, 18, 20, 22, 45,
20, 21, 24, 25, 90, 18, 27, 90, 21, 23,
20, 21, 24, 25, 92, 18, 27, 92, 21, 23,
28, 23, 34, 34, 17, 18, 19, 18, 20, 22,

45, 20, 23, 21, 24, 25, 18, 26, 27, 21,
26, 23, 28, 23, 29, 30, 30, 41, 41, 46,
29, 125, 69, 23, 31, 31, 31, 31, 26, 47,
29, 127, 71, 23, 31, 31, 31, 31, 26, 47,
48, 26, 32, 32, 32, 32, 29, 30, 30, 49,
46, 29, 33, 33, 33, 33, 35, 35, 35, 35,
50, 47, 48, 53, 54, 55, 56, 40, 57, 58,
60, 49, 61, 62, 63, 64, 66, 37, 67, 70,
71, 50, 73, 74, 53, 54, 75, 55, 56, 57,
58, 76, 60, 61, 62, 63, 77, 64, 66, 67,
70, 78, 71, 73, 74, 79, 80, 84, 75, 81,

82, 86, 76, 87, 88, 92, 93, 77, 96, 97,
98, 100, 78, 101, 103, 15, 79, 107, 80, 84,
81, 82, 86, 109, 87, 111, 88, 92, 93, 96,
112, 97, 98, 100, 105, 101, 103, 105, 107, 114,
14, 116, 117, 121, 12, 109, 111, 10, 9, 3,
0, 112, 0, 0, 0, 105, 0, 0, 0, 0,
0, 114, 116, 117, 121, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 105, 124, 0,
124, 124, 126, 0, 0, 126, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123,

123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
123, 123, 123, 123
60, 49, 61, 62, 63, 64, 66, 37, 67, 15,
14, 50, 12, 10, 53, 54, 73, 55, 56, 57,
58, 72, 60, 61, 62, 63, 75, 64, 66, 67,
68, 68, 68, 68, 69, 69, 69, 69, 73, 76,

77, 82, 72, 78, 79, 80, 81, 75, 83, 84,
86, 9, 88, 89, 90, 94, 95, 3, 98, 99,
76, 100, 77, 82, 78, 79, 80, 81, 102, 83,
84, 103, 86, 88, 89, 105, 90, 94, 95, 98,
109, 99, 107, 100, 111, 107, 113, 114, 116, 0,
102, 118, 119, 103, 123, 0, 0, 105, 0, 0,
0, 109, 0, 107, 0, 0, 111, 113, 114, 0,
116, 0, 118, 119, 0, 123, 0, 0, 0, 0,
0, 0, 0, 0, 0, 107, 126, 0, 126, 126,
128, 0, 0, 128, 125, 125, 125, 125, 125, 125,

125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125, 125, 125, 125, 125, 125, 125, 125, 125,
125, 125
} ;

static yy_state_type yy_last_accepting_state;
Expand Down Expand Up @@ -600,7 +602,7 @@ char *yytext;

int yyparse();

#line 604 "engines/director/lingo/lingo-lex.cpp"
#line 606 "engines/director/lingo/lingo-lex.cpp"

#define INITIAL 0

Expand Down Expand Up @@ -788,7 +790,7 @@ YY_DECL
#line 45 "engines/director/lingo/lingo-lex.l"


#line 792 "engines/director/lingo/lingo-lex.cpp"
#line 794 "engines/director/lingo/lingo-lex.cpp"

if ( !(yy_init) )
{
Expand Down Expand Up @@ -842,13 +844,13 @@ YY_DECL
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 >= 124 )
if ( yy_current_state >= 126 )
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] != 287 );
while ( yy_base[yy_current_state] != 295 );

yy_find_action:
yy_act = yy_accept[yy_current_state];
Expand Down Expand Up @@ -1075,7 +1077,7 @@ YY_RULE_SETUP
#line 96 "engines/director/lingo/lingo-lex.l"
ECHO;
YY_BREAK
#line 1079 "engines/director/lingo/lingo-lex.cpp"
#line 1081 "engines/director/lingo/lingo-lex.cpp"
case YY_STATE_EOF(INITIAL):
yyterminate();

Expand Down Expand Up @@ -1368,7 +1370,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 >= 124 )
if ( yy_current_state >= 126 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
Expand Down Expand Up @@ -1396,11 +1398,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 >= 124 )
if ( yy_current_state >= 126 )
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 == 123);
yy_is_jam = (yy_current_state == 125);

return yy_is_jam ? 0 : yy_current_state;
}
Expand Down
4 changes: 2 additions & 2 deletions engines/director/lingo/lingo-lex.l
Expand Up @@ -45,8 +45,8 @@ whitespace [\t ]
%%
--[^\r\n]*
^{whitespace}
[\t]+ { return ' '; }
^{whitespace}+
[\t]+ { return ' '; }
(?i:down) { return tDOWN; }
(?i:if) { return tIF; }
Expand Down

0 comments on commit 2dba612

Please sign in to comment.