aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorEugene Sandulenko2016-06-25 00:44:31 +0200
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit2451bed12822cd1996d616dc5c296cff5aecbcde (patch)
tree2172009a17be7743c0c61c83052bc52168de9786 /engines/director
parent61e80e158b48d84234c16304f8c3aeb76fd6e7b7 (diff)
downloadscummvm-rg350-2451bed12822cd1996d616dc5c296cff5aecbcde.tar.gz
scummvm-rg350-2451bed12822cd1996d616dc5c296cff5aecbcde.tar.bz2
scummvm-rg350-2451bed12822cd1996d616dc5c296cff5aecbcde.zip
DIRECTOR: Lingo: Renamed VAR->ID in the grammar for clarity
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/lingo/lingo-code.cpp8
-rw-r--r--engines/director/lingo/lingo-gr.cpp104
-rw-r--r--engines/director/lingo/lingo-gr.h4
-rw-r--r--engines/director/lingo/lingo-gr.y32
-rw-r--r--engines/director/lingo/lingo-lex.cpp2
-rw-r--r--engines/director/lingo/lingo-lex.l4
6 files changed, 85 insertions, 69 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index d1240ec0a1..7a3c8c8788 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -123,18 +123,18 @@ void Lingo::c_assign() {
d1 = g_lingo->pop();
d2 = g_lingo->pop();
- if (d1.sym->type != VAR && d1.sym->type != VOID) {
+ if (d1.sym->type != INT && d1.sym->type != VOID) {
warning("assignment to non-variable '%s'", d1.sym->name);
return;
}
d1.sym->u.val = d2.val;
- d1.sym->type = VAR;
+ d1.sym->type = INT;
g_lingo->push(d2);
}
bool Lingo::verify(Symbol *s) {
- if (s->type != VAR && s->type != VOID) {
+ if (s->type != INT && s->type != VOID) {
warning("attempt to evaluate non-variable '%s'", s->name);
return false;
@@ -290,7 +290,7 @@ void Lingo::c_repeatwithcode(void) {
g_lingo->execute(init); /* condition */
d = g_lingo->pop();
counter->u.val = d.val;
- counter->type = VAR;
+ counter->type = INT;
while (true) {
g_lingo->execute(body); /* body */
diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp
index 3b4d2d82d5..a02ba17ba1 100644
--- a/engines/director/lingo/lingo-gr.cpp
+++ b/engines/director/lingo/lingo-gr.cpp
@@ -70,7 +70,7 @@
VOID = 259,
INT = 260,
FLOAT = 261,
- VAR = 262,
+ ID = 262,
STRING = 263,
HANDLER = 264,
tDOWN = 265,
@@ -109,7 +109,7 @@
#define VOID 259
#define INT 260
#define FLOAT 261
-#define VAR 262
+#define ID 262
#define STRING 263
#define HANDLER 264
#define tDOWN 265
@@ -525,11 +525,11 @@ static const yytype_uint16 yyrline[] =
0, 92, 92, 93, 94, 97, 98, 99, 100, 101,
102, 103, 104, 107, 108, 109, 112, 113, 114, 120,
132, 143, 159, 173, 174, 175, 177, 179, 185, 187,
- 189, 191, 192, 193, 196, 197, 198, 199, 200, 201,
- 202, 203, 204, 205, 206, 207, 208, 209, 210, 213,
- 214, 215, 216, 217, 228, 229, 230, 231, 232, 233,
- 236, 237, 238, 239, 242, 243, 244, 272, 272, 278,
- 279, 280, 281
+ 189, 191, 192, 193, 196, 201, 206, 207, 208, 209,
+ 210, 211, 212, 213, 214, 215, 216, 217, 218, 221,
+ 222, 223, 224, 225, 236, 237, 238, 239, 240, 241,
+ 244, 245, 246, 247, 250, 251, 252, 280, 280, 286,
+ 287, 288, 289
};
#endif
@@ -538,7 +538,7 @@ static const yytype_uint16 yyrline[] =
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
- "$end", "error", "$undefined", "UNARY", "VOID", "INT", "FLOAT", "VAR",
+ "$end", "error", "$undefined", "UNARY", "VOID", "INT", "FLOAT", "ID",
"STRING", "HANDLER", "tDOWN", "tELSE", "tEND", "tEXIT", "tFRAME", "tGO",
"tIF", "tINTO", "tLOOP", "tMACRO", "tMCI", "tMCIWAIT", "tMOVIE", "tNEXT",
"tOF", "tPREVIOUS", "tPUT", "tREPEAT", "tSET", "tTHEN", "tTO", "tWITH",
@@ -1700,166 +1700,174 @@ yyreduce:
case 34:
#line 196 "engines/director/lingo/lingo-gr.y"
- { (yyval.code) = g_lingo->code1(g_lingo->c_constpush); inst i = 0; WRITE_LE_UINT32(&i, (yyvsp[(1) - (1)].i)); g_lingo->code1(i); ;}
+ {
+ (yyval.code) = g_lingo->code1(g_lingo->c_constpush);
+ inst i = 0;
+ WRITE_LE_UINT32(&i, (yyvsp[(1) - (1)].i));
+ g_lingo->code1(i); ;}
break;
case 35:
-#line 197 "engines/director/lingo/lingo-gr.y"
- { (yyval.code) = g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); g_lingo->code1(g_lingo->c_eval); delete (yyvsp[(1) - (1)].s); ;}
+#line 201 "engines/director/lingo/lingo-gr.y"
+ {
+ (yyval.code) = g_lingo->code1(g_lingo->c_varpush);
+ g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str());
+ g_lingo->code1(g_lingo->c_eval);
+ delete (yyvsp[(1) - (1)].s); ;}
break;
case 37:
-#line 199 "engines/director/lingo/lingo-gr.y"
+#line 207 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_add); ;}
break;
case 38:
-#line 200 "engines/director/lingo/lingo-gr.y"
+#line 208 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_sub); ;}
break;
case 39:
-#line 201 "engines/director/lingo/lingo-gr.y"
+#line 209 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_mul); ;}
break;
case 40:
-#line 202 "engines/director/lingo/lingo-gr.y"
+#line 210 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_div); ;}
break;
case 41:
-#line 203 "engines/director/lingo/lingo-gr.y"
+#line 211 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_gt); ;}
break;
case 42:
-#line 204 "engines/director/lingo/lingo-gr.y"
+#line 212 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_lt); ;}
break;
case 43:
-#line 205 "engines/director/lingo/lingo-gr.y"
+#line 213 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_neq); ;}
break;
case 44:
-#line 206 "engines/director/lingo/lingo-gr.y"
+#line 214 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_ge); ;}
break;
case 45:
-#line 207 "engines/director/lingo/lingo-gr.y"
+#line 215 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_le); ;}
break;
case 46:
-#line 208 "engines/director/lingo/lingo-gr.y"
+#line 216 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = (yyvsp[(2) - (2)].code); ;}
break;
case 47:
-#line 209 "engines/director/lingo/lingo-gr.y"
+#line 217 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->c_negate); ;}
break;
case 48:
-#line 210 "engines/director/lingo/lingo-gr.y"
+#line 218 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = (yyvsp[(2) - (3)].code); ;}
break;
case 49:
-#line 213 "engines/director/lingo/lingo-gr.y"
+#line 221 "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 50:
-#line 214 "engines/director/lingo/lingo-gr.y"
+#line 222 "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 51:
-#line 215 "engines/director/lingo/lingo-gr.y"
+#line 223 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_printtop); ;}
break;
case 53:
-#line 217 "engines/director/lingo/lingo-gr.y"
+#line 225 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_exit); ;}
break;
case 54:
-#line 228 "engines/director/lingo/lingo-gr.y"
+#line 236 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_gotoloop); ;}
break;
case 55:
-#line 229 "engines/director/lingo/lingo-gr.y"
+#line 237 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_gotonext); ;}
break;
case 56:
-#line 230 "engines/director/lingo/lingo-gr.y"
+#line 238 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->c_gotoprevious); ;}
break;
case 57:
-#line 231 "engines/director/lingo/lingo-gr.y"
+#line 239 "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 58:
-#line 232 "engines/director/lingo/lingo-gr.y"
+#line 240 "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 59:
-#line 233 "engines/director/lingo/lingo-gr.y"
+#line 241 "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 60:
-#line 236 "engines/director/lingo/lingo-gr.y"
+#line 244 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(3) - (3)].s); ;}
break;
case 61:
-#line 237 "engines/director/lingo/lingo-gr.y"
+#line 245 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(2) - (2)].s); ;}
break;
case 62:
-#line 238 "engines/director/lingo/lingo-gr.y"
+#line 246 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(2) - (2)].s); ;}
break;
case 63:
-#line 239 "engines/director/lingo/lingo-gr.y"
+#line 247 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(1) - (1)].s); ;}
break;
case 64:
-#line 242 "engines/director/lingo/lingo-gr.y"
+#line 250 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(3) - (3)].s); ;}
break;
case 65:
-#line 243 "engines/director/lingo/lingo-gr.y"
+#line 251 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(2) - (2)].s); ;}
break;
case 66:
-#line 244 "engines/director/lingo/lingo-gr.y"
+#line 252 "engines/director/lingo/lingo-gr.y"
{ (yyval.s) = (yyvsp[(3) - (3)].s); ;}
break;
case 67:
-#line 272 "engines/director/lingo/lingo-gr.y"
+#line 280 "engines/director/lingo/lingo-gr.y"
{ g_lingo->_indef = true; ;}
break;
case 68:
-#line 273 "engines/director/lingo/lingo-gr.y"
+#line 281 "engines/director/lingo/lingo-gr.y"
{
g_lingo->code1(g_lingo->c_procret);
g_lingo->define(*(yyvsp[(2) - (7)].s), (yyvsp[(4) - (7)].code), (yyvsp[(7) - (7)].code), (yyvsp[(5) - (7)].narg));
@@ -1867,28 +1875,28 @@ yyreduce:
break;
case 69:
-#line 278 "engines/director/lingo/lingo-gr.y"
+#line 286 "engines/director/lingo/lingo-gr.y"
{ (yyval.narg) = 0; ;}
break;
case 70:
-#line 279 "engines/director/lingo/lingo-gr.y"
+#line 287 "engines/director/lingo/lingo-gr.y"
{ g_lingo->codeArg(*(yyvsp[(1) - (1)].s)); delete (yyvsp[(1) - (1)].s); (yyval.narg) = 1; ;}
break;
case 71:
-#line 280 "engines/director/lingo/lingo-gr.y"
+#line 288 "engines/director/lingo/lingo-gr.y"
{ g_lingo->codeArg(*(yyvsp[(3) - (3)].s)); delete (yyvsp[(3) - (3)].s); (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;}
break;
case 72:
-#line 281 "engines/director/lingo/lingo-gr.y"
+#line 289 "engines/director/lingo/lingo-gr.y"
{ g_lingo->codeArg(*(yyvsp[(4) - (4)].s)); delete (yyvsp[(4) - (4)].s); (yyval.narg) = (yyvsp[(1) - (4)].narg) + 1; ;}
break;
/* Line 1267 of yacc.c. */
-#line 1892 "engines/director/lingo/lingo-gr.cpp"
+#line 1900 "engines/director/lingo/lingo-gr.cpp"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2102,6 +2110,6 @@ yyreturn:
}
-#line 285 "engines/director/lingo/lingo-gr.y"
+#line 293 "engines/director/lingo/lingo-gr.y"
diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h
index 3232523e26..2bf7d7aa12 100644
--- a/engines/director/lingo/lingo-gr.h
+++ b/engines/director/lingo/lingo-gr.h
@@ -43,7 +43,7 @@
VOID = 259,
INT = 260,
FLOAT = 261,
- VAR = 262,
+ ID = 262,
STRING = 263,
HANDLER = 264,
tDOWN = 265,
@@ -82,7 +82,7 @@
#define VOID 259
#define INT 260
#define FLOAT 261
-#define VAR 262
+#define ID 262
#define STRING 263
#define HANDLER 264
#define tDOWN 265
diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y
index 8fdf8250ea..5f775c40b0 100644
--- a/engines/director/lingo/lingo-gr.y
+++ b/engines/director/lingo/lingo-gr.y
@@ -73,7 +73,7 @@ using namespace Director;
%token UNARY VOID
%token<i> INT
%token<f> FLOAT
-%token<s> VAR STRING HANDLER
+%token<s> ID STRING HANDLER
%token tDOWN tELSE tEND tEXIT tFRAME tGO tIF tINTO tLOOP tMACRO tMCI tMCIWAIT
%token tMOVIE tNEXT tOF tPREVIOUS tPUT tREPEAT tSET tTHEN tTO tWITH tWHILE
%token tGE tLE tGT tLT tEQ tNEQ
@@ -104,9 +104,9 @@ programline:
| /* empty */
;
-asgn: tPUT expr tINTO VAR { g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString($4->c_str()); g_lingo->code1(g_lingo->c_assign); $$ = $2; delete $4; }
- | tSET VAR '=' expr { g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString($2->c_str()); g_lingo->code1(g_lingo->c_assign); $$ = $4; delete $2; }
- | tSET VAR tTO expr { g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString($2->c_str()); g_lingo->code1(g_lingo->c_assign); $$ = $4; delete $2; }
+asgn: tPUT expr tINTO ID { g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString($4->c_str()); g_lingo->code1(g_lingo->c_assign); $$ = $2; delete $4; }
+ | tSET ID '=' expr { g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString($2->c_str()); g_lingo->code1(g_lingo->c_assign); $$ = $4; delete $2; }
+ | tSET ID tTO expr { g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString($2->c_str()); g_lingo->code1(g_lingo->c_assign); $$ = $4; delete $2; }
;
stmt: expr { g_lingo->code1(g_lingo->c_xpop); }
@@ -176,7 +176,7 @@ cond: expr { g_lingo->code1(STOP); }
;
repeatwhile: tREPEAT tWHILE { $$ = g_lingo->code3(g_lingo->c_repeatwhilecode, STOP, STOP); }
;
-repeatwith: tREPEAT tWITH VAR {
+repeatwith: tREPEAT tWITH ID {
$$ = g_lingo->code3(g_lingo->c_repeatwithcode, STOP, STOP);
g_lingo->code3(STOP, STOP, STOP);
g_lingo->codeString($3->c_str());
@@ -193,8 +193,16 @@ stmtlist: /* nothing */ { $$ = g_lingo->_currentScript->size(); }
| stmtlist stmt
;
-expr: INT { $$ = g_lingo->code1(g_lingo->c_constpush); inst i = 0; WRITE_LE_UINT32(&i, $1); g_lingo->code1(i); };
- | VAR { $$ = g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString($1->c_str()); g_lingo->code1(g_lingo->c_eval); delete $1; }
+expr: INT {
+ $$ = g_lingo->code1(g_lingo->c_constpush);
+ inst i = 0;
+ WRITE_LE_UINT32(&i, $1);
+ g_lingo->code1(i); };
+ | ID {
+ $$ = g_lingo->code1(g_lingo->c_varpush);
+ g_lingo->codeString($1->c_str());
+ g_lingo->code1(g_lingo->c_eval);
+ delete $1; }
| asgn
| expr '+' expr { g_lingo->code1(g_lingo->c_add); }
| expr '-' expr { g_lingo->code1(g_lingo->c_sub); }
@@ -211,7 +219,7 @@ expr: INT { $$ = g_lingo->code1(g_lingo->c_constpush); inst i = 0; WRITE_LE
;
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; }
+ | tMCIWAIT ID { g_lingo->code1(g_lingo->c_mciwait); g_lingo->codeString($2->c_str()); delete $2; }
| tPUT expr { g_lingo->code1(g_lingo->c_printtop); }
| gotofunc
| tEXIT { g_lingo->code1(g_lingo->c_exit); }
@@ -269,16 +277,16 @@ gotomovie: tOF tMOVIE STRING { $$ = $3; }
//
// See also:
// on keyword
-defn: tMACRO VAR { g_lingo->_indef = true; }
+defn: tMACRO ID { g_lingo->_indef = true; }
begin argdef stmtlist end {
g_lingo->code1(g_lingo->c_procret);
g_lingo->define(*$2, $4, $7, $5);
g_lingo->_indef = false; }
;
argdef: /* nothing */ { $$ = 0; }
- | VAR { g_lingo->codeArg(*$1); delete $1; $$ = 1; }
- | argdef ',' VAR { g_lingo->codeArg(*$3); delete $3; $$ = $1 + 1; }
- | argdef ',' '\n' VAR { g_lingo->codeArg(*$4); delete $4; $$ = $1 + 1; }
+ | ID { g_lingo->codeArg(*$1); delete $1; $$ = 1; }
+ | argdef ',' ID { g_lingo->codeArg(*$3); delete $3; $$ = $1 + 1; }
+ | argdef ',' '\n' ID { g_lingo->codeArg(*$4); delete $4; $$ = $1 + 1; }
;
diff --git a/engines/director/lingo/lingo-lex.cpp b/engines/director/lingo/lingo-lex.cpp
index 421b407eb0..953d7de8a1 100644
--- a/engines/director/lingo/lingo-lex.cpp
+++ b/engines/director/lingo/lingo-lex.cpp
@@ -975,7 +975,7 @@ YY_RULE_SETUP
case 30:
YY_RULE_SETUP
#line 79 "engines/director/lingo/lingo-lex.l"
-{ yylval.s = new Common::String(yytext); return VAR; }
+{ yylval.s = new Common::String(yytext); return ID; }
YY_BREAK
case 31:
YY_RULE_SETUP
diff --git a/engines/director/lingo/lingo-lex.l b/engines/director/lingo/lingo-lex.l
index edabbf05b7..5f84fb9390 100644
--- a/engines/director/lingo/lingo-lex.l
+++ b/engines/director/lingo/lingo-lex.l
@@ -34,7 +34,7 @@ int yyparse();
%}
-variable [_[:alpha:]][_[:alnum:]]*
+identifier [_[:alpha:]][_[:alnum:]]*
constfloat [[:digit:]]+\.[[:digit:]]*
constinteger [[:digit:]]+
conststring \"[^\"\n]*\"
@@ -76,7 +76,7 @@ while { return tWHILE; }
[>][=] { return tGE; }
[<][=] { return tLE; }
-{variable} { yylval.s = new Common::String(yytext); return VAR; }
+{identifier} { yylval.s = new Common::String(yytext); return ID; }
{constfloat} { yylval.f = atof(yytext); return FLOAT; }
{constinteger} { yylval.i = strtol(yytext, NULL, 10); return INT; }
{operator} { return *yytext; }