Skip to content

Commit

Permalink
DIRECTOR: Lingo: Simpler token constants
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent 81b056f commit 5db0d15
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 73 deletions.
75 changes: 37 additions & 38 deletions engines/director/lingo/lingo-gr.cpp
Expand Up @@ -72,12 +72,12 @@
FLOAT = 261,
VAR = 262,
STRING = 263,
OP_INTO = 264,
OP_TO = 265,
FUNC_MCI = 266,
FUNC_MCIWAIT = 267,
FUNC_PUT = 268,
FUNC_SET = 269
tINTO = 264,
tTO = 265,
tMCI = 266,
tMCIWAIT = 267,
tPUT = 268,
tSET = 269
};
#endif
/* Tokens. */
Expand All @@ -87,12 +87,12 @@
#define FLOAT 261
#define VAR 262
#define STRING 263
#define OP_INTO 264
#define OP_TO 265
#define FUNC_MCI 266
#define FUNC_MCIWAIT 267
#define FUNC_PUT 268
#define FUNC_SET 269
#define tINTO 264
#define tTO 265
#define tMCI 266
#define tMCIWAIT 267
#define tPUT 268
#define tSET 269



Expand Down Expand Up @@ -447,9 +447,9 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
0, 68, 68, 69, 72, 73, 74, 75, 76, 77,
80, 81, 82, 85, 88, 89, 90, 91, 92, 93,
94, 95, 96, 99, 100
0, 64, 64, 65, 68, 69, 70, 71, 72, 73,
76, 77, 78, 81, 84, 85, 86, 87, 88, 89,
90, 91, 92, 95, 96
};
#endif

Expand All @@ -459,10 +459,9 @@ static const yytype_uint8 yyrline[] =
static const char *const yytname[] =
{
"$end", "error", "$undefined", "UNARY", "UNDEF", "INT", "FLOAT", "VAR",
"STRING", "OP_INTO", "OP_TO", "FUNC_MCI", "FUNC_MCIWAIT", "FUNC_PUT",
"FUNC_SET", "'='", "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('",
"')'", "$accept", "program", "programline", "assign", "statement",
"expr", "func", 0
"STRING", "tINTO", "tTO", "tMCI", "tMCIWAIT", "tPUT", "tSET", "'='",
"'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('", "')'", "$accept",
"program", "programline", "assign", "statement", "expr", "func", 0
};
#endif

Expand Down Expand Up @@ -1377,93 +1376,93 @@ yyparse ()
switch (yyn)
{
case 6:
#line 74 "engines/director/lingo/lingo-gr.y"
#line 70 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_xpop); ;}
break;

case 8:
#line 76 "engines/director/lingo/lingo-gr.y"
#line 72 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_printtop); ;}
break;

case 10:
#line 80 "engines/director/lingo/lingo-gr.y"
#line 76 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(4) - (4)].s)->c_str()); g_lingo->code1(g_lingo->func_assign); (yyval.code) = (yyvsp[(2) - (4)].code); delete (yyvsp[(4) - (4)].s); ;}
break;

case 11:
#line 81 "engines/director/lingo/lingo-gr.y"
#line 77 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); g_lingo->code1(g_lingo->func_assign); (yyval.code) = (yyvsp[(4) - (4)].code); delete (yyvsp[(2) - (4)].s); ;}
break;

case 12:
#line 82 "engines/director/lingo/lingo-gr.y"
#line 78 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); g_lingo->code1(g_lingo->func_assign); (yyval.code) = (yyvsp[(4) - (4)].code); delete (yyvsp[(2) - (4)].s); ;}
break;

case 13:
#line 85 "engines/director/lingo/lingo-gr.y"
#line 81 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_xpop); ;}
break;

case 14:
#line 88 "engines/director/lingo/lingo-gr.y"
#line 84 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_constpush); inst i; WRITE_LE_UINT32(&i, (yyvsp[(1) - (1)].i)); (yyval.code) = g_lingo->code1(i); ;}
break;

case 15:
#line 89 "engines/director/lingo/lingo-gr.y"
#line 85 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); (yyval.code) = g_lingo->code1(g_lingo->func_eval); delete (yyvsp[(1) - (1)].s); ;}
break;

case 16:
#line 90 "engines/director/lingo/lingo-gr.y"
#line 86 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_add); ;}
break;

case 17:
#line 91 "engines/director/lingo/lingo-gr.y"
#line 87 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_sub); ;}
break;

case 18:
#line 92 "engines/director/lingo/lingo-gr.y"
#line 88 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_mul); ;}
break;

case 19:
#line 93 "engines/director/lingo/lingo-gr.y"
#line 89 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_div); ;}
break;

case 20:
#line 94 "engines/director/lingo/lingo-gr.y"
#line 90 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = (yyvsp[(2) - (2)].code); ;}
break;

case 21:
#line 95 "engines/director/lingo/lingo-gr.y"
#line 91 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->func_negate); ;}
break;

case 22:
#line 96 "engines/director/lingo/lingo-gr.y"
#line 92 "engines/director/lingo/lingo-gr.y"
{ (yyval.code) = (yyvsp[(2) - (3)].code); ;}
break;

case 23:
#line 99 "engines/director/lingo/lingo-gr.y"
#line 95 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_mci); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
break;

case 24:
#line 100 "engines/director/lingo/lingo-gr.y"
#line 96 "engines/director/lingo/lingo-gr.y"
{ g_lingo->code1(g_lingo->func_mciwait); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;}
break;


/* Line 1267 of yacc.c. */
#line 1467 "engines/director/lingo/lingo-gr.cpp"
#line 1466 "engines/director/lingo/lingo-gr.cpp"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
Expand Down Expand Up @@ -1677,6 +1676,6 @@ yyparse ()
}


#line 103 "engines/director/lingo/lingo-gr.y"
#line 99 "engines/director/lingo/lingo-gr.y"


24 changes: 12 additions & 12 deletions engines/director/lingo/lingo-gr.h
Expand Up @@ -45,12 +45,12 @@
FLOAT = 261,
VAR = 262,
STRING = 263,
OP_INTO = 264,
OP_TO = 265,
FUNC_MCI = 266,
FUNC_MCIWAIT = 267,
FUNC_PUT = 268,
FUNC_SET = 269
tINTO = 264,
tTO = 265,
tMCI = 266,
tMCIWAIT = 267,
tPUT = 268,
tSET = 269
};
#endif
/* Tokens. */
Expand All @@ -60,12 +60,12 @@
#define FLOAT 261
#define VAR 262
#define STRING 263
#define OP_INTO 264
#define OP_TO 265
#define FUNC_MCI 266
#define FUNC_MCIWAIT 267
#define FUNC_PUT 268
#define FUNC_SET 269
#define tINTO 264
#define tTO 265
#define tMCI 266
#define tMCIWAIT 267
#define tPUT 268
#define tSET 269



Expand Down
18 changes: 7 additions & 11 deletions engines/director/lingo/lingo-gr.y
Expand Up @@ -49,12 +49,8 @@ using namespace Director;
%token<i> INT
%token<f> FLOAT
%token<s> VAR STRING
%token OP_INTO
%token OP_TO
%token FUNC_MCI
%token FUNC_MCIWAIT
%token FUNC_PUT
%token FUNC_SET
%token tINTO tTO
%token tMCI tMCIWAIT tPUT tSET

%type<code> assign expr

Expand All @@ -77,9 +73,9 @@ programline:
| /* empty */
;

assign: FUNC_PUT expr OP_INTO VAR { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString($4->c_str()); g_lingo->code1(g_lingo->func_assign); $$ = $2; delete $4; }
| FUNC_SET VAR '=' expr { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString($2->c_str()); g_lingo->code1(g_lingo->func_assign); $$ = $4; delete $2; }
| FUNC_SET VAR OP_TO expr { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString($2->c_str()); g_lingo->code1(g_lingo->func_assign); $$ = $4; delete $2; }
assign: tPUT expr tINTO VAR { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString($4->c_str()); g_lingo->code1(g_lingo->func_assign); $$ = $2; delete $4; }
| tSET VAR '=' expr { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString($2->c_str()); g_lingo->code1(g_lingo->func_assign); $$ = $4; delete $2; }
| tSET VAR tTO expr { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString($2->c_str()); g_lingo->code1(g_lingo->func_assign); $$ = $4; delete $2; }
;

statement: expr { g_lingo->code1(g_lingo->func_xpop); }
Expand All @@ -96,8 +92,8 @@ expr: INT { g_lingo->code1(g_lingo->func_constpush); inst i; WRITE_LE_UINT3
| '(' expr ')' { $$ = $2; }
;

func: FUNC_MCI STRING { g_lingo->code1(g_lingo->func_mci); g_lingo->codeString($2->c_str()); delete $2; }
| FUNC_MCIWAIT VAR { g_lingo->code1(g_lingo->func_mciwait); g_lingo->codeString($2->c_str()); delete $2; }
func: tMCI STRING { g_lingo->code1(g_lingo->func_mci); g_lingo->codeString($2->c_str()); delete $2; }
| tMCIWAIT VAR { g_lingo->code1(g_lingo->func_mciwait); g_lingo->codeString($2->c_str()); delete $2; }
;

%%
12 changes: 6 additions & 6 deletions engines/director/lingo/lingo-lex.cpp
Expand Up @@ -802,32 +802,32 @@ YY_RULE_SETUP
case 4:
YY_RULE_SETUP
#line 50 "engines/director/lingo/lingo-lex.l"
{ return OP_INTO; }
{ return tINTO; }
YY_BREAK
case 5:
YY_RULE_SETUP
#line 51 "engines/director/lingo/lingo-lex.l"
{ return FUNC_MCI; }
{ return tMCI; }
YY_BREAK
case 6:
YY_RULE_SETUP
#line 52 "engines/director/lingo/lingo-lex.l"
{ return FUNC_MCIWAIT; }
{ return tMCIWAIT; }
YY_BREAK
case 7:
YY_RULE_SETUP
#line 53 "engines/director/lingo/lingo-lex.l"
{ return FUNC_PUT; }
{ return tPUT; }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 54 "engines/director/lingo/lingo-lex.l"
{ return FUNC_SET; }
{ return tSET; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 55 "engines/director/lingo/lingo-lex.l"
{ return OP_TO; }
{ return tTO; }
YY_BREAK
case 10:
YY_RULE_SETUP
Expand Down
12 changes: 6 additions & 6 deletions engines/director/lingo/lingo-lex.l
Expand Up @@ -47,12 +47,12 @@ whitespace [\t ]
--[^\r\n]*
^{whitespace}
[\t]+ { return ' '; }
into { return OP_INTO; }
mci { return FUNC_MCI; }
mciwait { return FUNC_MCIWAIT; }
put { return FUNC_PUT; }
set { return FUNC_SET; }
to { return OP_TO; }
into { return tINTO; }
mci { return tMCI; }
mciwait { return tMCIWAIT; }
put { return tPUT; }
set { return tSET; }
to { return tTO; }
{variable} { yylval.s = new Common::String(yytext); return VAR; }
{constfloat} { yylval.f = atof(yytext); return FLOAT; }
Expand Down

0 comments on commit 5db0d15

Please sign in to comment.