diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index bafc22536cb2..b620677ba050 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -198,24 +198,4 @@ int Lingo::codeId_(Common::String &name) { return ret; } -int Lingo::codeFunc(Common::String *name, int nargs) { - int ret; - - if (!g_lingo->_builtins.contains(*name)) { - ret = g_lingo->code1(g_lingo->c_call); - g_lingo->codeString(name->c_str()); - - inst numpar = 0; - WRITE_UINT32(&numpar, nargs); - g_lingo->code1(numpar); - } else { - if (nargs != g_lingo->_builtins[*name]->nargs) - error("Built-in function %s expects %d arguments but got %d", name->c_str(), g_lingo->_builtins[*name]->nargs, nargs); - - ret = g_lingo->code1(g_lingo->_builtins[*name]->func); - } - - return ret; -} - } diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index 4e4262bb69a4..4c4efdb786c9 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -71,39 +71,40 @@ VAR = 260, INT = 261, FLOAT = 262, - ID = 263, - STRING = 264, - HANDLER = 265, - tDOWN = 266, - tELSE = 267, - tEND = 268, - tEXIT = 269, - tFRAME = 270, - tGLOBAL = 271, - tGO = 272, - tIF = 273, - tINTO = 274, - tLOOP = 275, - tMACRO = 276, - tMCI = 277, - tMCIWAIT = 278, - tMOVIE = 279, - tNEXT = 280, - tOF = 281, - tPREVIOUS = 282, - tPUT = 283, - tREPEAT = 284, - tSET = 285, - tTHEN = 286, - tTO = 287, - tWITH = 288, - tWHILE = 289, - tGE = 290, - tLE = 291, - tGT = 292, - tLT = 293, - tEQ = 294, - tNEQ = 295 + BLTIN = 263, + ID = 264, + STRING = 265, + HANDLER = 266, + tDOWN = 267, + tELSE = 268, + tEND = 269, + tEXIT = 270, + tFRAME = 271, + tGLOBAL = 272, + tGO = 273, + tIF = 274, + tINTO = 275, + tLOOP = 276, + tMACRO = 277, + tMCI = 278, + tMCIWAIT = 279, + tMOVIE = 280, + tNEXT = 281, + tOF = 282, + tPREVIOUS = 283, + tPUT = 284, + tREPEAT = 285, + tSET = 286, + tTHEN = 287, + tTO = 288, + tWITH = 289, + tWHILE = 290, + tGE = 291, + tLE = 292, + tGT = 293, + tLT = 294, + tEQ = 295, + tNEQ = 296 }; #endif /* Tokens. */ @@ -112,39 +113,40 @@ #define VAR 260 #define INT 261 #define FLOAT 262 -#define ID 263 -#define STRING 264 -#define HANDLER 265 -#define tDOWN 266 -#define tELSE 267 -#define tEND 268 -#define tEXIT 269 -#define tFRAME 270 -#define tGLOBAL 271 -#define tGO 272 -#define tIF 273 -#define tINTO 274 -#define tLOOP 275 -#define tMACRO 276 -#define tMCI 277 -#define tMCIWAIT 278 -#define tMOVIE 279 -#define tNEXT 280 -#define tOF 281 -#define tPREVIOUS 282 -#define tPUT 283 -#define tREPEAT 284 -#define tSET 285 -#define tTHEN 286 -#define tTO 287 -#define tWITH 288 -#define tWHILE 289 -#define tGE 290 -#define tLE 291 -#define tGT 292 -#define tLT 293 -#define tEQ 294 -#define tNEQ 295 +#define BLTIN 263 +#define ID 264 +#define STRING 265 +#define HANDLER 266 +#define tDOWN 267 +#define tELSE 268 +#define tEND 269 +#define tEXIT 270 +#define tFRAME 271 +#define tGLOBAL 272 +#define tGO 273 +#define tIF 274 +#define tINTO 275 +#define tLOOP 276 +#define tMACRO 277 +#define tMCI 278 +#define tMCIWAIT 279 +#define tMOVIE 280 +#define tNEXT 281 +#define tOF 282 +#define tPREVIOUS 283 +#define tPUT 284 +#define tREPEAT 285 +#define tSET 286 +#define tTHEN 287 +#define tTO 288 +#define tWITH 289 +#define tWHILE 290 +#define tGE 291 +#define tLE 292 +#define tGT 293 +#define tLT 294 +#define tEQ 295 +#define tNEQ 296 @@ -196,7 +198,7 @@ typedef union YYSTYPE int narg; /* number of arguments */ } /* Line 193 of yacc.c. */ -#line 200 "engines/director/lingo/lingo-gr.cpp" +#line 202 "engines/director/lingo/lingo-gr.cpp" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -209,7 +211,7 @@ typedef union YYSTYPE /* Line 216 of yacc.c. */ -#line 213 "engines/director/lingo/lingo-gr.cpp" +#line 215 "engines/director/lingo/lingo-gr.cpp" #ifdef short # undef short @@ -422,22 +424,22 @@ union yyalloc #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 58 +#define YYFINAL 60 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 326 +#define YYLAST 340 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 53 +#define YYNTOKENS 54 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 25 /* YYNRULES -- Number of rules. */ -#define YYNRULES 82 +#define YYNRULES 83 /* YYNRULES -- Number of states. */ -#define YYNSTATES 170 +#define YYNSTATES 174 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 295 +#define YYMAXUTOK 296 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -446,12 +448,12 @@ union yyalloc static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 47, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 48, 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, 46, 2, 2, - 48, 49, 44, 42, 52, 43, 2, 45, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 47, 2, 2, + 49, 50, 45, 43, 53, 44, 2, 46, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 51, 41, 50, 2, 2, 2, 2, 2, 2, 2, + 52, 42, 51, 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, @@ -474,7 +476,7 @@ static const yytype_uint8 yytranslate[] = 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40 + 35, 36, 37, 38, 39, 40, 41 }; #if YYDEBUG @@ -485,46 +487,47 @@ static const yytype_uint16 yyprhs[] = 0, 0, 3, 7, 9, 10, 12, 14, 16, 18, 20, 22, 24, 29, 34, 39, 41, 43, 51, 62, 71, 83, 96, 103, 105, 109, 113, 116, 120, 122, - 123, 124, 125, 128, 131, 133, 135, 140, 142, 144, - 148, 152, 156, 160, 164, 168, 172, 176, 180, 183, - 186, 190, 193, 196, 199, 201, 203, 206, 208, 212, - 215, 218, 221, 224, 228, 231, 235, 238, 241, 243, - 247, 250, 254, 255, 264, 265, 267, 271, 276, 277, - 281, 282, 284 + 123, 124, 125, 128, 131, 133, 135, 140, 145, 147, + 149, 153, 157, 161, 165, 169, 173, 177, 181, 185, + 188, 191, 195, 198, 201, 204, 206, 208, 211, 213, + 217, 220, 223, 226, 229, 233, 236, 240, 243, 246, + 248, 252, 255, 259, 260, 269, 270, 272, 276, 281, + 282, 286, 287, 289 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 54, 0, -1, 55, 47, 54, -1, 55, -1, -1, - 72, -1, 67, -1, 76, -1, 56, -1, 58, -1, - 57, -1, 1, -1, 28, 66, 19, 8, -1, 30, - 8, 41, 66, -1, 30, 8, 32, 66, -1, 66, - -1, 67, -1, 62, 59, 31, 65, 64, 13, 18, - -1, 62, 59, 31, 65, 64, 12, 65, 64, 13, - 18, -1, 60, 48, 59, 49, 65, 64, 13, 29, - -1, 61, 41, 66, 64, 32, 66, 64, 65, 64, - 13, 29, -1, 61, 41, 66, 64, 11, 32, 66, - 64, 65, 64, 13, 29, -1, 62, 59, 31, 63, - 57, 64, -1, 66, -1, 66, 41, 66, -1, 48, - 59, 49, -1, 29, 34, -1, 29, 33, 8, -1, - 18, -1, -1, -1, -1, 65, 47, -1, 65, 57, - -1, 6, -1, 7, -1, 8, 48, 77, 49, -1, - 8, -1, 56, -1, 66, 42, 66, -1, 66, 43, - 66, -1, 66, 44, 66, -1, 66, 45, 66, -1, - 66, 50, 66, -1, 66, 51, 66, -1, 66, 40, - 66, -1, 66, 35, 66, -1, 66, 36, 66, -1, - 42, 66, -1, 43, 66, -1, 48, 66, 49, -1, - 22, 9, -1, 23, 8, -1, 28, 66, -1, 69, - -1, 14, -1, 16, 68, -1, 8, -1, 68, 52, - 8, -1, 17, 20, -1, 17, 25, -1, 17, 27, - -1, 17, 70, -1, 17, 70, 71, -1, 17, 71, - -1, 32, 15, 9, -1, 15, 9, -1, 32, 9, - -1, 9, -1, 26, 24, 9, -1, 24, 9, -1, - 32, 24, 9, -1, -1, 21, 8, 73, 63, 74, - 47, 75, 65, -1, -1, 8, -1, 74, 52, 8, - -1, 74, 47, 52, 8, -1, -1, 8, 63, 77, - -1, -1, 66, -1, 77, 52, 66, -1 + 55, 0, -1, 56, 48, 55, -1, 56, -1, -1, + 73, -1, 68, -1, 77, -1, 57, -1, 59, -1, + 58, -1, 1, -1, 29, 67, 20, 9, -1, 31, + 9, 42, 67, -1, 31, 9, 33, 67, -1, 67, + -1, 68, -1, 63, 60, 32, 66, 65, 14, 19, + -1, 63, 60, 32, 66, 65, 13, 66, 65, 14, + 19, -1, 61, 49, 60, 50, 66, 65, 14, 30, + -1, 62, 42, 67, 65, 33, 67, 65, 66, 65, + 14, 30, -1, 62, 42, 67, 65, 12, 33, 67, + 65, 66, 65, 14, 30, -1, 63, 60, 32, 64, + 58, 65, -1, 67, -1, 67, 42, 67, -1, 49, + 60, 50, -1, 30, 35, -1, 30, 34, 9, -1, + 19, -1, -1, -1, -1, 66, 48, -1, 66, 58, + -1, 6, -1, 7, -1, 8, 49, 78, 50, -1, + 9, 49, 78, 50, -1, 9, -1, 57, -1, 67, + 43, 67, -1, 67, 44, 67, -1, 67, 45, 67, + -1, 67, 46, 67, -1, 67, 51, 67, -1, 67, + 52, 67, -1, 67, 41, 67, -1, 67, 36, 67, + -1, 67, 37, 67, -1, 43, 67, -1, 44, 67, + -1, 49, 67, 50, -1, 23, 10, -1, 24, 9, + -1, 29, 67, -1, 70, -1, 15, -1, 17, 69, + -1, 9, -1, 69, 53, 9, -1, 18, 21, -1, + 18, 26, -1, 18, 28, -1, 18, 71, -1, 18, + 71, 72, -1, 18, 72, -1, 33, 16, 10, -1, + 16, 10, -1, 33, 10, -1, 10, -1, 27, 25, + 10, -1, 25, 10, -1, 33, 25, 10, -1, -1, + 22, 9, 74, 64, 75, 48, 76, 66, -1, -1, + 9, -1, 75, 53, 9, -1, 75, 48, 53, 9, + -1, -1, 9, 64, 78, -1, -1, 67, -1, 78, + 53, 67, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -533,12 +536,12 @@ static const yytype_uint16 yyrline[] = 0, 92, 92, 93, 96, 97, 98, 99, 100, 101, 102, 103, 106, 112, 118, 126, 127, 128, 134, 146, 157, 173, 187, 195, 196, 197, 199, 201, 207, 209, - 211, 213, 214, 215, 218, 223, 226, 229, 232, 233, - 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, - 244, 247, 248, 249, 250, 251, 252, 255, 256, 267, - 268, 269, 270, 275, 281, 288, 289, 290, 291, 294, - 295, 296, 324, 324, 331, 332, 333, 334, 336, 339, - 347, 348, 349 + 211, 213, 214, 215, 218, 223, 226, 232, 240, 243, + 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, + 254, 255, 258, 259, 260, 261, 262, 263, 266, 267, + 278, 279, 280, 281, 286, 292, 299, 300, 301, 302, + 305, 306, 307, 335, 335, 342, 343, 344, 345, 347, + 350, 358, 359, 360 }; #endif @@ -548,15 +551,16 @@ static const yytype_uint16 yyrline[] = static const char *const yytname[] = { "$end", "error", "$undefined", "UNARY", "VOID", "VAR", "INT", "FLOAT", - "ID", "STRING", "HANDLER", "tDOWN", "tELSE", "tEND", "tEXIT", "tFRAME", - "tGLOBAL", "tGO", "tIF", "tINTO", "tLOOP", "tMACRO", "tMCI", "tMCIWAIT", - "tMOVIE", "tNEXT", "tOF", "tPREVIOUS", "tPUT", "tREPEAT", "tSET", - "tTHEN", "tTO", "tWITH", "tWHILE", "tGE", "tLE", "tGT", "tLT", "tEQ", - "tNEQ", "'='", "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('", "')'", - "'>'", "'<'", "','", "$accept", "program", "programline", "asgn", "stmt", - "stmtoneliner", "cond", "repeatwhile", "repeatwith", "if", "begin", - "end", "stmtlist", "expr", "func", "globallist", "gotofunc", "gotoframe", - "gotomovie", "defn", "@1", "argdef", "argstore", "macro", "arglist", 0 + "BLTIN", "ID", "STRING", "HANDLER", "tDOWN", "tELSE", "tEND", "tEXIT", + "tFRAME", "tGLOBAL", "tGO", "tIF", "tINTO", "tLOOP", "tMACRO", "tMCI", + "tMCIWAIT", "tMOVIE", "tNEXT", "tOF", "tPREVIOUS", "tPUT", "tREPEAT", + "tSET", "tTHEN", "tTO", "tWITH", "tWHILE", "tGE", "tLE", "tGT", "tLT", + "tEQ", "tNEQ", "'='", "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('", + "')'", "'>'", "'<'", "','", "$accept", "program", "programline", "asgn", + "stmt", "stmtoneliner", "cond", "repeatwhile", "repeatwith", "if", + "begin", "end", "stmtlist", "expr", "func", "globallist", "gotofunc", + "gotoframe", "gotomovie", "defn", "@1", "argdef", "argstore", "macro", + "arglist", 0 }; #endif @@ -569,23 +573,23 @@ static const yytype_uint16 yytoknum[] = 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 61, 43, 45, 42, 47, 37, 10, 40, 41, - 62, 60, 44 + 295, 296, 61, 43, 45, 42, 47, 37, 10, 40, + 41, 62, 60, 44 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 53, 54, 54, 55, 55, 55, 55, 55, 55, - 55, 55, 56, 56, 56, 57, 57, 57, 57, 57, - 57, 57, 58, 59, 59, 59, 60, 61, 62, 63, - 64, 65, 65, 65, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, - 66, 67, 67, 67, 67, 67, 67, 68, 68, 69, - 69, 69, 69, 69, 69, 70, 70, 70, 70, 71, - 71, 71, 73, 72, 74, 74, 74, 74, 75, 76, - 77, 77, 77 + 0, 54, 55, 55, 56, 56, 56, 56, 56, 56, + 56, 56, 57, 57, 57, 58, 58, 58, 58, 58, + 58, 58, 59, 60, 60, 60, 61, 62, 63, 64, + 65, 66, 66, 66, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 68, 68, 68, 68, 68, 68, 69, 69, + 70, 70, 70, 70, 70, 70, 71, 71, 71, 71, + 72, 72, 72, 74, 73, 75, 75, 75, 75, 76, + 77, 78, 78, 78 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -594,12 +598,12 @@ static const yytype_uint8 yyr2[] = 0, 2, 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 1, 1, 7, 10, 8, 11, 12, 6, 1, 3, 3, 2, 3, 1, 0, - 0, 0, 2, 2, 1, 1, 4, 1, 1, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, - 3, 2, 2, 2, 1, 1, 2, 1, 3, 2, - 2, 2, 2, 3, 2, 3, 2, 2, 1, 3, - 2, 3, 0, 8, 0, 1, 3, 4, 0, 3, - 0, 1, 3 + 0, 0, 2, 2, 1, 1, 4, 4, 1, 1, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, + 2, 3, 2, 2, 2, 1, 1, 2, 1, 3, + 2, 2, 2, 2, 3, 2, 3, 2, 2, 1, + 3, 2, 3, 0, 8, 0, 1, 3, 4, 0, + 3, 0, 1, 3 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -607,165 +611,172 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 11, 34, 35, 29, 55, 0, 0, 28, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, - 38, 10, 9, 0, 0, 0, 15, 6, 54, 5, - 7, 80, 80, 57, 56, 68, 0, 59, 0, 60, - 0, 61, 0, 62, 64, 72, 51, 52, 37, 0, - 38, 53, 0, 26, 0, 48, 49, 0, 1, 0, - 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 81, 0, 79, 0, 66, 70, - 0, 67, 0, 0, 0, 63, 29, 0, 0, 27, - 0, 0, 50, 2, 0, 30, 0, 0, 29, 0, - 46, 47, 45, 39, 40, 41, 42, 43, 44, 36, - 0, 58, 69, 65, 71, 74, 12, 14, 13, 31, - 0, 25, 0, 30, 24, 82, 75, 0, 30, 0, - 0, 30, 0, 16, 32, 33, 0, 78, 0, 0, - 0, 30, 22, 0, 31, 0, 0, 31, 76, 0, - 30, 31, 31, 30, 17, 77, 73, 19, 31, 30, - 0, 30, 0, 0, 0, 0, 18, 0, 20, 21 + 0, 11, 34, 35, 0, 29, 56, 0, 0, 28, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3, 39, 10, 9, 0, 0, 0, 15, 6, 55, + 5, 7, 81, 81, 81, 58, 57, 69, 0, 60, + 0, 61, 0, 62, 0, 63, 65, 73, 52, 53, + 38, 0, 39, 54, 0, 26, 0, 49, 50, 0, + 1, 0, 0, 0, 0, 0, 23, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 82, 0, 0, 80, + 0, 67, 71, 0, 68, 0, 0, 0, 64, 29, + 0, 0, 27, 0, 0, 51, 2, 0, 30, 0, + 0, 29, 0, 47, 48, 46, 40, 41, 42, 43, + 44, 45, 36, 0, 37, 59, 70, 66, 72, 75, + 12, 14, 13, 31, 0, 25, 0, 30, 24, 83, + 76, 0, 30, 0, 0, 30, 0, 16, 32, 33, + 0, 79, 0, 0, 0, 30, 22, 0, 31, 0, + 0, 31, 77, 0, 30, 31, 31, 30, 17, 78, + 74, 19, 31, 30, 0, 30, 0, 0, 0, 0, + 18, 0, 20, 21 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 18, 19, 50, 135, 22, 63, 23, 24, 132, - 32, 120, 123, 26, 133, 34, 28, 43, 44, 29, - 86, 127, 147, 30, 75 + -1, 19, 20, 52, 139, 23, 65, 24, 25, 136, + 34, 124, 127, 27, 137, 36, 29, 45, 46, 30, + 89, 131, 151, 31, 77 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -119 +#define YYPACT_NINF -123 static const yytype_int16 yypact[] = { - 83, -119, -119, -119, 258, -119, 17, 217, -119, 27, - 5, 33, 66, 30, 39, 66, 66, 66, 38, 22, - 15, -119, -119, 19, 36, 109, 246, -119, -119, -119, - -119, 66, 66, -119, 29, -119, 62, -119, 73, -119, - 61, -119, 21, 20, -119, -119, -119, -119, 40, 66, - -119, 180, 78, -119, -10, -8, -8, 222, -119, 83, - 109, 66, 109, 64, 234, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 246, -31, 41, 84, -119, -119, - 93, -119, 94, 98, 86, -119, -119, 180, 111, -119, - 66, 66, -119, -119, 72, 246, 74, 210, 4, 66, - 246, 246, 246, 275, 275, -8, -8, 246, 246, -119, - 66, -119, -119, -119, -119, 114, -119, 246, 246, -119, - -9, -119, 164, 126, 246, 246, -119, -13, 126, 92, - 66, -119, 109, -119, -119, -119, 63, 75, 127, 123, - 66, 246, -119, 107, -119, 128, 133, -119, -119, 116, - 246, -119, -119, 126, -119, -119, 126, -119, -119, 126, - 134, 126, 137, 135, 145, 130, -119, 131, -119, -119 + 86, -123, -123, -123, -24, 288, -123, 22, 247, -123, + 26, 27, 32, 157, -17, 35, 157, 157, 157, 48, + 4, 16, -123, -123, 30, 42, 201, 276, -123, -123, + -123, -123, 157, 157, 157, -123, 12, -123, 73, -123, + 75, -123, 63, -123, 14, 20, -123, -123, -123, -123, + 47, 157, -123, 215, 81, -123, -19, -9, -9, 252, + -123, 86, 201, 157, 201, 59, 264, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 276, 19, 23, 46, + 102, -123, -123, 104, -123, 108, 109, 95, -123, -123, + 215, 113, -123, 157, 157, -123, -123, 74, 276, 76, + 240, -2, 157, 276, 276, 276, 61, 61, -9, -9, + 276, 276, -123, 157, -123, -123, -123, -123, -123, 116, + -123, 276, 276, -123, 3, -123, 174, 130, 276, 276, + -123, 18, 130, 94, 157, -123, 201, -123, -123, -123, + 64, 79, 124, 126, 157, 276, -123, 110, -123, 122, + 134, -123, -123, 114, 276, -123, -123, 130, -123, -123, + 130, -123, -123, 130, 132, 130, 136, 133, 137, 125, + -123, 127, -123, -123 }; /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = +static const yytype_int8 yypgoto[] = { - -119, 102, -119, 6, 7, -119, -52, -119, -119, 9, - -74, 60, -118, -12, 11, -119, -119, -119, 119, -119, - -119, -119, -119, -119, 132 + -123, 97, -123, 6, 2, -123, -54, -123, -123, 7, + -67, 84, -122, -13, 9, -123, -123, -123, 111, -123, + -123, -123, -123, -123, 41 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -38 +#define YYTABLE_NINF -39 static const yytype_int16 yytable[] = { - 51, 128, 129, 55, 56, 57, 20, 21, 94, 25, - 96, 27, 115, 64, 46, -8, -31, -31, 109, 74, - 74, 110, 90, 130, 122, 33, 153, 65, 66, 156, - 81, 91, 67, 159, 137, 45, 82, 87, 58, 138, - 161, 47, 72, 73, 38, 83, 40, 54, 64, 95, - 97, -31, 84, 100, 101, 102, 103, 104, 105, 106, - 107, 108, -8, 52, 53, 20, 21, 60, 25, 59, - 27, 78, 2, 3, 48, 144, 145, 61, 117, 118, - 143, 77, 79, -4, 1, 80, 89, 124, 31, 2, - 3, 4, 111, 110, 49, 98, 14, 5, 125, 6, - 7, 8, 112, 113, 9, 10, 11, 114, 15, 16, - 83, 12, 13, 14, 17, 2, 3, 48, 141, 116, - 64, 119, 126, 121, 140, 15, 16, 146, 150, 131, - -4, 17, 2, 3, 48, 148, 149, 49, 152, 14, - 5, 155, 6, 7, 8, 157, 154, 163, 10, 11, - 165, 15, 16, 166, 12, 13, 14, 62, 167, 168, - 169, 93, 85, 0, 76, 0, 0, 0, 15, 16, - 2, 3, 48, 134, 17, 0, 0, 0, 5, 0, - 6, 7, 8, 136, 0, 0, 10, 11, 139, 0, - 0, 142, 12, 13, 14, 0, 0, 0, 0, 88, - 0, 151, 0, 0, 0, 0, 15, 16, 0, 0, - 158, 0, 17, 160, 0, 65, 66, 0, 0, 162, - 67, 164, 68, 69, 70, 71, 35, 0, 0, 0, - 72, 73, 36, 0, 0, 0, 0, 37, 0, 0, - 0, 38, 39, 40, 41, 65, 66, 0, 0, 42, - 67, 99, 68, 69, 70, 71, 0, 65, 66, 92, - 72, 73, 67, 0, 68, 69, 70, 71, 0, 65, - 66, 92, 72, 73, 67, 99, 68, 69, 70, 71, - 0, 65, 66, 0, 72, 73, 67, 0, 68, 69, - 70, 71, 0, -37, -37, 0, 72, 73, -37, 0, - 0, 0, -37, -37, 0, 0, 31, 0, -37, -37, - 65, 66, 0, 0, 0, 67, 0, 0, 0, 70, - 71, 0, 0, 0, 0, 72, 73 + 53, 132, 22, 57, 58, 59, 21, 26, 97, 28, + 99, -31, -31, 66, 93, 133, -8, 54, 55, 76, + 76, 76, 119, 94, 84, 32, 157, 67, 68, 160, + 85, 35, 69, 163, 126, 47, 134, 48, 90, 86, + 165, 49, 74, 75, 56, 40, -31, 42, 60, 66, + 98, 100, 61, 87, 103, 104, 105, 106, 107, 108, + 109, 110, 111, 22, -8, 80, 141, 21, 26, 112, + 28, 142, 113, 114, 78, 79, 113, 148, 149, 62, + 121, 122, 147, 81, 63, 82, -4, 1, 83, 128, + 92, 101, 2, 3, 4, 5, 33, 67, 68, 113, + 129, 6, 69, 7, 8, 9, 72, 73, 10, 11, + 12, 115, 74, 75, 116, 13, 14, 15, 117, 118, + 86, 145, 120, 66, 123, 130, 125, 144, 135, 16, + 17, 154, 150, 152, -4, 18, 2, 3, 4, 50, + 153, 158, 156, 159, 161, 6, 167, 7, 8, 9, + 169, 171, 170, 11, 12, 172, 88, 173, 96, 13, + 14, 15, 0, 2, 3, 4, 50, 0, 0, 0, + 0, 0, 0, 16, 17, 0, 0, 0, 138, 18, + 2, 3, 4, 50, 0, 0, 51, 0, 15, 6, + 0, 7, 8, 9, 0, 0, 0, 11, 12, 0, + 16, 17, 0, 13, 14, 15, 18, 2, 3, 4, + 50, 140, 0, 0, 0, 0, 143, 16, 17, 146, + 0, 0, 0, 18, 0, 0, 0, 0, 0, 155, + 51, 0, 15, 0, 0, 91, 0, 0, 162, 0, + 0, 164, 0, 0, 16, 17, 0, 166, 0, 168, + 64, 67, 68, 0, 0, 0, 69, 37, 70, 71, + 72, 73, 0, 38, 0, 0, 74, 75, 39, 0, + 0, 0, 40, 41, 42, 43, 67, 68, 0, 0, + 44, 69, 102, 70, 71, 72, 73, 0, 67, 68, + 95, 74, 75, 69, 0, 70, 71, 72, 73, 0, + 67, 68, 95, 74, 75, 69, 102, 70, 71, 72, + 73, 0, 67, 68, 0, 74, 75, 69, 0, 70, + 71, 72, 73, 0, -38, -38, 0, 74, 75, -38, + 0, 0, 0, -38, -38, 0, 0, 33, 0, -38, + -38 }; static const yytype_int16 yycheck[] = { - 12, 119, 11, 15, 16, 17, 0, 0, 60, 0, - 62, 0, 86, 25, 9, 0, 12, 13, 49, 31, - 32, 52, 32, 32, 98, 8, 144, 35, 36, 147, - 9, 41, 40, 151, 47, 8, 15, 49, 0, 52, - 158, 8, 50, 51, 24, 24, 26, 8, 60, 61, - 62, 47, 32, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 47, 33, 34, 59, 59, 48, 59, 47, - 59, 9, 6, 7, 8, 12, 13, 41, 90, 91, - 132, 52, 9, 0, 1, 24, 8, 99, 48, 6, - 7, 8, 8, 52, 28, 31, 30, 14, 110, 16, - 17, 18, 9, 9, 21, 22, 23, 9, 42, 43, - 24, 28, 29, 30, 48, 6, 7, 8, 130, 8, - 132, 49, 8, 49, 32, 42, 43, 52, 140, 122, - 47, 48, 6, 7, 8, 8, 13, 28, 31, 30, - 14, 8, 16, 17, 18, 29, 18, 13, 22, 23, - 13, 42, 43, 18, 28, 29, 30, 48, 13, 29, - 29, 59, 43, -1, 32, -1, -1, -1, 42, 43, - 6, 7, 8, 47, 48, -1, -1, -1, 14, -1, - 16, 17, 18, 123, -1, -1, 22, 23, 128, -1, - -1, 131, 28, 29, 30, -1, -1, -1, -1, 19, - -1, 141, -1, -1, -1, -1, 42, 43, -1, -1, - 150, -1, 48, 153, -1, 35, 36, -1, -1, 159, - 40, 161, 42, 43, 44, 45, 9, -1, -1, -1, - 50, 51, 15, -1, -1, -1, -1, 20, -1, -1, - -1, 24, 25, 26, 27, 35, 36, -1, -1, 32, - 40, 41, 42, 43, 44, 45, -1, 35, 36, 49, - 50, 51, 40, -1, 42, 43, 44, 45, -1, 35, - 36, 49, 50, 51, 40, 41, 42, 43, 44, 45, - -1, 35, 36, -1, 50, 51, 40, -1, 42, 43, - 44, 45, -1, 35, 36, -1, 50, 51, 40, -1, - -1, -1, 44, 45, -1, -1, 48, -1, 50, 51, - 35, 36, -1, -1, -1, 40, -1, -1, -1, 44, - 45, -1, -1, -1, -1, 50, 51 + 13, 123, 0, 16, 17, 18, 0, 0, 62, 0, + 64, 13, 14, 26, 33, 12, 0, 34, 35, 32, + 33, 34, 89, 42, 10, 49, 148, 36, 37, 151, + 16, 9, 41, 155, 101, 9, 33, 10, 51, 25, + 162, 9, 51, 52, 9, 25, 48, 27, 0, 62, + 63, 64, 48, 33, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 61, 48, 53, 48, 61, 61, 50, + 61, 53, 53, 50, 33, 34, 53, 13, 14, 49, + 93, 94, 136, 10, 42, 10, 0, 1, 25, 102, + 9, 32, 6, 7, 8, 9, 49, 36, 37, 53, + 113, 15, 41, 17, 18, 19, 45, 46, 22, 23, + 24, 9, 51, 52, 10, 29, 30, 31, 10, 10, + 25, 134, 9, 136, 50, 9, 50, 33, 126, 43, + 44, 144, 53, 9, 48, 49, 6, 7, 8, 9, + 14, 19, 32, 9, 30, 15, 14, 17, 18, 19, + 14, 14, 19, 23, 24, 30, 45, 30, 61, 29, + 30, 31, -1, 6, 7, 8, 9, -1, -1, -1, + -1, -1, -1, 43, 44, -1, -1, -1, 48, 49, + 6, 7, 8, 9, -1, -1, 29, -1, 31, 15, + -1, 17, 18, 19, -1, -1, -1, 23, 24, -1, + 43, 44, -1, 29, 30, 31, 49, 6, 7, 8, + 9, 127, -1, -1, -1, -1, 132, 43, 44, 135, + -1, -1, -1, 49, -1, -1, -1, -1, -1, 145, + 29, -1, 31, -1, -1, 20, -1, -1, 154, -1, + -1, 157, -1, -1, 43, 44, -1, 163, -1, 165, + 49, 36, 37, -1, -1, -1, 41, 10, 43, 44, + 45, 46, -1, 16, -1, -1, 51, 52, 21, -1, + -1, -1, 25, 26, 27, 28, 36, 37, -1, -1, + 33, 41, 42, 43, 44, 45, 46, -1, 36, 37, + 50, 51, 52, 41, -1, 43, 44, 45, 46, -1, + 36, 37, 50, 51, 52, 41, 42, 43, 44, 45, + 46, -1, 36, 37, -1, 51, 52, 41, -1, 43, + 44, 45, 46, -1, 36, 37, -1, 51, 52, 41, + -1, -1, -1, 45, 46, -1, -1, 49, -1, 51, + 52 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 1, 6, 7, 8, 14, 16, 17, 18, 21, - 22, 23, 28, 29, 30, 42, 43, 48, 54, 55, - 56, 57, 58, 60, 61, 62, 66, 67, 69, 72, - 76, 48, 63, 8, 68, 9, 15, 20, 24, 25, - 26, 27, 32, 70, 71, 8, 9, 8, 8, 28, - 56, 66, 33, 34, 8, 66, 66, 66, 0, 47, - 48, 41, 48, 59, 66, 35, 36, 40, 42, 43, - 44, 45, 50, 51, 66, 77, 77, 52, 9, 9, - 24, 9, 15, 24, 32, 71, 73, 66, 19, 8, - 32, 41, 49, 54, 59, 66, 59, 66, 31, 41, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 49, - 52, 8, 9, 9, 9, 63, 8, 66, 66, 49, - 64, 49, 63, 65, 66, 66, 8, 74, 65, 11, - 32, 57, 62, 67, 47, 57, 64, 47, 52, 64, - 32, 66, 64, 59, 12, 13, 52, 75, 8, 13, - 66, 64, 31, 65, 18, 8, 65, 29, 64, 65, - 64, 65, 64, 13, 64, 13, 18, 13, 29, 29 + 0, 1, 6, 7, 8, 9, 15, 17, 18, 19, + 22, 23, 24, 29, 30, 31, 43, 44, 49, 55, + 56, 57, 58, 59, 61, 62, 63, 67, 68, 70, + 73, 77, 49, 49, 64, 9, 69, 10, 16, 21, + 25, 26, 27, 28, 33, 71, 72, 9, 10, 9, + 9, 29, 57, 67, 34, 35, 9, 67, 67, 67, + 0, 48, 49, 42, 49, 60, 67, 36, 37, 41, + 43, 44, 45, 46, 51, 52, 67, 78, 78, 78, + 53, 10, 10, 25, 10, 16, 25, 33, 72, 74, + 67, 20, 9, 33, 42, 50, 55, 60, 67, 60, + 67, 32, 42, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 50, 53, 50, 9, 10, 10, 10, 64, + 9, 67, 67, 50, 65, 50, 64, 66, 67, 67, + 9, 75, 66, 12, 33, 58, 63, 68, 48, 58, + 65, 48, 53, 65, 33, 67, 65, 60, 13, 14, + 53, 76, 9, 14, 67, 65, 32, 66, 19, 9, + 66, 30, 65, 66, 65, 66, 65, 14, 65, 14, + 19, 14, 30, 30 }; #define yyerrok (yyerrstatus = 0) @@ -1761,124 +1772,139 @@ yyparse () case 36: #line 226 "engines/director/lingo/lingo-gr.y" { - (yyval.code) = g_lingo->codeFunc((yyvsp[(1) - (4)].s), (yyvsp[(3) - (4)].narg)); - delete (yyvsp[(1) - (4)].s); ;} + if ((yyvsp[(3) - (4)].narg) != g_lingo->_builtins[*(yyvsp[(1) - (4)].s)]->nargs) + error("Built-in function %s expects %d arguments but got %d", (yyvsp[(1) - (4)].s)->c_str(), g_lingo->_builtins[*(yyvsp[(1) - (4)].s)]->nargs, (yyvsp[(3) - (4)].narg)); + + (yyval.code) = g_lingo->code1(g_lingo->_builtins[*(yyvsp[(1) - (4)].s)]->func); + delete (yyvsp[(1) - (4)].s); ;} break; case 37: -#line 229 "engines/director/lingo/lingo-gr.y" +#line 232 "engines/director/lingo/lingo-gr.y" + { + (yyval.code) = g_lingo->code1(g_lingo->c_call); + g_lingo->codeString((yyvsp[(1) - (4)].s)->c_str()); + + inst numpar = 0; + WRITE_UINT32(&numpar, (yyvsp[(3) - (4)].narg)); + g_lingo->code1(numpar); + delete (yyvsp[(1) - (4)].s); ;} + break; + + case 38: +#line 240 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->codeId(*(yyvsp[(1) - (1)].s)); delete (yyvsp[(1) - (1)].s); ;} break; - case 39: -#line 233 "engines/director/lingo/lingo-gr.y" + case 40: +#line 244 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_add); ;} break; - case 40: -#line 234 "engines/director/lingo/lingo-gr.y" + case 41: +#line 245 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_sub); ;} break; - case 41: -#line 235 "engines/director/lingo/lingo-gr.y" + case 42: +#line 246 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_mul); ;} break; - case 42: -#line 236 "engines/director/lingo/lingo-gr.y" + case 43: +#line 247 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_div); ;} break; - case 43: -#line 237 "engines/director/lingo/lingo-gr.y" + case 44: +#line 248 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gt); ;} break; - case 44: -#line 238 "engines/director/lingo/lingo-gr.y" + case 45: +#line 249 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_lt); ;} break; - case 45: -#line 239 "engines/director/lingo/lingo-gr.y" + case 46: +#line 250 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_neq); ;} break; - case 46: -#line 240 "engines/director/lingo/lingo-gr.y" + case 47: +#line 251 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_ge); ;} break; - case 47: -#line 241 "engines/director/lingo/lingo-gr.y" + case 48: +#line 252 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_le); ;} break; - case 48: -#line 242 "engines/director/lingo/lingo-gr.y" + case 49: +#line 253 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (2)].code); ;} break; - case 49: -#line 243 "engines/director/lingo/lingo-gr.y" + case 50: +#line 254 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->c_negate); ;} break; - case 50: -#line 244 "engines/director/lingo/lingo-gr.y" + case 51: +#line 255 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (3)].code); ;} break; - case 51: -#line 247 "engines/director/lingo/lingo-gr.y" + case 52: +#line 258 "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 52: -#line 248 "engines/director/lingo/lingo-gr.y" + case 53: +#line 259 "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 53: -#line 249 "engines/director/lingo/lingo-gr.y" + case 54: +#line 260 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_printtop); ;} break; - case 55: -#line 251 "engines/director/lingo/lingo-gr.y" + case 56: +#line 262 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_exit); ;} break; - case 57: -#line 255 "engines/director/lingo/lingo-gr.y" + case 58: +#line 266 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_global); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); delete (yyvsp[(1) - (1)].s); ;} break; - case 58: -#line 256 "engines/director/lingo/lingo-gr.y" + case 59: +#line 267 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_global); g_lingo->codeString((yyvsp[(3) - (3)].s)->c_str()); delete (yyvsp[(3) - (3)].s); ;} break; - case 59: -#line 267 "engines/director/lingo/lingo-gr.y" + case 60: +#line 278 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotoloop); ;} break; - case 60: -#line 268 "engines/director/lingo/lingo-gr.y" + case 61: +#line 279 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotonext); ;} break; - case 61: -#line 269 "engines/director/lingo/lingo-gr.y" + case 62: +#line 280 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotoprevious); ;} break; - case 62: -#line 270 "engines/director/lingo/lingo-gr.y" + case 63: +#line 281 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_goto); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); @@ -1886,8 +1912,8 @@ yyparse () delete (yyvsp[(2) - (2)].s); ;} break; - case 63: -#line 275 "engines/director/lingo/lingo-gr.y" + case 64: +#line 286 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_goto); g_lingo->codeString((yyvsp[(2) - (3)].s)->c_str()); @@ -1896,8 +1922,8 @@ yyparse () delete (yyvsp[(3) - (3)].s); ;} break; - case 64: -#line 281 "engines/director/lingo/lingo-gr.y" + case 65: +#line 292 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_goto); g_lingo->codeString(""); @@ -1905,48 +1931,48 @@ yyparse () delete (yyvsp[(2) - (2)].s); ;} break; - case 65: -#line 288 "engines/director/lingo/lingo-gr.y" + case 66: +#line 299 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 66: -#line 289 "engines/director/lingo/lingo-gr.y" + case 67: +#line 300 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 67: -#line 290 "engines/director/lingo/lingo-gr.y" + case 68: +#line 301 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 68: -#line 291 "engines/director/lingo/lingo-gr.y" + case 69: +#line 302 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(1) - (1)].s); ;} break; - case 69: -#line 294 "engines/director/lingo/lingo-gr.y" + case 70: +#line 305 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 70: -#line 295 "engines/director/lingo/lingo-gr.y" + case 71: +#line 306 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 71: -#line 296 "engines/director/lingo/lingo-gr.y" + case 72: +#line 307 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 72: -#line 324 "engines/director/lingo/lingo-gr.y" + case 73: +#line 335 "engines/director/lingo/lingo-gr.y" { g_lingo->_indef = true; ;} break; - case 73: -#line 325 "engines/director/lingo/lingo-gr.y" + case 74: +#line 336 "engines/director/lingo/lingo-gr.y" { g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack g_lingo->code1(g_lingo->c_procret); @@ -1954,33 +1980,33 @@ yyparse () g_lingo->_indef = false; ;} break; - case 74: -#line 331 "engines/director/lingo/lingo-gr.y" + case 75: +#line 342 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 0; ;} break; - case 75: -#line 332 "engines/director/lingo/lingo-gr.y" + case 76: +#line 343 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(1) - (1)].s)); (yyval.narg) = 1; ;} break; - case 76: -#line 333 "engines/director/lingo/lingo-gr.y" + case 77: +#line 344 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(3) - (3)].s)); (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;} break; - case 77: -#line 334 "engines/director/lingo/lingo-gr.y" + case 78: +#line 345 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(4) - (4)].s)); (yyval.narg) = (yyvsp[(1) - (4)].narg) + 1; ;} break; - case 78: -#line 336 "engines/director/lingo/lingo-gr.y" + case 79: +#line 347 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArgStore(); ;} break; - case 79: -#line 339 "engines/director/lingo/lingo-gr.y" + case 80: +#line 350 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_call); g_lingo->codeString((yyvsp[(1) - (3)].s)->c_str()); @@ -1989,24 +2015,24 @@ yyparse () g_lingo->code1(numpar); ;} break; - case 80: -#line 347 "engines/director/lingo/lingo-gr.y" + case 81: +#line 358 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 0; ;} break; - case 81: -#line 348 "engines/director/lingo/lingo-gr.y" + case 82: +#line 359 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 1; ;} break; - case 82: -#line 349 "engines/director/lingo/lingo-gr.y" + case 83: +#line 360 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;} break; /* Line 1267 of yacc.c. */ -#line 2010 "engines/director/lingo/lingo-gr.cpp" +#line 2036 "engines/director/lingo/lingo-gr.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2220,6 +2246,6 @@ yyparse () } -#line 352 "engines/director/lingo/lingo-gr.y" +#line 363 "engines/director/lingo/lingo-gr.y" diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h index efc1e80acb92..e21948c62fb9 100644 --- a/engines/director/lingo/lingo-gr.h +++ b/engines/director/lingo/lingo-gr.h @@ -44,39 +44,40 @@ VAR = 260, INT = 261, FLOAT = 262, - ID = 263, - STRING = 264, - HANDLER = 265, - tDOWN = 266, - tELSE = 267, - tEND = 268, - tEXIT = 269, - tFRAME = 270, - tGLOBAL = 271, - tGO = 272, - tIF = 273, - tINTO = 274, - tLOOP = 275, - tMACRO = 276, - tMCI = 277, - tMCIWAIT = 278, - tMOVIE = 279, - tNEXT = 280, - tOF = 281, - tPREVIOUS = 282, - tPUT = 283, - tREPEAT = 284, - tSET = 285, - tTHEN = 286, - tTO = 287, - tWITH = 288, - tWHILE = 289, - tGE = 290, - tLE = 291, - tGT = 292, - tLT = 293, - tEQ = 294, - tNEQ = 295 + BLTIN = 263, + ID = 264, + STRING = 265, + HANDLER = 266, + tDOWN = 267, + tELSE = 268, + tEND = 269, + tEXIT = 270, + tFRAME = 271, + tGLOBAL = 272, + tGO = 273, + tIF = 274, + tINTO = 275, + tLOOP = 276, + tMACRO = 277, + tMCI = 278, + tMCIWAIT = 279, + tMOVIE = 280, + tNEXT = 281, + tOF = 282, + tPREVIOUS = 283, + tPUT = 284, + tREPEAT = 285, + tSET = 286, + tTHEN = 287, + tTO = 288, + tWITH = 289, + tWHILE = 290, + tGE = 291, + tLE = 292, + tGT = 293, + tLT = 294, + tEQ = 295, + tNEQ = 296 }; #endif /* Tokens. */ @@ -85,39 +86,40 @@ #define VAR 260 #define INT 261 #define FLOAT 262 -#define ID 263 -#define STRING 264 -#define HANDLER 265 -#define tDOWN 266 -#define tELSE 267 -#define tEND 268 -#define tEXIT 269 -#define tFRAME 270 -#define tGLOBAL 271 -#define tGO 272 -#define tIF 273 -#define tINTO 274 -#define tLOOP 275 -#define tMACRO 276 -#define tMCI 277 -#define tMCIWAIT 278 -#define tMOVIE 279 -#define tNEXT 280 -#define tOF 281 -#define tPREVIOUS 282 -#define tPUT 283 -#define tREPEAT 284 -#define tSET 285 -#define tTHEN 286 -#define tTO 287 -#define tWITH 288 -#define tWHILE 289 -#define tGE 290 -#define tLE 291 -#define tGT 292 -#define tLT 293 -#define tEQ 294 -#define tNEQ 295 +#define BLTIN 263 +#define ID 264 +#define STRING 265 +#define HANDLER 266 +#define tDOWN 267 +#define tELSE 268 +#define tEND 269 +#define tEXIT 270 +#define tFRAME 271 +#define tGLOBAL 272 +#define tGO 273 +#define tIF 274 +#define tINTO 275 +#define tLOOP 276 +#define tMACRO 277 +#define tMCI 278 +#define tMCIWAIT 279 +#define tMOVIE 280 +#define tNEXT 281 +#define tOF 282 +#define tPREVIOUS 283 +#define tPUT 284 +#define tREPEAT 285 +#define tSET 286 +#define tTHEN 287 +#define tTO 288 +#define tWITH 289 +#define tWHILE 290 +#define tGE 291 +#define tLE 292 +#define tGT 293 +#define tLT 294 +#define tEQ 295 +#define tNEQ 296 @@ -133,7 +135,7 @@ typedef union YYSTYPE int narg; /* number of arguments */ } /* Line 1529 of yacc.c. */ -#line 137 "engines/director/lingo/lingo-gr.hpp" +#line 139 "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 1c57e3fbce34..df083b5d45b9 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 VAR %token INT %token FLOAT -%token ID STRING HANDLER +%token BLTIN ID STRING HANDLER %token tDOWN tELSE tEND tEXIT tFRAME tGLOBAL 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 @@ -223,9 +223,20 @@ expr: INT { | FLOAT { $$ = g_lingo->code1(g_lingo->c_fconstpush); g_lingo->codeFloat($1); } + | BLTIN '(' arglist ')' { + if ($3 != g_lingo->_builtins[*$1]->nargs) + error("Built-in function %s expects %d arguments but got %d", $1->c_str(), g_lingo->_builtins[*$1]->nargs, $3); + + $$ = g_lingo->code1(g_lingo->_builtins[*$1]->func); + delete $1; } | ID '(' arglist ')' { - $$ = g_lingo->codeFunc($1, $3); - delete $1; } + $$ = g_lingo->code1(g_lingo->c_call); + g_lingo->codeString($1->c_str()); + + inst numpar = 0; + WRITE_UINT32(&numpar, $3); + g_lingo->code1(numpar); + delete $1; } | ID { $$ = g_lingo->codeId(*$1); delete $1; } diff --git a/engines/director/lingo/lingo-lex.cpp b/engines/director/lingo/lingo-lex.cpp index 48f71527f5c5..bd84f79d7b50 100644 --- a/engines/director/lingo/lingo-lex.cpp +++ b/engines/director/lingo/lingo-lex.cpp @@ -1020,45 +1020,52 @@ YY_RULE_SETUP case 31: YY_RULE_SETUP #line 80 "engines/director/lingo/lingo-lex.l" -{ yylval.s = new Common::String(yytext); return ID; } +{ + yylval.s = new Common::String(yytext); + + if (Director::g_lingo->_builtins.contains(yytext)) + return BLTIN; + + return ID; + } YY_BREAK case 32: YY_RULE_SETUP -#line 81 "engines/director/lingo/lingo-lex.l" +#line 88 "engines/director/lingo/lingo-lex.l" { yylval.f = atof(yytext); return FLOAT; } YY_BREAK case 33: YY_RULE_SETUP -#line 82 "engines/director/lingo/lingo-lex.l" +#line 89 "engines/director/lingo/lingo-lex.l" { yylval.i = strtol(yytext, NULL, 10); return INT; } YY_BREAK case 34: YY_RULE_SETUP -#line 83 "engines/director/lingo/lingo-lex.l" +#line 90 "engines/director/lingo/lingo-lex.l" { return *yytext; } YY_BREAK case 35: /* rule 35 can match eol */ YY_RULE_SETUP -#line 84 "engines/director/lingo/lingo-lex.l" +#line 91 "engines/director/lingo/lingo-lex.l" { return '\n'; } YY_BREAK case 36: YY_RULE_SETUP -#line 85 "engines/director/lingo/lingo-lex.l" +#line 92 "engines/director/lingo/lingo-lex.l" { yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; } YY_BREAK case 37: YY_RULE_SETUP -#line 86 "engines/director/lingo/lingo-lex.l" +#line 93 "engines/director/lingo/lingo-lex.l" YY_BREAK case 38: YY_RULE_SETUP -#line 88 "engines/director/lingo/lingo-lex.l" +#line 95 "engines/director/lingo/lingo-lex.l" ECHO; YY_BREAK -#line 1062 "engines/director/lingo/lingo-lex.cpp" +#line 1069 "engines/director/lingo/lingo-lex.cpp" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2058,7 +2065,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 88 "engines/director/lingo/lingo-lex.l" +#line 95 "engines/director/lingo/lingo-lex.l" diff --git a/engines/director/lingo/lingo-lex.l b/engines/director/lingo/lingo-lex.l index 2e42471daa39..6144bba44873 100644 --- a/engines/director/lingo/lingo-lex.l +++ b/engines/director/lingo/lingo-lex.l @@ -77,7 +77,14 @@ whitespace [\t ] [>][=] { return tGE; } [<][=] { return tLE; } -{identifier} { yylval.s = new Common::String(yytext); return ID; } +{identifier} { + yylval.s = new Common::String(yytext); + + if (Director::g_lingo->_builtins.contains(yytext)) + return BLTIN; + + return ID; + } {constfloat} { yylval.f = atof(yytext); return FLOAT; } {constinteger} { yylval.i = strtol(yytext, NULL, 10); return INT; } {operator} { return *yytext; } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index c6c903d29b19..bd53ff27a80c 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -160,7 +160,6 @@ class Lingo { return (l + instLen - 1) / instLen; } - int codeFunc(Common::String *name, int nargs); void codeArg(Common::String *s); void codeArgStore(); int codeId(Common::String &s);