diff options
author | Eugene Sandulenko | 2016-06-20 18:59:26 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | db2380077fee7b6bccba4262fa25f55e50a2981a (patch) | |
tree | 6b7f4e9d69311f433ddcc8f6b9506f47886f686f | |
parent | a7ec15f77affc6ec9ee6f08d3e4a4b4d697770ac (diff) | |
download | scummvm-rg350-db2380077fee7b6bccba4262fa25f55e50a2981a.tar.gz scummvm-rg350-db2380077fee7b6bccba4262fa25f55e50a2981a.tar.bz2 scummvm-rg350-db2380077fee7b6bccba4262fa25f55e50a2981a.zip |
DIRECTOR: Lingo: Implement logical operators
-rw-r--r-- | engines/director/lingo/lingo-funcs.cpp | 49 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.cpp | 375 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.h | 16 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.y | 9 | ||||
-rw-r--r-- | engines/director/lingo/lingo-lex.cpp | 206 | ||||
-rw-r--r-- | engines/director/lingo/lingo-lex.l | 6 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 6 |
7 files changed, 416 insertions, 251 deletions
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp index cd399f7100..3e3d8858b0 100644 --- a/engines/director/lingo/lingo-funcs.cpp +++ b/engines/director/lingo/lingo-funcs.cpp @@ -341,6 +341,55 @@ void Lingo::func_negate() { g_lingo->push(d); } +void Lingo::func_eq() { + Datum d2 = g_lingo->pop(); + Datum d1 = g_lingo->pop(); + + d1.val = (d1.val == d2.val) ? 1 : 0; + g_lingo->push(d1); +} + +void Lingo::func_neq() { + Datum d2 = g_lingo->pop(); + Datum d1 = g_lingo->pop(); + + d1.val = (d1.val != d2.val) ? 1 : 0; + g_lingo->push(d1); +} + +void Lingo::func_gt() { + Datum d2 = g_lingo->pop(); + Datum d1 = g_lingo->pop(); + + d1.val = (d1.val > d2.val) ? 1 : 0; + g_lingo->push(d1); +} + +void Lingo::func_lt() { + Datum d2 = g_lingo->pop(); + Datum d1 = g_lingo->pop(); + + d1.val = (d1.val < d2.val) ? 1 : 0; + g_lingo->push(d1); +} + +void Lingo::func_ge() { + Datum d2 = g_lingo->pop(); + Datum d1 = g_lingo->pop(); + + d1.val = (d1.val >= d2.val) ? 1 : 0; + g_lingo->push(d1); +} + +void Lingo::func_le() { + Datum d2 = g_lingo->pop(); + Datum d1 = g_lingo->pop(); + + d1.val = (d1.val <= d2.val) ? 1 : 0; + g_lingo->push(d1); +} + + void Lingo::func_ifcode() { Datum d; int savepc = g_lingo->_pc; /* then part */ diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index c4cddd37d8..0e69b677c2 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -87,7 +87,13 @@ tPUT = 276, tSET = 277, tTHEN = 278, - tTO = 279 + tTO = 279, + tGE = 280, + tLE = 281, + tGT = 282, + tLT = 283, + tEQ = 284, + tNEQ = 285 }; #endif /* Tokens. */ @@ -113,6 +119,12 @@ #define tSET 277 #define tTHEN 278 #define tTO 279 +#define tGE 280 +#define tLE 281 +#define tGT 282 +#define tLT 283 +#define tEQ 284 +#define tNEQ 285 @@ -163,7 +175,7 @@ typedef union YYSTYPE int code; } /* Line 193 of yacc.c. */ -#line 167 "engines/director/lingo/lingo-gr.cpp" +#line 179 "engines/director/lingo/lingo-gr.cpp" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -176,7 +188,7 @@ typedef union YYSTYPE /* Line 216 of yacc.c. */ -#line 180 "engines/director/lingo/lingo-gr.cpp" +#line 192 "engines/director/lingo/lingo-gr.cpp" #ifdef short # undef short @@ -391,20 +403,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 38 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 89 +#define YYLAST 164 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 34 +#define YYNTOKENS 42 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 14 /* YYNRULES -- Number of rules. */ -#define YYNRULES 47 +#define YYNRULES 53 /* YYNRULES -- Number of states. */ -#define YYNSTATES 77 +#define YYNSTATES 89 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 279 +#define YYMAXUTOK 285 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -413,12 +425,12 @@ union yyalloc static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 31, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 37, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 30, 2, 2, - 32, 33, 28, 26, 2, 27, 2, 29, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 36, 2, 2, + 40, 41, 34, 32, 2, 33, 2, 35, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 25, 2, 2, 2, 2, 2, 2, 2, 2, + 39, 31, 38, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -439,7 +451,8 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30 }; #if YYDEBUG @@ -449,39 +462,43 @@ static const yytype_uint8 yyprhs[] = { 0, 0, 3, 7, 9, 10, 12, 14, 16, 18, 20, 21, 26, 31, 36, 38, 46, 48, 50, 54, - 58, 62, 66, 69, 72, 76, 78, 80, 81, 82, - 85, 88, 91, 94, 97, 99, 102, 105, 108, 111, - 115, 118, 122, 125, 128, 130, 134, 137 + 58, 62, 66, 70, 74, 78, 82, 86, 89, 92, + 96, 98, 102, 104, 105, 106, 109, 112, 115, 118, + 121, 123, 126, 129, 132, 135, 139, 142, 146, 149, + 152, 154, 158, 161 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 35, 0, -1, 36, 31, 35, -1, 36, -1, -1, - 44, -1, 37, -1, 38, -1, 39, -1, 1, -1, - -1, 21, 39, 13, 7, -1, 22, 7, 25, 39, - -1, 22, 7, 24, 39, -1, 39, -1, 41, 40, - 23, 43, 42, 10, 9, -1, 5, -1, 7, -1, - 39, 26, 39, -1, 39, 27, 39, -1, 39, 28, - 39, -1, 39, 29, 39, -1, 26, 39, -1, 27, - 39, -1, 32, 39, 33, -1, 39, -1, 9, -1, - -1, -1, 43, 31, -1, 43, 38, -1, 15, 8, - -1, 16, 7, -1, 21, 39, -1, 45, -1, 12, - 14, -1, 12, 18, -1, 12, 20, -1, 12, 46, - -1, 12, 46, 47, -1, 12, 47, -1, 24, 11, - 8, -1, 11, 8, -1, 24, 8, -1, 8, -1, - 19, 17, 8, -1, 17, 8, -1, 24, 17, 8, - -1 + 43, 0, -1, 44, 37, 43, -1, 44, -1, -1, + 52, -1, 45, -1, 46, -1, 47, -1, 1, -1, + -1, 21, 47, 13, 7, -1, 22, 7, 31, 47, + -1, 22, 7, 24, 47, -1, 47, -1, 49, 48, + 23, 51, 50, 10, 9, -1, 5, -1, 7, -1, + 47, 32, 47, -1, 47, 33, 47, -1, 47, 34, + 47, -1, 47, 35, 47, -1, 47, 38, 47, -1, + 47, 39, 47, -1, 47, 30, 47, -1, 47, 25, + 47, -1, 47, 26, 47, -1, 32, 47, -1, 33, + 47, -1, 40, 47, 41, -1, 47, -1, 47, 31, + 47, -1, 9, -1, -1, -1, 51, 37, -1, 51, + 46, -1, 15, 8, -1, 16, 7, -1, 21, 47, + -1, 53, -1, 12, 14, -1, 12, 18, -1, 12, + 20, -1, 12, 54, -1, 12, 54, 55, -1, 12, + 55, -1, 24, 11, 8, -1, 11, 8, -1, 24, + 8, -1, 8, -1, 19, 17, 8, -1, 17, 8, + -1, 24, 17, 8, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 89, 89, 90, 93, 94, 95, 96, 97, 98, - 99, 102, 103, 104, 107, 108, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 127, 129, 131, 133, 134, - 135, 138, 139, 140, 141, 152, 153, 154, 155, 156, - 157, 160, 161, 162, 163, 166, 167, 168 + 0, 90, 90, 91, 94, 95, 96, 97, 98, 99, + 100, 103, 104, 105, 108, 109, 117, 118, 119, 120, + 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, + 133, 134, 136, 138, 140, 141, 142, 145, 146, 147, + 148, 159, 160, 161, 162, 163, 164, 167, 168, 169, + 170, 173, 174, 175 }; #endif @@ -493,10 +510,10 @@ static const char *const yytname[] = "$end", "error", "$undefined", "UNARY", "UNDEF", "INT", "FLOAT", "VAR", "STRING", "tIF", "tEND", "tFRAME", "tGO", "tINTO", "tLOOP", "tMCI", "tMCIWAIT", "tMOVIE", "tNEXT", "tOF", "tPREVIOUS", "tPUT", "tSET", - "tTHEN", "tTO", "'='", "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('", - "')'", "$accept", "program", "programline", "assign", "stmt", "expr", - "cond", "if", "end", "stmtlist", "func", "gotofunc", "gotoframe", - "gotomovie", 0 + "tTHEN", "tTO", "tGE", "tLE", "tGT", "tLT", "tEQ", "tNEQ", "'='", "'+'", + "'-'", "'*'", "'/'", "'%'", "'\\n'", "'>'", "'<'", "'('", "')'", + "$accept", "program", "programline", "assign", "stmt", "expr", "cond", + "if", "end", "stmtlist", "func", "gotofunc", "gotoframe", "gotomovie", 0 }; #endif @@ -507,19 +524,21 @@ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 61, 43, 45, 42, 47, - 37, 10, 40, 41 + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 61, 43, 45, 42, 47, 37, 10, 62, 60, + 40, 41 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 34, 35, 35, 36, 36, 36, 36, 36, 36, - 36, 37, 37, 37, 38, 38, 39, 39, 39, 39, - 39, 39, 39, 39, 39, 40, 41, 42, 43, 43, - 43, 44, 44, 44, 44, 45, 45, 45, 45, 45, - 45, 46, 46, 46, 46, 47, 47, 47 + 0, 42, 43, 43, 44, 44, 44, 44, 44, 44, + 44, 45, 45, 45, 46, 46, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 48, 48, 49, 50, 51, 51, 51, 52, 52, 52, + 52, 53, 53, 53, 53, 53, 53, 54, 54, 54, + 54, 55, 55, 55 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -527,9 +546,10 @@ static const yytype_uint8 yyr2[] = { 0, 2, 3, 1, 0, 1, 1, 1, 1, 1, 0, 4, 4, 4, 1, 7, 1, 1, 3, 3, - 3, 3, 2, 2, 3, 1, 1, 0, 0, 2, - 2, 2, 2, 2, 1, 2, 2, 2, 2, 3, - 2, 3, 2, 2, 1, 3, 2, 3 + 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, + 1, 3, 1, 0, 0, 2, 2, 2, 2, 2, + 1, 2, 2, 2, 2, 3, 2, 3, 2, 2, + 1, 3, 2, 3 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -537,43 +557,45 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 9, 16, 17, 26, 0, 0, 0, 0, 0, + 0, 9, 16, 17, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 7, 8, 0, 5, - 34, 44, 0, 35, 0, 36, 0, 37, 0, 38, - 40, 31, 32, 33, 0, 22, 23, 0, 1, 0, - 0, 0, 0, 0, 25, 0, 42, 46, 0, 43, - 0, 0, 0, 39, 0, 0, 0, 24, 2, 18, - 19, 20, 21, 28, 45, 41, 47, 11, 13, 12, - 27, 29, 30, 14, 0, 0, 15 + 40, 50, 0, 41, 0, 42, 0, 43, 0, 44, + 46, 37, 38, 39, 0, 27, 28, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, + 0, 48, 52, 0, 49, 0, 0, 0, 45, 0, + 0, 0, 29, 2, 25, 26, 24, 18, 19, 20, + 21, 22, 23, 0, 34, 51, 47, 53, 11, 13, + 12, 31, 33, 35, 36, 14, 0, 0, 15 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 13, 14, 15, 16, 17, 45, 18, 74, 70, + -1, 13, 14, 15, 16, 17, 50, 18, 86, 82, 19, 20, 29, 30 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -19 +#define YYPACT_NINF -24 static const yytype_int8 yypact[] = { - 37, -19, -19, -19, -19, 5, -7, 8, 4, 13, - 4, 4, 4, 12, -10, -19, -19, 60, 4, -19, - -19, -19, 18, -19, 19, -19, 11, -19, -3, 61, - -19, -19, -19, 44, -18, -19, -19, 48, -19, 37, - 4, 4, 4, 4, 60, 17, -19, -19, 42, -19, - 43, 46, 28, -19, 49, 4, 4, -19, -19, -11, - -11, -19, -19, -19, -19, -19, -19, -19, 60, 60, - 34, -19, -19, 60, 45, 58, -19 + 54, -24, -24, -24, -24, 107, -3, 2, 18, 6, + 18, 18, 18, 17, -11, -24, -24, 114, 18, -24, + -24, -24, 19, -24, 20, -24, 13, -24, 4, 5, + -24, -24, -24, 67, -23, -19, -19, 78, -24, 54, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 103, + 8, -24, -24, 35, -24, 36, 37, 30, -24, 41, + 18, 18, -24, -24, 114, 114, 114, 125, 125, -19, + -19, 114, 114, 18, -24, -24, -24, -24, -24, 114, + 114, 114, 9, -24, -24, 114, 46, 48, -24 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -19, 40, -19, -19, 14, -8, -19, -19, -19, -19, - -19, -19, -19, 53 + -24, 21, -24, -24, -20, -8, -24, -24, -24, -24, + -24, -24, -24, 38 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -583,28 +605,44 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -5 static const yytype_int8 yytable[] = { - 33, 31, 35, 36, 37, 49, 55, 56, 50, 2, - 44, 3, 38, 21, 51, 32, 22, 42, 43, 23, - 34, 39, 24, 25, 26, 27, 46, 47, 48, 28, - 10, 11, 59, 60, 61, 62, 12, -4, 1, 2, - 63, 3, 2, 4, 3, 51, 4, 68, 69, 5, - 64, 65, 6, 7, 66, 75, 67, 54, 8, 9, - 10, 11, 73, 10, 11, 71, 12, 76, -4, 12, - 40, 41, 42, 43, 40, 41, 42, 43, 24, 58, - 26, 57, 53, 0, 72, 52, 40, 41, 42, 43 + 33, 60, 35, 36, 37, 31, 40, 41, 61, 32, + 49, 42, 54, 34, 2, 55, 3, 38, 4, 47, + 48, 56, 24, 2, 26, 3, 39, 51, 52, 57, + 53, 74, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 10, 11, 75, 76, 77, 83, 56, 78, 12, + 10, 11, 79, 80, -4, 1, 87, 88, 12, 2, + 63, 3, 84, 4, 0, 81, 5, 58, 0, 6, + 7, 0, 0, 0, 85, 8, 9, 0, 0, 0, + 59, 0, 0, 0, 0, 0, 10, 11, 0, 0, + 0, -4, 40, 41, 12, 0, 0, 42, 0, 43, + 44, 45, 46, 40, 41, 47, 48, 0, 42, 0, + 43, 44, 45, 46, 0, 21, 47, 48, 22, 62, + 0, 23, 0, 0, 24, 25, 26, 27, 40, 41, + 0, 28, 0, 42, 73, 43, 44, 45, 46, 40, + 41, 47, 48, 0, 42, 0, 43, 44, 45, 46, + 40, 41, 47, 48, 0, 42, 0, 0, 0, 45, + 46, 0, 0, 47, 48 }; static const yytype_int8 yycheck[] = { - 8, 8, 10, 11, 12, 8, 24, 25, 11, 5, - 18, 7, 0, 8, 17, 7, 11, 28, 29, 14, - 7, 31, 17, 18, 19, 20, 8, 8, 17, 24, - 26, 27, 40, 41, 42, 43, 32, 0, 1, 5, - 23, 7, 5, 9, 7, 17, 9, 55, 56, 12, - 8, 8, 15, 16, 8, 10, 7, 13, 21, 22, - 26, 27, 70, 26, 27, 31, 32, 9, 31, 32, - 26, 27, 28, 29, 26, 27, 28, 29, 17, 39, - 19, 33, 29, -1, 70, 24, 26, 27, 28, 29 + 8, 24, 10, 11, 12, 8, 25, 26, 31, 7, + 18, 30, 8, 7, 5, 11, 7, 0, 9, 38, + 39, 17, 17, 5, 19, 7, 37, 8, 8, 24, + 17, 23, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 32, 33, 8, 8, 8, 37, 17, 7, 40, + 32, 33, 60, 61, 0, 1, 10, 9, 40, 5, + 39, 7, 82, 9, -1, 73, 12, 29, -1, 15, + 16, -1, -1, -1, 82, 21, 22, -1, -1, -1, + 13, -1, -1, -1, -1, -1, 32, 33, -1, -1, + -1, 37, 25, 26, 40, -1, -1, 30, -1, 32, + 33, 34, 35, 25, 26, 38, 39, -1, 30, -1, + 32, 33, 34, 35, -1, 8, 38, 39, 11, 41, + -1, 14, -1, -1, 17, 18, 19, 20, 25, 26, + -1, 24, -1, 30, 31, 32, 33, 34, 35, 25, + 26, 38, 39, -1, 30, -1, 32, 33, 34, 35, + 25, 26, 38, 39, -1, 30, -1, -1, -1, 34, + 35, -1, -1, 38, 39 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -612,13 +650,14 @@ static const yytype_int8 yycheck[] = static const yytype_uint8 yystos[] = { 0, 1, 5, 7, 9, 12, 15, 16, 21, 22, - 26, 27, 32, 35, 36, 37, 38, 39, 41, 44, - 45, 8, 11, 14, 17, 18, 19, 20, 24, 46, - 47, 8, 7, 39, 7, 39, 39, 39, 0, 31, - 26, 27, 28, 29, 39, 40, 8, 8, 17, 8, - 11, 17, 24, 47, 13, 24, 25, 33, 35, 39, - 39, 39, 39, 23, 8, 8, 8, 7, 39, 39, - 43, 31, 38, 39, 42, 10, 9 + 32, 33, 40, 43, 44, 45, 46, 47, 49, 52, + 53, 8, 11, 14, 17, 18, 19, 20, 24, 54, + 55, 8, 7, 47, 7, 47, 47, 47, 0, 37, + 25, 26, 30, 32, 33, 34, 35, 38, 39, 47, + 48, 8, 8, 17, 8, 11, 17, 24, 55, 13, + 24, 31, 41, 43, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 31, 23, 8, 8, 8, 7, 47, + 47, 47, 51, 37, 46, 47, 50, 10, 9 }; #define yyerrok (yyerrstatus = 0) @@ -1433,42 +1472,42 @@ yyreduce: switch (yyn) { case 6: -#line 95 "engines/director/lingo/lingo-gr.y" +#line 96 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_xpop); ;} break; case 8: -#line 97 "engines/director/lingo/lingo-gr.y" +#line 98 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_printtop); ;} break; case 9: -#line 98 "engines/director/lingo/lingo-gr.y" +#line 99 "engines/director/lingo/lingo-gr.y" { yyerrok; ;} break; case 11: -#line 102 "engines/director/lingo/lingo-gr.y" +#line 103 "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 12: -#line 103 "engines/director/lingo/lingo-gr.y" +#line 104 "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 104 "engines/director/lingo/lingo-gr.y" +#line 105 "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 14: -#line 107 "engines/director/lingo/lingo-gr.y" +#line 108 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_xpop); ;} break; case 15: -#line 108 "engines/director/lingo/lingo-gr.y" +#line 109 "engines/director/lingo/lingo-gr.y" { inst then, end; WRITE_LE_UINT32(&then, (yyvsp[(4) - (7)].code)); @@ -1478,153 +1517,183 @@ yyreduce: break; case 16: -#line 116 "engines/director/lingo/lingo-gr.y" +#line 117 "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 17: -#line 117 "engines/director/lingo/lingo-gr.y" +#line 118 "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 18: -#line 118 "engines/director/lingo/lingo-gr.y" +#line 119 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_add); ;} break; case 19: -#line 119 "engines/director/lingo/lingo-gr.y" +#line 120 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_sub); ;} break; case 20: -#line 120 "engines/director/lingo/lingo-gr.y" +#line 121 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_mul); ;} break; case 21: -#line 121 "engines/director/lingo/lingo-gr.y" +#line 122 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_div); ;} break; case 22: -#line 122 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = (yyvsp[(2) - (2)].code); ;} +#line 123 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->func_gt); ;} break; case 23: -#line 123 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->func_negate); ;} +#line 124 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->func_lt); ;} break; case 24: -#line 124 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = (yyvsp[(2) - (3)].code); ;} +#line 125 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->func_neq); ;} break; case 25: -#line 127 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(STOP); ;} +#line 126 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->func_ge); ;} break; case 26: -#line 129 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = g_lingo->code1(g_lingo->func_ifcode); g_lingo->code3(STOP,STOP,STOP); ;} +#line 127 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(g_lingo->func_le); ;} break; case 27: -#line 131 "engines/director/lingo/lingo-gr.y" - { g_lingo->code1(STOP); (yyval.code) = g_lingo->_currentScript->size(); ;} +#line 128 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = (yyvsp[(2) - (2)].code); ;} break; case 28: +#line 129 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->func_negate); ;} + break; + + case 29: +#line 130 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = (yyvsp[(2) - (3)].code); ;} + break; + + case 30: #line 133 "engines/director/lingo/lingo-gr.y" - { (yyval.code) = g_lingo->_currentScript->size(); ;} + { g_lingo->code1(STOP); ;} break; case 31: -#line 138 "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); ;} +#line 134 "engines/director/lingo/lingo-gr.y" + { g_lingo->code2(g_lingo->func_eq, STOP); ;} break; case 32: -#line 139 "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); ;} +#line 136 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = g_lingo->code1(g_lingo->func_ifcode); g_lingo->code3(STOP,STOP,STOP); ;} break; case 33: +#line 138 "engines/director/lingo/lingo-gr.y" + { g_lingo->code1(STOP); (yyval.code) = g_lingo->_currentScript->size(); ;} + break; + + case 34: #line 140 "engines/director/lingo/lingo-gr.y" + { (yyval.code) = g_lingo->_currentScript->size(); ;} + break; + + case 37: +#line 145 "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 38: +#line 146 "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; + + case 39: +#line 147 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_printtop); ;} break; - case 35: -#line 152 "engines/director/lingo/lingo-gr.y" + case 41: +#line 159 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_gotoloop); ;} break; - case 36: -#line 153 "engines/director/lingo/lingo-gr.y" + case 42: +#line 160 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_gotonext); ;} break; - case 37: -#line 154 "engines/director/lingo/lingo-gr.y" + case 43: +#line 161 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_gotoprevious); ;} break; - case 38: -#line 155 "engines/director/lingo/lingo-gr.y" + case 44: +#line 162 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_goto); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); g_lingo->codeString(""); delete (yyvsp[(2) - (2)].s); ;} break; - case 39: -#line 156 "engines/director/lingo/lingo-gr.y" + case 45: +#line 163 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_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 40: -#line 157 "engines/director/lingo/lingo-gr.y" + case 46: +#line 164 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_goto); g_lingo->codeString(""); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;} break; - case 41: -#line 160 "engines/director/lingo/lingo-gr.y" + case 47: +#line 167 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 42: -#line 161 "engines/director/lingo/lingo-gr.y" + case 48: +#line 168 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 43: -#line 162 "engines/director/lingo/lingo-gr.y" + case 49: +#line 169 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 44: -#line 163 "engines/director/lingo/lingo-gr.y" + case 50: +#line 170 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(1) - (1)].s); ;} break; - case 45: -#line 166 "engines/director/lingo/lingo-gr.y" + case 51: +#line 173 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 46: -#line 167 "engines/director/lingo/lingo-gr.y" + case 52: +#line 174 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 47: -#line 168 "engines/director/lingo/lingo-gr.y" + case 53: +#line 175 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; /* Line 1267 of yacc.c. */ -#line 1628 "engines/director/lingo/lingo-gr.cpp" +#line 1697 "engines/director/lingo/lingo-gr.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1838,6 +1907,6 @@ yyreturn: } -#line 198 "engines/director/lingo/lingo-gr.y" +#line 205 "engines/director/lingo/lingo-gr.y" diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h index 6261f6ce91..6f59a5f833 100644 --- a/engines/director/lingo/lingo-gr.h +++ b/engines/director/lingo/lingo-gr.h @@ -60,7 +60,13 @@ tPUT = 276, tSET = 277, tTHEN = 278, - tTO = 279 + tTO = 279, + tGE = 280, + tLE = 281, + tGT = 282, + tLT = 283, + tEQ = 284, + tNEQ = 285 }; #endif /* Tokens. */ @@ -86,6 +92,12 @@ #define tSET 277 #define tTHEN 278 #define tTO 279 +#define tGE 280 +#define tLE 281 +#define tGT 282 +#define tLT 283 +#define tEQ 284 +#define tNEQ 285 @@ -100,7 +112,7 @@ typedef union YYSTYPE int code; } /* Line 1529 of yacc.c. */ -#line 104 "engines/director/lingo/lingo-gr.hpp" +#line 116 "engines/director/lingo/lingo-gr.hpp" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index 76a706af5d..1bf3c9eec8 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -75,6 +75,7 @@ using namespace Director; %token<s> VAR STRING %token tIF tEND tFRAME tGO tINTO tLOOP tMCI tMCIWAIT tMOVIE tNEXT tOF tPREVIOUS %token tPUT tSET tTHEN tTO +%token tGE tLE tGT tLT tEQ tNEQ %type<code> assign cond expr if end stmtlist %type<s> gotoframe gotomovie @@ -119,12 +120,18 @@ expr: INT { g_lingo->code1(g_lingo->func_constpush); inst i; WRITE_LE_UINT3 | expr '-' expr { g_lingo->code1(g_lingo->func_sub); } | expr '*' expr { g_lingo->code1(g_lingo->func_mul); } | expr '/' expr { g_lingo->code1(g_lingo->func_div); } + | expr '>' expr { g_lingo->code1(g_lingo->func_gt); } + | expr '<' expr { g_lingo->code1(g_lingo->func_lt); } + | expr tNEQ expr { g_lingo->code1(g_lingo->func_neq); } + | expr tGE expr { g_lingo->code1(g_lingo->func_ge); } + | expr tLE expr { g_lingo->code1(g_lingo->func_le); } | '+' expr %prec UNARY { $$ = $2; } | '-' expr %prec UNARY { $$ = $2; g_lingo->code1(g_lingo->func_negate); } | '(' expr ')' { $$ = $2; } ; -cond: expr { g_lingo->code1(STOP); } +cond: expr { g_lingo->code1(STOP); } + | expr '=' expr { g_lingo->code2(g_lingo->func_eq, STOP); } ; if: tIF { $$ = g_lingo->code1(g_lingo->func_ifcode); g_lingo->code3(STOP,STOP,STOP); } ; diff --git a/engines/director/lingo/lingo-lex.cpp b/engines/director/lingo/lingo-lex.cpp index ef0fe50832..1bde391ea3 100644 --- a/engines/director/lingo/lingo-lex.cpp +++ b/engines/director/lingo/lingo-lex.cpp @@ -364,8 +364,8 @@ static void yy_fatal_error (yyconst char msg[] ); *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 26 -#define YY_END_OF_BUFFER 27 +#define YY_NUM_RULES 29 +#define YY_END_OF_BUFFER 30 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -373,16 +373,17 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[79] = +static yyconst flex_int16_t yy_accept[85] = { 0, - 0, 0, 27, 26, 3, 24, 26, 23, 23, 22, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 2, 2, 3, 24, 0, 25, 1, 21, - 22, 20, 20, 20, 7, 4, 20, 20, 20, 20, - 20, 14, 20, 20, 20, 20, 19, 1, 21, 5, - 20, 20, 20, 10, 20, 20, 20, 16, 17, 20, - 20, 8, 9, 20, 20, 13, 20, 18, 6, 20, - 12, 20, 20, 20, 11, 20, 15, 0 + 0, 0, 30, 29, 3, 27, 29, 29, 26, 26, + 25, 26, 26, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 2, 2, 3, 27, 20, + 0, 28, 1, 24, 25, 22, 21, 23, 23, 23, + 7, 4, 23, 23, 23, 23, 23, 14, 23, 23, + 23, 23, 19, 1, 24, 5, 23, 23, 23, 10, + 23, 23, 23, 16, 17, 23, 23, 8, 9, 23, + 23, 13, 23, 18, 6, 23, 12, 23, 23, 23, + 11, 23, 15, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -390,17 +391,17 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 5, 1, 6, 1, 1, 7, 1, 1, 7, - 7, 7, 7, 7, 8, 9, 7, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 7, 1, 1, - 7, 1, 1, 1, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 1, 1, 1, 7, 11, 1, 12, 11, 13, 14, - - 15, 16, 17, 18, 19, 11, 11, 20, 21, 22, - 23, 24, 11, 25, 26, 27, 28, 29, 30, 31, - 11, 11, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 5, 6, 7, 1, 1, 8, 1, 1, 8, + 8, 8, 8, 8, 9, 10, 8, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 8, 1, 12, + 13, 14, 1, 1, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 1, 1, 1, 8, 15, 1, 16, 15, 17, 18, + + 19, 20, 21, 22, 23, 15, 15, 24, 25, 26, + 27, 28, 15, 29, 30, 31, 32, 33, 34, 35, + 15, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -417,76 +418,78 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[32] = +static yyconst flex_int32_t yy_meta[36] = { 0, - 1, 1, 2, 3, 1, 1, 1, 1, 1, 4, + 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, + 4, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4 + 4, 4, 4, 4, 4 } ; -static yyconst flex_int16_t yy_base[82] = +static yyconst flex_int16_t yy_base[88] = { 0, - 0, 30, 99, 100, 96, 30, 91, 100, 88, 27, - 0, 73, 69, 70, 22, 69, 26, 76, 74, 15, - 74, 23, 86, 100, 85, 44, 80, 100, 0, 75, - 41, 0, 70, 71, 0, 0, 55, 58, 61, 50, - 47, 0, 62, 49, 48, 59, 0, 0, 63, 0, - 51, 48, 46, 39, 49, 40, 37, 0, 0, 43, - 49, 0, 0, 51, 47, 0, 42, 0, 0, 41, - 0, 35, 30, 25, 0, 19, 0, 100, 51, 38, - 55 + 0, 34, 106, 107, 103, 34, 91, 96, 107, 93, + 30, 88, 87, 0, 73, 69, 70, 22, 69, 26, + 76, 74, 15, 74, 23, 90, 107, 89, 48, 107, + 83, 107, 0, 78, 44, 107, 107, 0, 70, 71, + 0, 0, 55, 58, 61, 50, 47, 0, 62, 49, + 48, 59, 0, 0, 66, 0, 51, 48, 46, 39, + 49, 40, 37, 0, 0, 43, 49, 0, 0, 51, + 47, 0, 42, 0, 0, 41, 0, 35, 30, 25, + 0, 19, 0, 107, 55, 42, 59 } ; -static yyconst flex_int16_t yy_def[82] = +static yyconst flex_int16_t yy_def[88] = { 0, - 78, 1, 78, 78, 78, 78, 79, 78, 78, 78, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 78, 78, 78, 78, 79, 78, 81, 78, - 78, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 81, 78, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, - 80, 80, 80, 80, 80, 80, 80, 0, 78, 78, - 78 + 84, 1, 84, 84, 84, 84, 84, 85, 84, 84, + 84, 84, 84, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 84, 84, 84, 84, 84, + 85, 84, 87, 84, 84, 84, 84, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 87, 84, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 0, 84, 84, 84 } ; -static yyconst flex_int16_t yy_nxt[132] = +static yyconst flex_int16_t yy_nxt[143] = { 0, - 4, 5, 6, 6, 4, 7, 8, 9, 4, 10, - 11, 11, 11, 11, 12, 13, 14, 11, 15, 16, - 17, 18, 19, 20, 11, 21, 22, 11, 11, 11, - 11, 23, 26, 26, 24, 30, 31, 36, 39, 43, - 46, 32, 44, 37, 77, 47, 26, 26, 40, 30, - 31, 27, 76, 27, 27, 48, 75, 74, 48, 73, - 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, - 62, 61, 49, 60, 59, 58, 57, 56, 55, 54, - 53, 52, 51, 50, 49, 28, 25, 25, 45, 42, - 41, 38, 35, 34, 33, 29, 28, 25, 78, 3, - - 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, - 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, - 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, - 78 + 4, 5, 6, 6, 4, 7, 8, 9, 10, 4, + 11, 12, 9, 13, 14, 14, 14, 14, 15, 16, + 17, 14, 18, 19, 20, 21, 22, 23, 14, 24, + 25, 14, 14, 14, 14, 26, 29, 29, 27, 34, + 35, 42, 45, 49, 52, 38, 50, 43, 83, 53, + 29, 29, 46, 34, 35, 31, 82, 31, 31, 54, + 81, 80, 54, 79, 78, 77, 76, 75, 74, 73, + 72, 71, 70, 69, 68, 67, 55, 66, 65, 64, + 63, 62, 61, 60, 59, 58, 57, 56, 55, 32, + 28, 28, 51, 48, 47, 44, 41, 40, 39, 37, + + 36, 33, 32, 30, 28, 84, 3, 84, 84, 84, + 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, + 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, + 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, + 84, 84 } ; -static yyconst flex_int16_t yy_chk[132] = +static yyconst flex_int16_t yy_chk[143] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 6, 6, 2, 10, 10, 15, 17, 20, - 22, 80, 20, 15, 76, 22, 26, 26, 17, 31, - 31, 79, 74, 79, 79, 81, 73, 72, 81, 70, - 67, 65, 64, 61, 60, 57, 56, 55, 54, 53, - 52, 51, 49, 46, 45, 44, 43, 41, 40, 39, - 38, 37, 34, 33, 30, 27, 25, 23, 21, 19, - 18, 16, 14, 13, 12, 9, 7, 5, 3, 78, - - 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, - 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, - 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, - 78 + 1, 1, 1, 1, 1, 2, 6, 6, 2, 11, + 11, 18, 20, 23, 25, 86, 23, 18, 82, 25, + 29, 29, 20, 35, 35, 85, 80, 85, 85, 87, + 79, 78, 87, 76, 73, 71, 70, 67, 66, 63, + 62, 61, 60, 59, 58, 57, 55, 52, 51, 50, + 49, 47, 46, 45, 44, 43, 40, 39, 34, 31, + 28, 26, 24, 22, 21, 19, 17, 16, 15, 13, + + 12, 10, 8, 7, 5, 3, 84, 84, 84, 84, + 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, + 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, + 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, + 84, 84 } ; static yy_state_type yy_last_accepting_state; @@ -536,7 +539,7 @@ char *yytext; int yyparse(); -#line 540 "engines/director/lingo/lingo-lex.cpp" +#line 543 "engines/director/lingo/lingo-lex.cpp" #define INITIAL 0 @@ -724,7 +727,7 @@ YY_DECL #line 45 "engines/director/lingo/lingo-lex.l" -#line 728 "engines/director/lingo/lingo-lex.cpp" +#line 731 "engines/director/lingo/lingo-lex.cpp" if ( !(yy_init) ) { @@ -778,13 +781,13 @@ yy_match: 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 >= 79 ) + if ( yy_current_state >= 85 ) 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] != 100 ); + while ( yy_base[yy_current_state] != 107 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -906,40 +909,55 @@ YY_RULE_SETUP case 20: YY_RULE_SETUP #line 68 "engines/director/lingo/lingo-lex.l" -{ yylval.s = new Common::String(yytext); return VAR; } +{ return tNEQ; } YY_BREAK case 21: YY_RULE_SETUP #line 69 "engines/director/lingo/lingo-lex.l" -{ yylval.f = atof(yytext); return FLOAT; } +{ return tGE; } YY_BREAK case 22: YY_RULE_SETUP #line 70 "engines/director/lingo/lingo-lex.l" -{ yylval.i = strtol(yytext, NULL, 10); return INT; } +{ return tLE; } YY_BREAK case 23: YY_RULE_SETUP -#line 71 "engines/director/lingo/lingo-lex.l" -{ return *yytext; } +#line 72 "engines/director/lingo/lingo-lex.l" +{ yylval.s = new Common::String(yytext); return VAR; } YY_BREAK case 24: -/* rule 24 can match eol */ YY_RULE_SETUP -#line 72 "engines/director/lingo/lingo-lex.l" -{ return '\n'; } +#line 73 "engines/director/lingo/lingo-lex.l" +{ yylval.f = atof(yytext); return FLOAT; } YY_BREAK case 25: YY_RULE_SETUP -#line 73 "engines/director/lingo/lingo-lex.l" -{ yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; } +#line 74 "engines/director/lingo/lingo-lex.l" +{ yylval.i = strtol(yytext, NULL, 10); return INT; } YY_BREAK case 26: YY_RULE_SETUP #line 75 "engines/director/lingo/lingo-lex.l" +{ return *yytext; } + YY_BREAK +case 27: +/* rule 27 can match eol */ +YY_RULE_SETUP +#line 76 "engines/director/lingo/lingo-lex.l" +{ return '\n'; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 77 "engines/director/lingo/lingo-lex.l" +{ yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 79 "engines/director/lingo/lingo-lex.l" ECHO; YY_BREAK -#line 943 "engines/director/lingo/lingo-lex.cpp" +#line 961 "engines/director/lingo/lingo-lex.cpp" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1232,7 +1250,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 >= 79 ) + if ( yy_current_state >= 85 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1260,11 +1278,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 >= 79 ) + if ( yy_current_state >= 85 ) 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 == 78); + yy_is_jam = (yy_current_state == 84); return yy_is_jam ? 0 : yy_current_state; } @@ -1939,7 +1957,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 75 "engines/director/lingo/lingo-lex.l" +#line 79 "engines/director/lingo/lingo-lex.l" diff --git a/engines/director/lingo/lingo-lex.l b/engines/director/lingo/lingo-lex.l index a6e644a5e5..2408b19422 100644 --- a/engines/director/lingo/lingo-lex.l +++ b/engines/director/lingo/lingo-lex.l @@ -38,7 +38,7 @@ variable [_[:alpha:]][_[:alnum:]]* constfloat [[:digit:]]+\.[[:digit:]]* constinteger [[:digit:]]+ conststring \"[^\"\n]*\" -operator [-+*/%=^:,()] +operator [-+*/%=^:,()><] newline [\n\r]+ whitespace [\t ] @@ -65,6 +65,10 @@ set { return tSET; } then { return tTHEN; } to { return tTO; } +[!][=] { return tNEQ; } +[>][=] { return tGE; } +[<][=] { return tLE; } + {variable} { yylval.s = new Common::String(yytext); return VAR; } {constfloat} { yylval.f = atof(yytext); return FLOAT; } {constinteger} { yylval.i = strtol(yytext, NULL, 10); return INT; } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index d4a119053d..aabf010576 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -133,6 +133,12 @@ public: bool verify(Symbol *s); static void func_eval(); static void func_ifcode(); + static void func_eq(); + static void func_neq(); + static void func_gt(); + static void func_lt(); + static void func_ge(); + static void func_le(); static void func_mci(); static void func_mciwait(); |