diff options
author | Eugene Sandulenko | 2016-07-07 19:35:45 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 6636c9006bf9e274f6d7e85556f3426e4b3594df (patch) | |
tree | 8fb67af9f9bf60939d2d55b805209bd7ab6b6d5e | |
parent | 1745917752f5ec85f8a3b2b65dc1b2321aa576ab (diff) | |
download | scummvm-rg350-6636c9006bf9e274f6d7e85556f3426e4b3594df.tar.gz scummvm-rg350-6636c9006bf9e274f6d7e85556f3426e4b3594df.tar.bz2 scummvm-rg350-6636c9006bf9e274f6d7e85556f3426e4b3594df.zip |
DIRECTOR: Lingo: Provide error position in the file
-rw-r--r-- | engines/director/director.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.cpp | 770 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.y | 21 | ||||
-rw-r--r-- | engines/director/lingo/lingo-lex.cpp | 174 | ||||
-rw-r--r-- | engines/director/lingo/lingo-lex.l | 88 | ||||
-rw-r--r-- | engines/director/lingo/lingo.cpp | 4 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 3 |
7 files changed, 555 insertions, 507 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 29b62e2996..8dc9ca7f67 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -121,7 +121,7 @@ Common::Error DirectorEngine::run() { else if x = 2 then\n\ put 2.1\n\ put 2.2\n\ - else if x = 3 then put 3\n\ + else if x = 3 then put 3\n\ end if\n\ if x = 4 then put 4\n\ else put 5\n\ diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index 2b8e37a76a..f295ea0bc3 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -169,7 +169,7 @@ extern int yylex(); extern int yyparse(); -void yyerror(char *s) { error("%s", s); } +void yyerror(char *s) { error("%s at line %d col %d", s, Director::g_lingo->_linenumber, Director::g_lingo->_colnumber); } using namespace Director; @@ -432,16 +432,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 61 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 383 +#define YYLAST 384 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 57 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 31 +#define YYNNTS 32 /* YYNRULES -- Number of rules. */ -#define YYNRULES 95 +#define YYNRULES 96 /* YYNRULES -- Number of states. */ -#define YYNSTATES 204 +#define YYNSTATES 205 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 @@ -490,72 +490,72 @@ static const yytype_uint8 yytranslate[] = YYRHS. */ static const yytype_uint16 yyprhs[] = { - 0, 0, 3, 7, 9, 10, 12, 14, 16, 18, - 20, 22, 27, 32, 37, 39, 41, 43, 45, 54, - 66, 79, 88, 100, 112, 119, 130, 141, 142, 146, - 149, 151, 158, 160, 166, 168, 172, 176, 179, 183, - 185, 187, 188, 189, 190, 193, 196, 198, 200, 205, - 210, 212, 214, 218, 222, 226, 230, 234, 238, 242, - 246, 250, 253, 256, 260, 263, 266, 269, 271, 273, - 276, 278, 282, 285, 288, 291, 294, 298, 301, 305, - 308, 311, 313, 317, 320, 324, 325, 334, 335, 337, - 341, 346, 347, 351, 352, 354 + 0, 0, 3, 7, 9, 11, 12, 14, 16, 18, + 20, 22, 24, 29, 34, 39, 41, 43, 45, 47, + 56, 68, 81, 90, 102, 114, 121, 132, 143, 144, + 148, 151, 153, 160, 162, 168, 170, 174, 178, 181, + 185, 187, 189, 190, 191, 192, 195, 198, 200, 202, + 207, 212, 214, 216, 220, 224, 228, 232, 236, 240, + 244, 248, 252, 255, 258, 262, 265, 268, 271, 273, + 275, 278, 280, 284, 287, 290, 293, 296, 300, 303, + 307, 310, 313, 315, 319, 322, 326, 327, 336, 337, + 339, 343, 348, 349, 353, 354, 356 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 58, 0, -1, 58, 51, 59, -1, 59, -1, -1, - 82, -1, 77, -1, 86, -1, 60, -1, 62, -1, - 1, -1, 31, 76, 22, 10, -1, 33, 10, 45, - 76, -1, 33, 10, 35, 76, -1, 76, -1, 77, - -1, 61, -1, 63, -1, 69, 52, 68, 53, 75, - 74, 16, 32, -1, 70, 45, 76, 74, 35, 76, - 74, 75, 74, 16, 32, -1, 70, 45, 76, 74, - 13, 35, 76, 74, 75, 74, 16, 32, -1, 71, - 68, 34, 51, 75, 74, 16, 21, -1, 71, 68, - 34, 51, 75, 74, 14, 75, 74, 16, 21, -1, - 71, 68, 34, 51, 75, 74, 73, 65, 74, 16, - 21, -1, 71, 68, 34, 73, 61, 74, -1, 71, - 68, 34, 73, 61, 74, 38, 73, 61, 74, -1, - 71, 68, 34, 73, 61, 74, 66, 74, 64, 74, - -1, -1, 38, 73, 61, -1, 65, 67, -1, 67, - -1, 72, 68, 34, 73, 62, 74, -1, 66, -1, - 72, 68, 34, 75, 74, -1, 76, -1, 76, 45, - 76, -1, 52, 68, 53, -1, 32, 37, -1, 32, - 36, 10, -1, 21, -1, 15, -1, -1, -1, -1, - 75, 51, -1, 75, 62, -1, 7, -1, 8, -1, - 9, 52, 87, 53, -1, 10, 52, 87, 53, -1, - 10, -1, 60, -1, 76, 46, 76, -1, 76, 47, - 76, -1, 76, 48, 76, -1, 76, 49, 76, -1, - 76, 54, 76, -1, 76, 55, 76, -1, 76, 44, - 76, -1, 76, 39, 76, -1, 76, 40, 76, -1, - 46, 76, -1, 47, 76, -1, 52, 76, 53, -1, - 25, 11, -1, 26, 10, -1, 31, 76, -1, 79, - -1, 17, -1, 19, 78, -1, 10, -1, 78, 56, - 10, -1, 20, 23, -1, 20, 28, -1, 20, 30, - -1, 20, 80, -1, 20, 80, 81, -1, 20, 81, - -1, 35, 18, 11, -1, 18, 11, -1, 35, 11, - -1, 11, -1, 29, 27, 11, -1, 27, 11, -1, - 35, 27, 11, -1, -1, 24, 10, 83, 73, 84, - 51, 85, 75, -1, -1, 10, -1, 84, 56, 10, - -1, 84, 51, 56, 10, -1, -1, 10, 73, 87, - -1, -1, 76, -1, 87, 56, 76, -1 + 58, 0, -1, 58, 59, 60, -1, 60, -1, 51, + -1, -1, 83, -1, 78, -1, 87, -1, 61, -1, + 63, -1, 1, -1, 31, 77, 22, 10, -1, 33, + 10, 45, 77, -1, 33, 10, 35, 77, -1, 77, + -1, 78, -1, 62, -1, 64, -1, 70, 52, 69, + 53, 76, 75, 16, 32, -1, 71, 45, 77, 75, + 35, 77, 75, 76, 75, 16, 32, -1, 71, 45, + 77, 75, 13, 35, 77, 75, 76, 75, 16, 32, + -1, 72, 69, 34, 59, 76, 75, 16, 21, -1, + 72, 69, 34, 59, 76, 75, 14, 76, 75, 16, + 21, -1, 72, 69, 34, 59, 76, 75, 74, 66, + 75, 16, 21, -1, 72, 69, 34, 74, 62, 75, + -1, 72, 69, 34, 74, 62, 75, 38, 74, 62, + 75, -1, 72, 69, 34, 74, 62, 75, 67, 75, + 65, 75, -1, -1, 38, 74, 62, -1, 66, 68, + -1, 68, -1, 73, 69, 34, 74, 63, 75, -1, + 67, -1, 73, 69, 34, 76, 75, -1, 77, -1, + 77, 45, 77, -1, 52, 69, 53, -1, 32, 37, + -1, 32, 36, 10, -1, 21, -1, 15, -1, -1, + -1, -1, 76, 59, -1, 76, 63, -1, 7, -1, + 8, -1, 9, 52, 88, 53, -1, 10, 52, 88, + 53, -1, 10, -1, 61, -1, 77, 46, 77, -1, + 77, 47, 77, -1, 77, 48, 77, -1, 77, 49, + 77, -1, 77, 54, 77, -1, 77, 55, 77, -1, + 77, 44, 77, -1, 77, 39, 77, -1, 77, 40, + 77, -1, 46, 77, -1, 47, 77, -1, 52, 77, + 53, -1, 25, 11, -1, 26, 10, -1, 31, 77, + -1, 80, -1, 17, -1, 19, 79, -1, 10, -1, + 79, 56, 10, -1, 20, 23, -1, 20, 28, -1, + 20, 30, -1, 20, 81, -1, 20, 81, 82, -1, + 20, 82, -1, 35, 18, 11, -1, 18, 11, -1, + 35, 11, -1, 11, -1, 29, 27, 11, -1, 27, + 11, -1, 35, 27, 11, -1, -1, 24, 10, 84, + 74, 85, 59, 86, 76, -1, -1, 10, -1, 85, + 56, 10, -1, 85, 59, 56, 10, -1, -1, 10, + 74, 88, -1, -1, 77, -1, 88, 56, 77, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 93, 93, 94, 97, 98, 99, 100, 101, 102, - 103, 106, 112, 118, 125, 126, 128, 129, 134, 145, - 161, 175, 182, 191, 200, 210, 220, 231, 232, 235, - 236, 239, 246, 247, 255, 256, 257, 259, 261, 267, - 273, 280, 282, 284, 285, 286, 289, 294, 297, 303, - 311, 314, 315, 316, 317, 318, 319, 320, 321, 322, - 323, 324, 325, 326, 329, 330, 331, 332, 333, 335, - 338, 339, 350, 351, 352, 353, 358, 364, 371, 372, - 373, 374, 377, 378, 379, 407, 407, 414, 415, 416, - 417, 419, 422, 430, 431, 432 + 0, 93, 93, 94, 97, 102, 103, 104, 105, 106, + 107, 108, 111, 117, 123, 130, 131, 133, 134, 139, + 150, 166, 180, 187, 196, 205, 215, 225, 236, 237, + 240, 241, 244, 251, 252, 260, 261, 262, 264, 266, + 272, 278, 285, 287, 289, 290, 291, 294, 299, 302, + 308, 316, 319, 320, 321, 322, 323, 324, 325, 326, + 327, 328, 329, 330, 331, 334, 335, 336, 337, 338, + 340, 343, 344, 355, 356, 357, 358, 363, 369, 376, + 377, 378, 379, 382, 383, 384, 412, 412, 419, 420, + 421, 422, 424, 427, 435, 436, 437 }; #endif @@ -571,7 +571,7 @@ static const char *const yytname[] = "tPREVIOUS", "tPUT", "tREPEAT", "tSET", "tTHEN", "tTO", "tWITH", "tWHILE", "tNLELSE", "tGE", "tLE", "tGT", "tLT", "tEQ", "tNEQ", "'='", "'+'", "'-'", "'*'", "'/'", "'%'", "'\\n'", "'('", "')'", "'>'", "'<'", - "','", "$accept", "program", "programline", "asgn", "stmtoneliner", + "','", "$accept", "program", "nl", "programline", "asgn", "stmtoneliner", "stmt", "ifstmt", "elsestmtoneliner", "elseifstmt", "elseifstmtoneliner", "elseifstmt1", "cond", "repeatwhile", "repeatwith", "if", "elseif", "begin", "end", "stmtlist", "expr", "func", "globallist", "gotofunc", @@ -597,31 +597,31 @@ static const yytype_uint16 yytoknum[] = /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 57, 58, 58, 59, 59, 59, 59, 59, 59, - 59, 60, 60, 60, 61, 61, 62, 62, 62, 62, - 62, 63, 63, 63, 63, 63, 63, 64, 64, 65, - 65, 66, 67, 67, 68, 68, 68, 69, 70, 71, - 72, 73, 74, 75, 75, 75, 76, 76, 76, 76, - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 76, 77, 77, 77, 77, 77, 77, - 78, 78, 79, 79, 79, 79, 79, 79, 80, 80, - 80, 80, 81, 81, 81, 83, 82, 84, 84, 84, - 84, 85, 86, 87, 87, 87 + 0, 57, 58, 58, 59, 60, 60, 60, 60, 60, + 60, 60, 61, 61, 61, 62, 62, 63, 63, 63, + 63, 63, 64, 64, 64, 64, 64, 64, 65, 65, + 66, 66, 67, 68, 68, 69, 69, 69, 70, 71, + 72, 73, 74, 75, 76, 76, 76, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 78, 78, 78, 78, 78, + 78, 79, 79, 80, 80, 80, 80, 80, 80, 81, + 81, 81, 81, 82, 82, 82, 84, 83, 85, 85, + 85, 85, 86, 87, 88, 88, 88 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 3, 1, 0, 1, 1, 1, 1, 1, - 1, 4, 4, 4, 1, 1, 1, 1, 8, 11, - 12, 8, 11, 11, 6, 10, 10, 0, 3, 2, - 1, 6, 1, 5, 1, 3, 3, 2, 3, 1, - 1, 0, 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 + 0, 2, 3, 1, 1, 0, 1, 1, 1, 1, + 1, 1, 4, 4, 4, 1, 1, 1, 1, 8, + 11, 12, 8, 11, 11, 6, 10, 10, 0, 3, + 2, 1, 6, 1, 5, 1, 3, 3, 2, 3, + 1, 1, 0, 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 @@ -629,36 +629,36 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 0, 10, 46, 47, 0, 41, 68, 0, 0, 39, + 0, 11, 47, 48, 0, 42, 69, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 3, 51, 16, 9, 17, 0, 0, 0, 14, 6, - 67, 5, 7, 93, 93, 93, 70, 69, 81, 0, - 72, 0, 73, 0, 74, 0, 75, 77, 85, 64, - 65, 50, 0, 51, 66, 0, 37, 0, 61, 62, - 0, 1, 0, 0, 0, 0, 0, 34, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 94, 0, 0, - 92, 0, 79, 83, 0, 80, 0, 0, 0, 76, - 41, 0, 0, 38, 0, 0, 63, 2, 0, 42, - 0, 0, 41, 0, 59, 60, 58, 52, 53, 54, - 55, 56, 57, 48, 0, 49, 71, 82, 78, 84, - 87, 11, 13, 12, 43, 0, 36, 43, 0, 35, - 95, 88, 0, 42, 0, 0, 42, 42, 15, 91, - 0, 44, 45, 0, 0, 42, 41, 24, 0, 43, - 89, 0, 42, 43, 43, 0, 0, 40, 41, 42, - 0, 90, 86, 18, 43, 42, 42, 21, 42, 32, - 30, 0, 0, 27, 0, 42, 0, 0, 29, 0, - 0, 42, 41, 42, 41, 0, 0, 0, 0, 41, - 25, 0, 26, 0, 0, 19, 22, 23, 42, 28, - 42, 20, 33, 31 + 3, 52, 17, 10, 18, 0, 0, 0, 15, 7, + 68, 6, 8, 94, 94, 94, 71, 70, 82, 0, + 73, 0, 74, 0, 75, 0, 76, 78, 86, 65, + 66, 51, 0, 52, 67, 0, 38, 0, 62, 63, + 0, 1, 4, 0, 0, 0, 0, 0, 35, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, + 0, 93, 0, 80, 84, 0, 81, 0, 0, 0, + 77, 42, 0, 0, 39, 0, 0, 64, 2, 0, + 43, 0, 0, 42, 0, 60, 61, 59, 53, 54, + 55, 56, 57, 58, 49, 0, 50, 72, 83, 79, + 85, 88, 12, 14, 13, 44, 0, 37, 44, 0, + 36, 96, 89, 0, 43, 0, 0, 43, 43, 16, + 0, 92, 45, 46, 0, 0, 43, 42, 25, 90, + 0, 44, 0, 43, 44, 44, 0, 0, 41, 42, + 43, 0, 91, 87, 19, 44, 43, 43, 22, 43, + 33, 31, 0, 0, 28, 0, 43, 0, 0, 30, + 0, 0, 43, 42, 43, 42, 0, 0, 0, 0, + 42, 26, 0, 27, 0, 0, 20, 23, 24, 43, + 29, 43, 21, 34, 32 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 19, 20, 53, 22, 142, 24, 183, 168, 169, - 170, 66, 25, 26, 27, 171, 193, 125, 133, 28, - 138, 37, 30, 46, 47, 31, 90, 132, 149, 32, - 78 + -1, 19, 142, 20, 53, 22, 143, 24, 184, 169, + 170, 171, 67, 25, 26, 27, 172, 194, 126, 134, + 28, 139, 37, 30, 46, 47, 31, 91, 133, 151, + 32, 79 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing @@ -666,127 +666,127 @@ static const yytype_int16 yydefgoto[] = #define YYPACT_NINF -124 static const yytype_int16 yypact[] = { - 143, -124, -124, -124, -39, 328, -124, 35, 287, -124, - 40, 15, 41, 172, -25, 46, 172, 172, 172, 3, - -124, 7, -124, -124, -124, 8, 18, 218, 316, -124, - -124, -124, -124, 172, 172, 172, -124, 31, -124, 77, - -124, 78, -124, 63, -124, 13, 32, -124, -124, -124, - -124, 39, 172, -124, 86, 82, -124, -20, -17, -17, - 292, -124, 143, 218, 172, 218, 60, 304, 172, 172, - 172, 172, 172, 172, 172, 172, 172, 316, -23, -1, - 47, 87, -124, -124, 90, -124, 91, 94, 79, -124, - -124, 86, 99, -124, 172, 172, -124, -124, 58, 316, - 59, 280, 66, 172, 316, 316, 316, 240, 240, -17, - -17, 316, 316, -124, 172, -124, -124, -124, -124, -124, - 108, -124, 316, 316, -124, -3, -124, -124, 266, 316, - 316, -124, -8, 189, 84, 172, 189, -124, -124, 64, - 111, -124, -124, 106, 172, 316, 25, -9, 114, -124, - -124, 95, 316, -124, -124, 107, 122, -124, -124, -124, - 218, -124, 189, -124, -124, 189, 189, -124, 122, -124, - -124, 218, 266, 100, 105, 189, 131, 133, -124, 139, - 123, -124, -124, -124, -124, 140, 126, 138, 144, -7, - -124, 266, -124, 235, 134, -124, -124, -124, 189, -124, - -124, -124, -124, -124 + 144, -124, -124, -124, -40, 329, -124, 23, 288, -124, + 28, 29, 37, 173, 6, 42, 173, 173, 173, 7, + -124, 9, -124, -124, -124, 5, 17, 219, 317, -124, + -124, -124, -124, 173, 173, 173, -124, 8, -124, 50, + -124, 57, -124, 53, -124, 12, -3, -124, -124, -124, + -124, 38, 173, -124, 87, 71, -124, -14, 148, 148, + 293, -124, -124, 144, 219, 173, 219, 55, 305, 173, + 173, 173, 173, 173, 173, 173, 173, 173, 317, -12, + -2, 35, 82, -124, -124, 84, -124, 91, 92, 66, + -124, -124, 87, 88, -124, 173, 173, -124, -124, 51, + 317, 54, 281, 59, 173, 317, 317, 317, 241, 241, + 148, 148, 317, 317, -124, 173, -124, -124, -124, -124, + -124, 96, -124, 317, 317, -124, 2, -124, -124, 267, + 317, 317, -124, -43, 190, 77, 173, 190, -124, -124, + 103, 63, -124, -124, 104, 173, 317, 13, -13, -124, + 111, -124, 90, 317, -124, -124, 102, 110, -124, -124, + -124, 219, -124, 190, -124, -124, 190, 190, -124, 110, + -124, -124, 219, 267, 100, 94, 190, 113, 123, -124, + 124, 114, -124, -124, -124, -124, 134, 125, 135, 137, + -5, -124, 267, -124, 236, 127, -124, -124, -124, 190, + -124, -124, -124, -124, -124 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -124, -124, 109, 16, -123, 0, -124, -124, -124, 23, - 5, -61, -124, -124, -124, 30, -4, -52, -107, 1, - 21, -124, -124, -124, 137, -124, -124, -124, -124, -124, - 45 + -124, -124, -15, 97, 16, -123, 0, -124, -124, -124, + 18, 3, -61, -124, -124, -124, 19, -4, -52, -106, + 1, 20, -124, -124, -124, 128, -124, -124, -124, -124, + -124, 21 }; /* 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 -51 +#define YYTABLE_NINF -52 static const yytype_int16 yytable[] = { - 23, 35, 98, 61, 100, 137, 157, -8, -43, -43, - 134, 55, 56, 33, 54, 94, 21, 58, 59, 60, - 136, 29, 68, 69, 85, 95, 49, 70, 67, 158, - 113, 86, 135, 114, 77, 77, 77, 75, 76, 154, - 87, 155, 162, 139, -43, 36, 165, 166, 140, 181, - 48, 50, 115, 91, 62, 114, 57, 175, -8, 41, - 63, 43, 23, 64, 67, 99, 101, 88, 199, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 21, 79, - 80, 143, 198, 29, 146, 147, 120, 81, 82, 83, - 84, 34, 93, 153, 102, 122, 123, 116, 128, 174, - 164, 117, 118, 114, 129, 119, 87, 173, 92, 121, - 180, 124, 126, 176, 177, 130, 179, 127, 131, 144, - 148, 150, 151, 185, 161, 68, 69, 163, 167, 190, - 70, 192, 71, 72, 73, 74, 145, 157, 182, 184, - 75, 76, 156, -4, 1, 152, 202, 186, 203, 187, - 2, 3, 4, 5, 172, 188, 194, 189, 195, 196, - 6, 67, 7, 8, 9, 197, 201, 10, 11, 12, - 159, 97, 67, 178, 13, 14, 15, 160, 191, 2, - 3, 4, 51, 89, 0, 0, 0, 0, 0, 16, - 17, 0, 0, 200, -4, 18, 2, 3, 4, 51, - 0, 0, 0, 52, 0, 15, 6, 0, 7, 8, - 9, 0, 0, 0, 11, 12, 0, 0, 16, 17, - 13, 14, 15, 0, 18, 2, 3, 4, 51, 0, - 0, 0, 0, 0, 0, 16, 17, 0, 0, 0, - 141, 18, 2, 3, 4, 51, 0, 0, 0, 52, - 0, 15, 6, 0, 7, 8, 9, 0, 0, 0, - 11, 12, 0, 0, 16, 17, 13, 14, 15, 0, - 65, 0, 0, 2, 3, 4, 51, 0, 0, 68, - 69, 16, 17, 6, 70, 7, 8, 18, 73, 74, - 0, 11, 12, 0, 75, 76, 0, 13, 38, 15, - 0, 0, 0, 0, 0, 39, 0, 0, 0, 0, - 40, 0, 16, 17, 41, 42, 43, 44, 18, 68, - 69, 0, 45, 0, 70, 103, 71, 72, 73, 74, - 0, 68, 69, 96, 75, 76, 70, 0, 71, 72, - 73, 74, 0, 68, 69, 96, 75, 76, 70, 103, - 71, 72, 73, 74, 0, 68, 69, 0, 75, 76, - 70, 0, 71, 72, 73, 74, 0, -50, -50, 0, - 75, 76, -50, 0, 0, 0, -50, -50, 0, 0, - 34, 0, -50, -50 + 23, 35, 158, 99, 63, 101, 138, 61, 62, -9, + -44, -44, 33, 140, 54, 135, 21, 58, 59, 60, + 29, 95, 137, 86, 41, 159, 43, 155, 68, 156, + 87, 96, 89, 36, 78, 78, 78, 136, 48, 88, + 49, 114, 55, 56, 115, 163, -44, 50, 166, 167, + 182, 116, 57, 92, 115, 80, 81, 64, 62, 176, + -9, 83, 65, 23, 82, 68, 100, 102, 84, 200, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 21, + 85, 94, 144, 29, 199, 147, 148, 121, 128, 103, + 34, 115, 117, 88, 154, 118, 123, 124, 122, 129, + 175, 165, 119, 120, 125, 130, 132, 127, 174, 93, + 62, 181, 145, 149, 177, 178, 131, 180, 141, 150, + 152, 162, 164, 168, 186, 158, 69, 70, 185, 187, + 191, 71, 193, 72, 73, 74, 75, 146, 183, 188, + 189, 76, 77, 157, -5, 1, 153, 203, 190, 204, + 195, 2, 3, 4, 5, 173, 197, 196, 198, 202, + 98, 6, 68, 7, 8, 9, 160, 161, 10, 11, + 12, 0, 179, 68, 90, 13, 14, 15, 0, 192, + 2, 3, 4, 51, 0, 0, 0, 69, 70, 0, + 16, 17, 71, 0, 201, -5, 18, 2, 3, 4, + 51, 0, 76, 77, 52, 0, 15, 6, 0, 7, + 8, 9, 0, 0, 0, 11, 12, 0, 0, 16, + 17, 13, 14, 15, 0, 18, 2, 3, 4, 51, + 0, 0, 0, 0, 0, 0, 16, 17, 0, 0, + 0, 62, 18, 2, 3, 4, 51, 0, 0, 0, + 52, 0, 15, 6, 0, 7, 8, 9, 0, 0, + 0, 11, 12, 0, 0, 16, 17, 13, 14, 15, + 0, 66, 0, 0, 2, 3, 4, 51, 0, 0, + 69, 70, 16, 17, 6, 71, 7, 8, 18, 74, + 75, 0, 11, 12, 0, 76, 77, 0, 13, 38, + 15, 0, 0, 0, 0, 0, 39, 0, 0, 0, + 0, 40, 0, 16, 17, 41, 42, 43, 44, 18, + 69, 70, 0, 45, 0, 71, 104, 72, 73, 74, + 75, 0, 69, 70, 97, 76, 77, 71, 0, 72, + 73, 74, 75, 0, 69, 70, 97, 76, 77, 71, + 104, 72, 73, 74, 75, 0, 69, 70, 0, 76, + 77, 71, 0, 72, 73, 74, 75, 0, -51, -51, + 0, 76, 77, -51, 0, 0, 0, -51, -51, 0, + 0, 34, 0, -51, -51 }; static const yytype_int16 yycheck[] = { - 0, 5, 63, 0, 65, 128, 15, 0, 15, 16, - 13, 36, 37, 52, 13, 35, 0, 16, 17, 18, - 127, 0, 39, 40, 11, 45, 11, 44, 27, 38, - 53, 18, 35, 56, 33, 34, 35, 54, 55, 14, - 27, 16, 149, 51, 51, 10, 153, 154, 56, 172, - 10, 10, 53, 52, 51, 56, 10, 164, 51, 27, - 52, 29, 62, 45, 63, 64, 65, 35, 191, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 62, 34, - 35, 133, 189, 62, 136, 137, 90, 56, 11, 11, - 27, 52, 10, 145, 34, 94, 95, 10, 102, 160, - 152, 11, 11, 56, 103, 11, 27, 159, 22, 10, - 171, 53, 53, 165, 166, 114, 168, 51, 10, 35, - 56, 10, 16, 175, 10, 39, 40, 32, 21, 181, - 44, 183, 46, 47, 48, 49, 135, 15, 38, 34, - 54, 55, 146, 0, 1, 144, 198, 16, 200, 16, - 7, 8, 9, 10, 158, 16, 16, 34, 32, 21, - 17, 160, 19, 20, 21, 21, 32, 24, 25, 26, - 147, 62, 171, 168, 31, 32, 33, 147, 182, 7, - 8, 9, 10, 46, -1, -1, -1, -1, -1, 46, - 47, -1, -1, 193, 51, 52, 7, 8, 9, 10, - -1, -1, -1, 31, -1, 33, 17, -1, 19, 20, - 21, -1, -1, -1, 25, 26, -1, -1, 46, 47, - 31, 32, 33, -1, 52, 7, 8, 9, 10, -1, - -1, -1, -1, -1, -1, 46, 47, -1, -1, -1, - 51, 52, 7, 8, 9, 10, -1, -1, -1, 31, - -1, 33, 17, -1, 19, 20, 21, -1, -1, -1, - 25, 26, -1, -1, 46, 47, 31, 32, 33, -1, - 52, -1, -1, 7, 8, 9, 10, -1, -1, 39, - 40, 46, 47, 17, 44, 19, 20, 52, 48, 49, - -1, 25, 26, -1, 54, 55, -1, 31, 11, 33, - -1, -1, -1, -1, -1, 18, -1, -1, -1, -1, - 23, -1, 46, 47, 27, 28, 29, 30, 52, 39, - 40, -1, 35, -1, 44, 45, 46, 47, 48, 49, - -1, 39, 40, 53, 54, 55, 44, -1, 46, 47, - 48, 49, -1, 39, 40, 53, 54, 55, 44, 45, - 46, 47, 48, 49, -1, 39, 40, -1, 54, 55, - 44, -1, 46, 47, 48, 49, -1, 39, 40, -1, - 54, 55, 44, -1, -1, -1, 48, 49, -1, -1, - 52, -1, 54, 55 + 0, 5, 15, 64, 19, 66, 129, 0, 51, 0, + 15, 16, 52, 56, 13, 13, 0, 16, 17, 18, + 0, 35, 128, 11, 27, 38, 29, 14, 27, 16, + 18, 45, 35, 10, 33, 34, 35, 35, 10, 27, + 11, 53, 36, 37, 56, 151, 51, 10, 154, 155, + 173, 53, 10, 52, 56, 34, 35, 52, 51, 165, + 51, 11, 45, 63, 56, 64, 65, 66, 11, 192, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 63, + 27, 10, 134, 63, 190, 137, 138, 91, 103, 34, + 52, 56, 10, 27, 146, 11, 95, 96, 10, 103, + 161, 153, 11, 11, 53, 104, 10, 53, 160, 22, + 51, 172, 35, 10, 166, 167, 115, 169, 133, 56, + 16, 10, 32, 21, 176, 15, 39, 40, 34, 16, + 182, 44, 184, 46, 47, 48, 49, 136, 38, 16, + 16, 54, 55, 147, 0, 1, 145, 199, 34, 201, + 16, 7, 8, 9, 10, 159, 21, 32, 21, 32, + 63, 17, 161, 19, 20, 21, 148, 148, 24, 25, + 26, -1, 169, 172, 46, 31, 32, 33, -1, 183, + 7, 8, 9, 10, -1, -1, -1, 39, 40, -1, + 46, 47, 44, -1, 194, 51, 52, 7, 8, 9, + 10, -1, 54, 55, 31, -1, 33, 17, -1, 19, + 20, 21, -1, -1, -1, 25, 26, -1, -1, 46, + 47, 31, 32, 33, -1, 52, 7, 8, 9, 10, + -1, -1, -1, -1, -1, -1, 46, 47, -1, -1, + -1, 51, 52, 7, 8, 9, 10, -1, -1, -1, + 31, -1, 33, 17, -1, 19, 20, 21, -1, -1, + -1, 25, 26, -1, -1, 46, 47, 31, 32, 33, + -1, 52, -1, -1, 7, 8, 9, 10, -1, -1, + 39, 40, 46, 47, 17, 44, 19, 20, 52, 48, + 49, -1, 25, 26, -1, 54, 55, -1, 31, 11, + 33, -1, -1, -1, -1, -1, 18, -1, -1, -1, + -1, 23, -1, 46, 47, 27, 28, 29, 30, 52, + 39, 40, -1, 35, -1, 44, 45, 46, 47, 48, + 49, -1, 39, 40, 53, 54, 55, 44, -1, 46, + 47, 48, 49, -1, 39, 40, 53, 54, 55, 44, + 45, 46, 47, 48, 49, -1, 39, 40, -1, 54, + 55, 44, -1, 46, 47, 48, 49, -1, 39, 40, + -1, 54, 55, 44, -1, -1, -1, 48, 49, -1, + -1, 52, -1, 54, 55 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -795,25 +795,25 @@ static const yytype_uint8 yystos[] = { 0, 1, 7, 8, 9, 10, 17, 19, 20, 21, 24, 25, 26, 31, 32, 33, 46, 47, 52, 58, - 59, 60, 61, 62, 63, 69, 70, 71, 76, 77, - 79, 82, 86, 52, 52, 73, 10, 78, 11, 18, - 23, 27, 28, 29, 30, 35, 80, 81, 10, 11, - 10, 10, 31, 60, 76, 36, 37, 10, 76, 76, - 76, 0, 51, 52, 45, 52, 68, 76, 39, 40, - 44, 46, 47, 48, 49, 54, 55, 76, 87, 87, - 87, 56, 11, 11, 27, 11, 18, 27, 35, 81, - 83, 76, 22, 10, 35, 45, 53, 59, 68, 76, - 68, 76, 34, 45, 76, 76, 76, 76, 76, 76, - 76, 76, 76, 53, 56, 53, 10, 11, 11, 11, - 73, 10, 76, 76, 53, 74, 53, 51, 73, 76, - 76, 10, 84, 75, 13, 35, 75, 61, 77, 51, - 56, 51, 62, 74, 35, 76, 74, 74, 56, 85, - 10, 16, 76, 74, 14, 16, 73, 15, 38, 66, - 72, 10, 75, 32, 74, 75, 75, 21, 65, 66, - 67, 72, 73, 74, 68, 75, 74, 74, 67, 74, - 68, 61, 38, 64, 34, 74, 16, 16, 16, 34, - 74, 73, 74, 73, 16, 32, 21, 21, 75, 61, - 62, 32, 74, 74 + 60, 61, 62, 63, 64, 70, 71, 72, 77, 78, + 80, 83, 87, 52, 52, 74, 10, 79, 11, 18, + 23, 27, 28, 29, 30, 35, 81, 82, 10, 11, + 10, 10, 31, 61, 77, 36, 37, 10, 77, 77, + 77, 0, 51, 59, 52, 45, 52, 69, 77, 39, + 40, 44, 46, 47, 48, 49, 54, 55, 77, 88, + 88, 88, 56, 11, 11, 27, 11, 18, 27, 35, + 82, 84, 77, 22, 10, 35, 45, 53, 60, 69, + 77, 69, 77, 34, 45, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 53, 56, 53, 10, 11, 11, + 11, 74, 10, 77, 77, 53, 75, 53, 59, 74, + 77, 77, 10, 85, 76, 13, 35, 76, 62, 78, + 56, 59, 59, 63, 75, 35, 77, 75, 75, 10, + 56, 86, 16, 77, 75, 14, 16, 74, 15, 38, + 67, 73, 10, 76, 32, 75, 76, 76, 21, 66, + 67, 68, 73, 74, 75, 69, 76, 75, 75, 68, + 75, 69, 62, 38, 65, 34, 75, 16, 16, 16, + 34, 75, 74, 75, 74, 16, 32, 21, 21, 76, + 62, 63, 32, 75, 75 }; #define yyerrok (yyerrstatus = 0) @@ -1627,18 +1627,26 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 8: -#line 101 "engines/director/lingo/lingo-gr.y" + case 4: +#line 97 "engines/director/lingo/lingo-gr.y" + { + g_lingo->_linenumber++; + g_lingo->_colnumber = 1; + ;} + break; + + case 9: +#line 106 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_xpop); ;} break; - case 10: -#line 103 "engines/director/lingo/lingo-gr.y" + case 11: +#line 108 "engines/director/lingo/lingo-gr.y" { yyerrok; ;} break; - case 11: -#line 106 "engines/director/lingo/lingo-gr.y" + case 12: +#line 111 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString((yyvsp[(4) - (4)].s)->c_str()); @@ -1647,8 +1655,8 @@ yyreduce: delete (yyvsp[(4) - (4)].s); ;} break; - case 12: -#line 112 "engines/director/lingo/lingo-gr.y" + case 13: +#line 117 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); @@ -1657,8 +1665,8 @@ yyreduce: delete (yyvsp[(2) - (4)].s); ;} break; - case 13: -#line 118 "engines/director/lingo/lingo-gr.y" + case 14: +#line 123 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); @@ -1667,13 +1675,13 @@ yyreduce: delete (yyvsp[(2) - (4)].s); ;} break; - case 14: -#line 125 "engines/director/lingo/lingo-gr.y" + case 15: +#line 130 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_xpop); ;} break; - case 18: -#line 134 "engines/director/lingo/lingo-gr.y" + case 19: +#line 139 "engines/director/lingo/lingo-gr.y" { inst body = 0, end = 0; WRITE_UINT32(&body, (yyvsp[(5) - (8)].code)); @@ -1682,8 +1690,8 @@ yyreduce: (*g_lingo->_currentScript)[(yyvsp[(1) - (8)].code) + 2] = end; ;} break; - case 19: -#line 145 "engines/director/lingo/lingo-gr.y" + case 20: +#line 150 "engines/director/lingo/lingo-gr.y" { inst init = 0, finish = 0, body = 0, end = 0, inc = 0; WRITE_UINT32(&init, (yyvsp[(3) - (11)].code)); @@ -1698,8 +1706,8 @@ yyreduce: (*g_lingo->_currentScript)[(yyvsp[(1) - (11)].code) + 5] = end; ;} break; - case 20: -#line 161 "engines/director/lingo/lingo-gr.y" + case 21: +#line 166 "engines/director/lingo/lingo-gr.y" { inst init = 0, finish = 0, body = 0, end = 0, inc = 0; WRITE_UINT32(&init, (yyvsp[(3) - (12)].code)); @@ -1714,8 +1722,8 @@ yyreduce: (*g_lingo->_currentScript)[(yyvsp[(1) - (12)].code) + 5] = end; ;} break; - case 21: -#line 175 "engines/director/lingo/lingo-gr.y" + case 22: +#line 180 "engines/director/lingo/lingo-gr.y" { inst then = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(5) - (8)].code)); @@ -1725,8 +1733,8 @@ yyreduce: g_lingo->processIf(0, 0); ;} break; - case 22: -#line 182 "engines/director/lingo/lingo-gr.y" + case 23: +#line 187 "engines/director/lingo/lingo-gr.y" { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(5) - (11)].code)); @@ -1738,8 +1746,8 @@ yyreduce: g_lingo->processIf(0, 0); ;} break; - case 23: -#line 191 "engines/director/lingo/lingo-gr.y" + case 24: +#line 196 "engines/director/lingo/lingo-gr.y" { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(5) - (11)].code)); @@ -1751,8 +1759,8 @@ yyreduce: g_lingo->processIf(0, (yyvsp[(9) - (11)].code)); ;} break; - case 24: -#line 200 "engines/director/lingo/lingo-gr.y" + case 25: +#line 205 "engines/director/lingo/lingo-gr.y" { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(4) - (6)].code)); @@ -1765,8 +1773,8 @@ yyreduce: g_lingo->processIf(0, 0); ;} break; - case 25: -#line 210 "engines/director/lingo/lingo-gr.y" + case 26: +#line 215 "engines/director/lingo/lingo-gr.y" { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(4) - (10)].code)); @@ -1779,8 +1787,8 @@ yyreduce: g_lingo->processIf(0, 0); ;} break; - case 26: -#line 220 "engines/director/lingo/lingo-gr.y" + case 27: +#line 225 "engines/director/lingo/lingo-gr.y" { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, (yyvsp[(4) - (10)].code)); @@ -1793,18 +1801,18 @@ yyreduce: g_lingo->processIf(0, (yyvsp[(10) - (10)].code)); ;} break; - case 27: -#line 231 "engines/director/lingo/lingo-gr.y" + case 28: +#line 236 "engines/director/lingo/lingo-gr.y" { (yyval.code) = 0; ;} break; - case 28: -#line 232 "engines/director/lingo/lingo-gr.y" + case 29: +#line 237 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (3)].code); ;} break; - case 31: -#line 239 "engines/director/lingo/lingo-gr.y" + case 32: +#line 244 "engines/director/lingo/lingo-gr.y" { inst then = 0; WRITE_UINT32(&then, (yyvsp[(4) - (6)].code)); @@ -1813,8 +1821,8 @@ yyreduce: g_lingo->codeLabel((yyvsp[(1) - (6)].code)); ;} break; - case 33: -#line 247 "engines/director/lingo/lingo-gr.y" + case 34: +#line 252 "engines/director/lingo/lingo-gr.y" { inst then = 0; WRITE_UINT32(&then, (yyvsp[(4) - (5)].code)); @@ -1823,23 +1831,23 @@ yyreduce: g_lingo->codeLabel((yyvsp[(1) - (5)].code)); ;} break; - case 34: -#line 255 "engines/director/lingo/lingo-gr.y" + case 35: +#line 260 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(STOP); ;} break; - case 35: -#line 256 "engines/director/lingo/lingo-gr.y" + case 36: +#line 261 "engines/director/lingo/lingo-gr.y" { g_lingo->code2(g_lingo->c_eq, STOP); ;} break; - case 37: -#line 259 "engines/director/lingo/lingo-gr.y" + case 38: +#line 264 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code3(g_lingo->c_repeatwhilecode, STOP, STOP); ;} break; - case 38: -#line 261 "engines/director/lingo/lingo-gr.y" + case 39: +#line 266 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code3(g_lingo->c_repeatwithcode, STOP, STOP); g_lingo->code3(STOP, STOP, STOP); @@ -1847,8 +1855,8 @@ yyreduce: delete (yyvsp[(3) - (3)].s); ;} break; - case 39: -#line 267 "engines/director/lingo/lingo-gr.y" + case 40: +#line 272 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code1(g_lingo->c_ifcode); g_lingo->code3(STOP, STOP, STOP); @@ -1856,8 +1864,8 @@ yyreduce: g_lingo->codeLabel(0); ;} break; - case 40: -#line 273 "engines/director/lingo/lingo-gr.y" + case 41: +#line 278 "engines/director/lingo/lingo-gr.y" { inst skipEnd; WRITE_UINT32(&skipEnd, 1); // We have to skip end to avoid multiple executions @@ -1866,23 +1874,23 @@ yyreduce: g_lingo->code1(skipEnd); ;} break; - case 41: -#line 280 "engines/director/lingo/lingo-gr.y" + case 42: +#line 285 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->_currentScript->size(); ;} break; - case 42: -#line 282 "engines/director/lingo/lingo-gr.y" + case 43: +#line 287 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(STOP); (yyval.code) = g_lingo->_currentScript->size(); ;} break; - case 43: -#line 284 "engines/director/lingo/lingo-gr.y" + case 44: +#line 289 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->_currentScript->size(); ;} break; - case 46: -#line 289 "engines/director/lingo/lingo-gr.y" + case 47: +#line 294 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code1(g_lingo->c_constpush); inst i = 0; @@ -1890,15 +1898,15 @@ yyreduce: g_lingo->code1(i); ;} break; - case 47: -#line 294 "engines/director/lingo/lingo-gr.y" + case 48: +#line 299 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code1(g_lingo->c_fconstpush); g_lingo->codeFloat((yyvsp[(1) - (1)].f)); ;} break; - case 48: -#line 297 "engines/director/lingo/lingo-gr.y" + case 49: +#line 302 "engines/director/lingo/lingo-gr.y" { 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)); @@ -1907,8 +1915,8 @@ yyreduce: delete (yyvsp[(1) - (4)].s); ;} break; - case 49: -#line 303 "engines/director/lingo/lingo-gr.y" + case 50: +#line 308 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->code1(g_lingo->c_call); g_lingo->codeString((yyvsp[(1) - (4)].s)->c_str()); @@ -1919,121 +1927,121 @@ yyreduce: delete (yyvsp[(1) - (4)].s); ;} break; - case 50: -#line 311 "engines/director/lingo/lingo-gr.y" + case 51: +#line 316 "engines/director/lingo/lingo-gr.y" { (yyval.code) = g_lingo->codeId(*(yyvsp[(1) - (1)].s)); delete (yyvsp[(1) - (1)].s); ;} break; - case 52: -#line 315 "engines/director/lingo/lingo-gr.y" + case 53: +#line 320 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_add); ;} break; - case 53: -#line 316 "engines/director/lingo/lingo-gr.y" + case 54: +#line 321 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_sub); ;} break; - case 54: -#line 317 "engines/director/lingo/lingo-gr.y" + case 55: +#line 322 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_mul); ;} break; - case 55: -#line 318 "engines/director/lingo/lingo-gr.y" + case 56: +#line 323 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_div); ;} break; - case 56: -#line 319 "engines/director/lingo/lingo-gr.y" + case 57: +#line 324 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gt); ;} break; - case 57: -#line 320 "engines/director/lingo/lingo-gr.y" + case 58: +#line 325 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_lt); ;} break; - case 58: -#line 321 "engines/director/lingo/lingo-gr.y" + case 59: +#line 326 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_neq); ;} break; - case 59: -#line 322 "engines/director/lingo/lingo-gr.y" + case 60: +#line 327 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_ge); ;} break; - case 60: -#line 323 "engines/director/lingo/lingo-gr.y" + case 61: +#line 328 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_le); ;} break; - case 61: -#line 324 "engines/director/lingo/lingo-gr.y" + case 62: +#line 329 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (2)].code); ;} break; - case 62: -#line 325 "engines/director/lingo/lingo-gr.y" + case 63: +#line 330 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (2)].code); g_lingo->code1(g_lingo->c_negate); ;} break; - case 63: -#line 326 "engines/director/lingo/lingo-gr.y" + case 64: +#line 331 "engines/director/lingo/lingo-gr.y" { (yyval.code) = (yyvsp[(2) - (3)].code); ;} break; - case 64: -#line 329 "engines/director/lingo/lingo-gr.y" + case 65: +#line 334 "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 65: -#line 330 "engines/director/lingo/lingo-gr.y" + case 66: +#line 335 "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 66: -#line 331 "engines/director/lingo/lingo-gr.y" + case 67: +#line 336 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_printtop); ;} break; - case 68: -#line 333 "engines/director/lingo/lingo-gr.y" + case 69: +#line 338 "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); ;} break; - case 70: -#line 338 "engines/director/lingo/lingo-gr.y" + case 71: +#line 343 "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 71: -#line 339 "engines/director/lingo/lingo-gr.y" + case 72: +#line 344 "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 72: -#line 350 "engines/director/lingo/lingo-gr.y" + case 73: +#line 355 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotoloop); ;} break; - case 73: -#line 351 "engines/director/lingo/lingo-gr.y" + case 74: +#line 356 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotonext); ;} break; - case 74: -#line 352 "engines/director/lingo/lingo-gr.y" + case 75: +#line 357 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_gotoprevious); ;} break; - case 75: -#line 353 "engines/director/lingo/lingo-gr.y" + case 76: +#line 358 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_goto); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); @@ -2041,8 +2049,8 @@ yyreduce: delete (yyvsp[(2) - (2)].s); ;} break; - case 76: -#line 358 "engines/director/lingo/lingo-gr.y" + case 77: +#line 363 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_goto); g_lingo->codeString((yyvsp[(2) - (3)].s)->c_str()); @@ -2051,8 +2059,8 @@ yyreduce: delete (yyvsp[(3) - (3)].s); ;} break; - case 77: -#line 364 "engines/director/lingo/lingo-gr.y" + case 78: +#line 369 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_goto); g_lingo->codeString(""); @@ -2060,48 +2068,48 @@ yyreduce: delete (yyvsp[(2) - (2)].s); ;} break; - case 78: -#line 371 "engines/director/lingo/lingo-gr.y" + case 79: +#line 376 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 79: -#line 372 "engines/director/lingo/lingo-gr.y" + case 80: +#line 377 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 80: -#line 373 "engines/director/lingo/lingo-gr.y" + case 81: +#line 378 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 81: -#line 374 "engines/director/lingo/lingo-gr.y" + case 82: +#line 379 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(1) - (1)].s); ;} break; - case 82: -#line 377 "engines/director/lingo/lingo-gr.y" + case 83: +#line 382 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 83: -#line 378 "engines/director/lingo/lingo-gr.y" + case 84: +#line 383 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(2) - (2)].s); ;} break; - case 84: -#line 379 "engines/director/lingo/lingo-gr.y" + case 85: +#line 384 "engines/director/lingo/lingo-gr.y" { (yyval.s) = (yyvsp[(3) - (3)].s); ;} break; - case 85: -#line 407 "engines/director/lingo/lingo-gr.y" + case 86: +#line 412 "engines/director/lingo/lingo-gr.y" { g_lingo->_indef = true; ;} break; - case 86: -#line 408 "engines/director/lingo/lingo-gr.y" + case 87: +#line 413 "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); @@ -2109,33 +2117,33 @@ yyreduce: g_lingo->_indef = false; ;} break; - case 87: -#line 414 "engines/director/lingo/lingo-gr.y" + case 88: +#line 419 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 0; ;} break; - case 88: -#line 415 "engines/director/lingo/lingo-gr.y" + case 89: +#line 420 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(1) - (1)].s)); (yyval.narg) = 1; ;} break; - case 89: -#line 416 "engines/director/lingo/lingo-gr.y" + case 90: +#line 421 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(3) - (3)].s)); (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;} break; - case 90: -#line 417 "engines/director/lingo/lingo-gr.y" + case 91: +#line 422 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArg((yyvsp[(4) - (4)].s)); (yyval.narg) = (yyvsp[(1) - (4)].narg) + 1; ;} break; - case 91: -#line 419 "engines/director/lingo/lingo-gr.y" + case 92: +#line 424 "engines/director/lingo/lingo-gr.y" { g_lingo->codeArgStore(); ;} break; - case 92: -#line 422 "engines/director/lingo/lingo-gr.y" + case 93: +#line 427 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->c_call); g_lingo->codeString((yyvsp[(1) - (3)].s)->c_str()); @@ -2144,24 +2152,24 @@ yyreduce: g_lingo->code1(numpar); ;} break; - case 93: -#line 430 "engines/director/lingo/lingo-gr.y" + case 94: +#line 435 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 0; ;} break; - case 94: -#line 431 "engines/director/lingo/lingo-gr.y" + case 95: +#line 436 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = 1; ;} break; - case 95: -#line 432 "engines/director/lingo/lingo-gr.y" + case 96: +#line 437 "engines/director/lingo/lingo-gr.y" { (yyval.narg) = (yyvsp[(1) - (3)].narg) + 1; ;} break; /* Line 1267 of yacc.c. */ -#line 2165 "engines/director/lingo/lingo-gr.cpp" +#line 2173 "engines/director/lingo/lingo-gr.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2375,6 +2383,6 @@ yyreturn: } -#line 435 "engines/director/lingo/lingo-gr.y" +#line 440 "engines/director/lingo/lingo-gr.y" diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index 221c7219db..e5d5e72f2b 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -56,7 +56,7 @@ extern int yylex(); extern int yyparse(); -void yyerror(char *s) { error("%s", s); } +void yyerror(char *s) { error("%s at line %d col %d", s, Director::g_lingo->_linenumber, Director::g_lingo->_colnumber); } using namespace Director; @@ -90,10 +90,15 @@ using namespace Director; %% -program: program '\n' programline +program: program nl programline | programline ; +nl: '\n' { + g_lingo->_linenumber++; + g_lingo->_colnumber = 1; + } + programline: | defn | func @@ -172,14 +177,14 @@ stmt: stmtoneliner (*g_lingo->_currentScript)[$1 + 5] = end; } /* end, if cond fails */ ; -ifstmt: if cond tTHEN '\n' stmtlist end tEND tIF { +ifstmt: if cond tTHEN nl stmtlist end tEND tIF { inst then = 0, end = 0; WRITE_UINT32(&then, $5); WRITE_UINT32(&end, $6); (*g_lingo->_currentScript)[$1 + 1] = then; /* thenpart */ (*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */ g_lingo->processIf(0, 0); } - | if cond tTHEN '\n' stmtlist end tELSE stmtlist end tEND tIF { + | if cond tTHEN nl stmtlist end tELSE stmtlist end tEND tIF { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, $5); WRITE_UINT32(&else1, $8); @@ -188,7 +193,7 @@ ifstmt: if cond tTHEN '\n' stmtlist end tEND tIF { (*g_lingo->_currentScript)[$1 + 2] = else1; /* elsepart */ (*g_lingo->_currentScript)[$1 + 3] = end; /* end, if cond fails */ g_lingo->processIf(0, 0); } - | if cond tTHEN '\n' stmtlist end begin elseifstmt end tEND tIF { + | if cond tTHEN nl stmtlist end begin elseifstmt end tEND tIF { inst then = 0, else1 = 0, end = 0; WRITE_UINT32(&then, $5); WRITE_UINT32(&else1, $7); @@ -282,7 +287,7 @@ begin: /* nothing */ { $$ = g_lingo->_currentScript->size(); } end: /* nothing */ { g_lingo->code1(STOP); $$ = g_lingo->_currentScript->size(); } ; stmtlist: /* nothing */ { $$ = g_lingo->_currentScript->size(); } - | stmtlist '\n' + | stmtlist nl | stmtlist stmt ; @@ -405,7 +410,7 @@ gotomovie: tOF tMOVIE STRING { $$ = $3; } // See also: // on keyword defn: tMACRO ID { g_lingo->_indef = true; } - begin argdef '\n' argstore stmtlist { + begin argdef nl argstore stmtlist { g_lingo->code2(g_lingo->c_constpush, (inst)0); // Push fake value on stack g_lingo->code1(g_lingo->c_procret); g_lingo->define(*$2, $4, $5); @@ -414,7 +419,7 @@ defn: tMACRO ID { g_lingo->_indef = true; } argdef: /* nothing */ { $$ = 0; } | ID { g_lingo->codeArg($1); $$ = 1; } | argdef ',' ID { g_lingo->codeArg($3); $$ = $1 + 1; } - | argdef '\n' ',' ID { g_lingo->codeArg($4); $$ = $1 + 1; } + | argdef nl ',' ID { g_lingo->codeArg($4); $$ = $1 + 1; } ; argstore: /* nothing */ { g_lingo->codeArgStore(); } ; diff --git a/engines/director/lingo/lingo-lex.cpp b/engines/director/lingo/lingo-lex.cpp index d302e38d0d..60ae1231f1 100644 --- a/engines/director/lingo/lingo-lex.cpp +++ b/engines/director/lingo/lingo-lex.cpp @@ -608,8 +608,21 @@ char *yytext; #include "director/lingo/lingo-gr.h" int yyparse(); +static void count() { + Director::g_lingo->_colnumber += strlen(yytext); +} + +static void countnl() { + char *p = yytext; -#line 613 "engines/director/lingo/lingo-lex.cpp" + while(*p == '\n' || *p == '\r') + p++; + + Director::g_lingo->_linenumber++; + Director::g_lingo->_colnumber = strlen(p); +} + +#line 626 "engines/director/lingo/lingo-lex.cpp" #define INITIAL 0 @@ -794,10 +807,10 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 45 "engines/director/lingo/lingo-lex.l" +#line 58 "engines/director/lingo/lingo-lex.l" -#line 801 "engines/director/lingo/lingo-lex.cpp" +#line 814 "engines/director/lingo/lingo-lex.cpp" if ( !(yy_init) ) { @@ -883,170 +896,171 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 47 "engines/director/lingo/lingo-lex.l" +#line 60 "engines/director/lingo/lingo-lex.l" YY_BREAK case 2: YY_RULE_SETUP -#line 48 "engines/director/lingo/lingo-lex.l" - +#line 61 "engines/director/lingo/lingo-lex.l" +{ count(); } YY_BREAK case 3: YY_RULE_SETUP -#line 49 "engines/director/lingo/lingo-lex.l" -{ return ' '; } +#line 62 "engines/director/lingo/lingo-lex.l" +{ count(); return ' '; } YY_BREAK case 4: YY_RULE_SETUP -#line 51 "engines/director/lingo/lingo-lex.l" -{ return tDOWN; } +#line 64 "engines/director/lingo/lingo-lex.l" +{ count(); return tDOWN; } YY_BREAK case 5: YY_RULE_SETUP -#line 52 "engines/director/lingo/lingo-lex.l" -{ return tIF; } +#line 65 "engines/director/lingo/lingo-lex.l" +{ count(); return tIF; } YY_BREAK case 6: /* rule 6 can match eol */ YY_RULE_SETUP -#line 53 "engines/director/lingo/lingo-lex.l" -{ return tNLELSIF; } +#line 66 "engines/director/lingo/lingo-lex.l" +{ countnl(); return tNLELSIF; } YY_BREAK case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 54 "engines/director/lingo/lingo-lex.l" -{ return tNLELSE; } +#line 67 "engines/director/lingo/lingo-lex.l" +{ countnl(); return tNLELSE; } YY_BREAK case 8: YY_RULE_SETUP -#line 55 "engines/director/lingo/lingo-lex.l" -{ return tELSE; } +#line 68 "engines/director/lingo/lingo-lex.l" +{ count(); return tELSE; } YY_BREAK case 9: YY_RULE_SETUP -#line 56 "engines/director/lingo/lingo-lex.l" -{ return tEND; } +#line 69 "engines/director/lingo/lingo-lex.l" +{ count(); return tEND; } YY_BREAK case 10: YY_RULE_SETUP -#line 57 "engines/director/lingo/lingo-lex.l" -{ return tEXIT; } +#line 70 "engines/director/lingo/lingo-lex.l" +{ count(); return tEXIT; } YY_BREAK case 11: YY_RULE_SETUP -#line 58 "engines/director/lingo/lingo-lex.l" -{ return tFRAME; } +#line 71 "engines/director/lingo/lingo-lex.l" +{ count(); return tFRAME; } YY_BREAK case 12: YY_RULE_SETUP -#line 59 "engines/director/lingo/lingo-lex.l" -{ return tGLOBAL; } +#line 72 "engines/director/lingo/lingo-lex.l" +{ count(); return tGLOBAL; } YY_BREAK case 13: YY_RULE_SETUP -#line 60 "engines/director/lingo/lingo-lex.l" -{ return tGO; } +#line 73 "engines/director/lingo/lingo-lex.l" +{ count(); return tGO; } YY_BREAK case 14: YY_RULE_SETUP -#line 61 "engines/director/lingo/lingo-lex.l" -{ return tINTO; } +#line 74 "engines/director/lingo/lingo-lex.l" +{ count(); return tINTO; } YY_BREAK case 15: YY_RULE_SETUP -#line 62 "engines/director/lingo/lingo-lex.l" -{ return tLOOP; } +#line 75 "engines/director/lingo/lingo-lex.l" +{ count(); return tLOOP; } YY_BREAK case 16: YY_RULE_SETUP -#line 63 "engines/director/lingo/lingo-lex.l" -{ return tMACRO; } +#line 76 "engines/director/lingo/lingo-lex.l" +{ count(); return tMACRO; } YY_BREAK case 17: YY_RULE_SETUP -#line 64 "engines/director/lingo/lingo-lex.l" -{ return tMCI; } +#line 77 "engines/director/lingo/lingo-lex.l" +{ count(); return tMCI; } YY_BREAK case 18: YY_RULE_SETUP -#line 65 "engines/director/lingo/lingo-lex.l" -{ return tMCIWAIT; } +#line 78 "engines/director/lingo/lingo-lex.l" +{ count(); return tMCIWAIT; } YY_BREAK case 19: YY_RULE_SETUP -#line 66 "engines/director/lingo/lingo-lex.l" -{ return tMOVIE; } +#line 79 "engines/director/lingo/lingo-lex.l" +{ count(); return tMOVIE; } YY_BREAK case 20: YY_RULE_SETUP -#line 67 "engines/director/lingo/lingo-lex.l" -{ return tNEXT; } +#line 80 "engines/director/lingo/lingo-lex.l" +{ count(); return tNEXT; } YY_BREAK case 21: YY_RULE_SETUP -#line 68 "engines/director/lingo/lingo-lex.l" -{ return tOF; } +#line 81 "engines/director/lingo/lingo-lex.l" +{ count(); return tOF; } YY_BREAK case 22: YY_RULE_SETUP -#line 69 "engines/director/lingo/lingo-lex.l" -{ return tPREVIOUS; } +#line 82 "engines/director/lingo/lingo-lex.l" +{ count(); return tPREVIOUS; } YY_BREAK case 23: YY_RULE_SETUP -#line 70 "engines/director/lingo/lingo-lex.l" -{ return tPUT; } +#line 83 "engines/director/lingo/lingo-lex.l" +{ count(); return tPUT; } YY_BREAK case 24: YY_RULE_SETUP -#line 71 "engines/director/lingo/lingo-lex.l" -{ return tREPEAT; } +#line 84 "engines/director/lingo/lingo-lex.l" +{ count(); return tREPEAT; } YY_BREAK case 25: YY_RULE_SETUP -#line 72 "engines/director/lingo/lingo-lex.l" -{ return tSET; } +#line 85 "engines/director/lingo/lingo-lex.l" +{ count(); return tSET; } YY_BREAK case 26: YY_RULE_SETUP -#line 73 "engines/director/lingo/lingo-lex.l" -{ return tTHEN; } +#line 86 "engines/director/lingo/lingo-lex.l" +{ count(); return tTHEN; } YY_BREAK case 27: YY_RULE_SETUP -#line 74 "engines/director/lingo/lingo-lex.l" -{ return tTO; } +#line 87 "engines/director/lingo/lingo-lex.l" +{ count(); return tTO; } YY_BREAK case 28: YY_RULE_SETUP -#line 75 "engines/director/lingo/lingo-lex.l" -{ return tWITH; } +#line 88 "engines/director/lingo/lingo-lex.l" +{ count(); return tWITH; } YY_BREAK case 29: YY_RULE_SETUP -#line 76 "engines/director/lingo/lingo-lex.l" -{ return tWHILE; } +#line 89 "engines/director/lingo/lingo-lex.l" +{ count(); return tWHILE; } YY_BREAK case 30: YY_RULE_SETUP -#line 78 "engines/director/lingo/lingo-lex.l" -{ return tNEQ; } +#line 91 "engines/director/lingo/lingo-lex.l" +{ count(); return tNEQ; } YY_BREAK case 31: YY_RULE_SETUP -#line 79 "engines/director/lingo/lingo-lex.l" -{ return tGE; } +#line 92 "engines/director/lingo/lingo-lex.l" +{ count(); return tGE; } YY_BREAK case 32: YY_RULE_SETUP -#line 80 "engines/director/lingo/lingo-lex.l" -{ return tLE; } +#line 93 "engines/director/lingo/lingo-lex.l" +{ count(); return tLE; } YY_BREAK case 33: YY_RULE_SETUP -#line 82 "engines/director/lingo/lingo-lex.l" +#line 95 "engines/director/lingo/lingo-lex.l" { + count(); yylval.s = new Common::String(yytext); if (Director::g_lingo->_builtins.contains(yytext)) @@ -1057,41 +1071,41 @@ YY_RULE_SETUP YY_BREAK case 34: YY_RULE_SETUP -#line 90 "engines/director/lingo/lingo-lex.l" -{ yylval.f = atof(yytext); return FLOAT; } +#line 104 "engines/director/lingo/lingo-lex.l" +{ count(); yylval.f = atof(yytext); return FLOAT; } YY_BREAK case 35: YY_RULE_SETUP -#line 91 "engines/director/lingo/lingo-lex.l" -{ yylval.i = strtol(yytext, NULL, 10); return INT; } +#line 105 "engines/director/lingo/lingo-lex.l" +{ count(); yylval.i = strtol(yytext, NULL, 10); return INT; } YY_BREAK case 36: YY_RULE_SETUP -#line 92 "engines/director/lingo/lingo-lex.l" -{ return *yytext; } +#line 106 "engines/director/lingo/lingo-lex.l" +{ count(); return *yytext; } YY_BREAK case 37: /* rule 37 can match eol */ YY_RULE_SETUP -#line 93 "engines/director/lingo/lingo-lex.l" +#line 107 "engines/director/lingo/lingo-lex.l" { return '\n'; } YY_BREAK case 38: YY_RULE_SETUP -#line 94 "engines/director/lingo/lingo-lex.l" -{ yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; } +#line 108 "engines/director/lingo/lingo-lex.l" +{ count(); yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; } YY_BREAK case 39: YY_RULE_SETUP -#line 95 "engines/director/lingo/lingo-lex.l" +#line 109 "engines/director/lingo/lingo-lex.l" YY_BREAK case 40: YY_RULE_SETUP -#line 97 "engines/director/lingo/lingo-lex.l" +#line 111 "engines/director/lingo/lingo-lex.l" ECHO; YY_BREAK -#line 1095 "engines/director/lingo/lingo-lex.cpp" +#line 1109 "engines/director/lingo/lingo-lex.cpp" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2091,7 +2105,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 97 "engines/director/lingo/lingo-lex.l" +#line 111 "engines/director/lingo/lingo-lex.l" diff --git a/engines/director/lingo/lingo-lex.l b/engines/director/lingo/lingo-lex.l index c340bd69bc..43b25f7c96 100644 --- a/engines/director/lingo/lingo-lex.l +++ b/engines/director/lingo/lingo-lex.l @@ -31,6 +31,19 @@ #include "director/lingo/lingo-gr.h" int yyparse(); +static void count() { + Director::g_lingo->_colnumber += strlen(yytext); +} + +static void countnl() { + char *p = yytext; + + while(*p == '\n' || *p == '\r') + p++; + + Director::g_lingo->_linenumber++; + Director::g_lingo->_colnumber = strlen(p); +} %} @@ -45,41 +58,42 @@ whitespace [\t ] %% --[^\r\n]* -^{whitespace}+ -[\t]+ { return ' '; } - -(?i:down) { return tDOWN; } -(?i:if) { return tIF; } -(?i:[\n\r]+[\t ]+else[\t ]+if) { return tNLELSIF; } -(?i:[\n\r]+[\t ]+else) { return tNLELSE; } -(?i:else) { return tELSE; } -(?i:end) { return tEND; } -(?i:exit) { return tEXIT; } -(?i:frame) { return tFRAME; } -(?i:global) { return tGLOBAL; } -(?i:go) { return tGO; } -(?i:into) { return tINTO; } -(?i:loop) { return tLOOP; } -(?i:macro) { return tMACRO; } -(?i:mci) { return tMCI; } -(?i:mciwait) { return tMCIWAIT; } -(?i:movie) { return tMOVIE; } -(?i:next) { return tNEXT; } -(?i:of) { return tOF; } -(?i:previous) { return tPREVIOUS; } -(?i:put) { return tPUT; } -(?i:repeat) { return tREPEAT; } -(?i:set) { return tSET; } -(?i:then) { return tTHEN; } -(?i:to) { return tTO; } -(?i:with) { return tWITH; } -(?i:while) { return tWHILE; } - -[!][=] { return tNEQ; } -[>][=] { return tGE; } -[<][=] { return tLE; } +^{whitespace}+ { count(); } +[\t]+ { count(); return ' '; } + +(?i:down) { count(); return tDOWN; } +(?i:if) { count(); return tIF; } +(?i:[\n\r]+[\t ]+else[\t ]+if) { countnl(); return tNLELSIF; } +(?i:[\n\r]+[\t ]+else) { countnl(); return tNLELSE; } +(?i:else) { count(); return tELSE; } +(?i:end) { count(); return tEND; } +(?i:exit) { count(); return tEXIT; } +(?i:frame) { count(); return tFRAME; } +(?i:global) { count(); return tGLOBAL; } +(?i:go) { count(); return tGO; } +(?i:into) { count(); return tINTO; } +(?i:loop) { count(); return tLOOP; } +(?i:macro) { count(); return tMACRO; } +(?i:mci) { count(); return tMCI; } +(?i:mciwait) { count(); return tMCIWAIT; } +(?i:movie) { count(); return tMOVIE; } +(?i:next) { count(); return tNEXT; } +(?i:of) { count(); return tOF; } +(?i:previous) { count(); return tPREVIOUS; } +(?i:put) { count(); return tPUT; } +(?i:repeat) { count(); return tREPEAT; } +(?i:set) { count(); return tSET; } +(?i:then) { count(); return tTHEN; } +(?i:to) { count(); return tTO; } +(?i:with) { count(); return tWITH; } +(?i:while) { count(); return tWHILE; } + +[!][=] { count(); return tNEQ; } +[>][=] { count(); return tGE; } +[<][=] { count(); return tLE; } {identifier} { + count(); yylval.s = new Common::String(yytext); if (Director::g_lingo->_builtins.contains(yytext)) @@ -87,11 +101,11 @@ whitespace [\t ] return ID; } -{constfloat} { yylval.f = atof(yytext); return FLOAT; } -{constinteger} { yylval.i = strtol(yytext, NULL, 10); return INT; } -{operator} { return *yytext; } +{constfloat} { count(); yylval.f = atof(yytext); return FLOAT; } +{constinteger} { count(); yylval.i = strtol(yytext, NULL, 10); return INT; } +{operator} { count(); return *yytext; } {newline} { return '\n'; } -{conststring} { yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; } +{conststring} { count(); yylval.s = new Common::String(&yytext[1]); yylval.s->deleteLastChar(); return STRING; } . %% diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index b1befd9f02..1ab0e89dd6 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -89,6 +89,8 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) { _returning = false; _indef = false; + _linenumber = _colnumber = 0; + warning("Lingo Inited"); } @@ -108,6 +110,8 @@ void Lingo::addCode(Common::String code, ScriptType type, uint16 id) { _currentScriptType = type; _scripts[type][id] = _currentScript; + _linenumber = _colnumber = 1; + // macros have conflicting grammar. Thus we ease life for the parser. if (code.contains("\nmacro ")) { const char *begin = strstr(code.c_str(), "\nmacro ") + 1; diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index de3847c188..d88f7053a7 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -242,6 +242,9 @@ public: BuiltinHash _builtins; Common::Array<int> _labelstack; + int _linenumber; + int _colnumber; + private: int parse(const char *code); void push(Datum d); |