X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/486240dc4c5d57b0afaddba60d87fe375112bed5..refs/tags/v1.0.11:/src/lexer.c diff --git a/src/lexer.c b/src/lexer.c index f1ce73c..883456c 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -9,6 +9,7 @@ #define YY_FLEX_MINOR_VERSION 5 #include +#include /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ @@ -22,7 +23,6 @@ #ifdef __cplusplus #include -#include /* Use prototypes in function declarations. */ #define YY_USE_PROTOS @@ -1536,9 +1536,8 @@ YY_RULE_SETUP BEGIN(CLASS_CODE); if(++found_classes > 1) { - print_error(FALSE, - "Only one class per file allowed", - line_no); + error_print(GOB_ERROR, line_no, + "Only one class per file allowed"); } return CLASS; @@ -1549,164 +1548,178 @@ case 52: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 345 "lexer.l" +#line 344 "lexer.l" { int maj = 0,min = 0,pl = 0; int rmaj = 0,rmin = 0,rpl = 0; + int effective_maj = 0; + int effective_rmaj = 0; char *p; sscanf(VERSION,"%d.%d.%d",&rmaj,&rmin,&rpl); + effective_rmaj = rmaj; + if (rmin >= 90) + effective_rmaj = rmaj + 1; + p = strchr(yytext,'r'); g_assert(p); /* we MUST have found it */ sscanf(p,"requires %d.%d.%d",&maj,&min,&pl); + effective_maj = maj; + if (min >= 90) + effective_maj = maj + 1; + if(rmaj < maj || (rmaj == maj && rmin < min) || (rmaj == maj && rmin == min && rpl < pl)) { - char *s; - s = g_strdup_printf( - "GOB version %d.%d.%d required " - "(this is %s)\n" - "To upgrade your gob, see: " - "http://www.5z.com/jirka/gob.html", - maj,min,pl,VERSION); - print_error(FALSE, s, line_no); - g_free(s); + error_printf(GOB_ERROR, line_no, + "GOB version at least %d.%d.%d required " + "(this is %s)\n" + "To upgrade your gob, see: " + "http://www.5z.com/jirka/gob.html", + maj, min, pl, VERSION); + } + + if(effective_rmaj != effective_maj) { + error_printf(GOB_ERROR, line_no, + "GOB major version %d required " + "(this is %s)\n" + "To upgrade your gob, see: " + "http://www.5z.com/jirka/gob.html", + maj, VERSION); } } YY_BREAK case 53: YY_RULE_SETUP -#line 369 "lexer.l" +#line 384 "lexer.l" { if(for_cpp) { - char *s; - s = g_strdup_printf("'%s' keyword should not " - "be used when generating " - "C++ code", yytext); - print_error(TRUE, s, line_no); - g_free(s); + error_printf(GOB_WARN, line_no, + "'%s' keyword should not " + "be used when generating " + "C++ code", yytext); } REJECT; } YY_BREAK case 54: YY_RULE_SETUP -#line 381 "lexer.l" +#line 394 "lexer.l" {return FROM;} YY_BREAK case 55: YY_RULE_SETUP -#line 383 "lexer.l" +#line 396 "lexer.l" {return VOID;} YY_BREAK case 56: YY_RULE_SETUP -#line 384 "lexer.l" +#line 397 "lexer.l" {return STRUCT;} YY_BREAK case 57: YY_RULE_SETUP -#line 385 "lexer.l" +#line 398 "lexer.l" {return UNION;} YY_BREAK case 58: YY_RULE_SETUP -#line 386 "lexer.l" +#line 399 "lexer.l" {return ENUM;} YY_BREAK case 59: YY_RULE_SETUP -#line 387 "lexer.l" +#line 400 "lexer.l" {return SIGNED;} YY_BREAK case 60: YY_RULE_SETUP -#line 388 "lexer.l" +#line 401 "lexer.l" {return UNSIGNED;} YY_BREAK case 61: YY_RULE_SETUP -#line 389 "lexer.l" +#line 402 "lexer.l" {return LONG;} YY_BREAK case 62: YY_RULE_SETUP -#line 390 "lexer.l" +#line 403 "lexer.l" {return SHORT;} YY_BREAK case 63: YY_RULE_SETUP -#line 391 "lexer.l" +#line 404 "lexer.l" {return INT;} YY_BREAK case 64: YY_RULE_SETUP -#line 392 "lexer.l" +#line 405 "lexer.l" {return FLOAT;} YY_BREAK case 65: YY_RULE_SETUP -#line 393 "lexer.l" +#line 406 "lexer.l" {return DOUBLE;} YY_BREAK case 66: YY_RULE_SETUP -#line 394 "lexer.l" +#line 407 "lexer.l" {return CHAR;} YY_BREAK case 67: YY_RULE_SETUP -#line 395 "lexer.l" +#line 408 "lexer.l" {return CONST;} YY_BREAK case 68: YY_RULE_SETUP -#line 397 "lexer.l" +#line 410 "lexer.l" {return THREEDOTS;} YY_BREAK case 69: YY_RULE_SETUP -#line 399 "lexer.l" +#line 412 "lexer.l" {yylval.line = line_no; return PUBLIC;} YY_BREAK case 70: YY_RULE_SETUP -#line 400 "lexer.l" +#line 413 "lexer.l" {yylval.line = line_no; return PRIVATE;} YY_BREAK case 71: YY_RULE_SETUP -#line 401 "lexer.l" +#line 414 "lexer.l" {yylval.line = line_no; return PROTECTED;} YY_BREAK case 72: YY_RULE_SETUP -#line 402 "lexer.l" +#line 415 "lexer.l" {yylval.line = line_no; return CLASSWIDE;} YY_BREAK case 73: YY_RULE_SETUP -#line 403 "lexer.l" +#line 416 "lexer.l" {yylval.line = line_no; return ARGUMENT;} YY_BREAK case 74: YY_RULE_SETUP -#line 404 "lexer.l" +#line 417 "lexer.l" {yylval.line = line_no; return VIRTUAL;} YY_BREAK case 75: YY_RULE_SETUP -#line 405 "lexer.l" +#line 418 "lexer.l" {yylval.line = line_no; return SIGNAL;} YY_BREAK case 76: YY_RULE_SETUP -#line 406 "lexer.l" +#line 419 "lexer.l" {yylval.line = line_no; return OVERRIDE;} YY_BREAK case 77: YY_RULE_SETUP -#line 407 "lexer.l" +#line 420 "lexer.l" { yylval.id = g_strdup(yytext); return NUMBER; @@ -1714,7 +1727,7 @@ YY_RULE_SETUP YY_BREAK case 78: YY_RULE_SETUP -#line 411 "lexer.l" +#line 424 "lexer.l" { /* this one is for a classname with a namespace */ yylval.id = g_strdup(yytext); @@ -1723,7 +1736,7 @@ YY_RULE_SETUP YY_BREAK case 79: YY_RULE_SETUP -#line 416 "lexer.l" +#line 429 "lexer.l" { /* this is for a classname with an empty namespace */ yylval.id = g_strdup(yytext); @@ -1732,7 +1745,7 @@ YY_RULE_SETUP YY_BREAK case 80: YY_RULE_SETUP -#line 421 "lexer.l" +#line 434 "lexer.l" { yylval.id = g_strdup(yytext); return TOKEN; @@ -1740,7 +1753,7 @@ YY_RULE_SETUP YY_BREAK case 81: YY_RULE_SETUP -#line 426 "lexer.l" +#line 439 "lexer.l" { yylval.id = g_strdup(yytext); return ARRAY_DIM; @@ -1748,7 +1761,7 @@ YY_RULE_SETUP YY_BREAK case 82: YY_RULE_SETUP -#line 431 "lexer.l" +#line 444 "lexer.l" { BEGIN(CLASS_CODE_I); return '{'; @@ -1756,7 +1769,7 @@ YY_RULE_SETUP YY_BREAK case 83: YY_RULE_SETUP -#line 435 "lexer.l" +#line 448 "lexer.l" { BEGIN(C_CODE); parenth_depth=1; @@ -1769,7 +1782,7 @@ YY_RULE_SETUP YY_BREAK case 84: YY_RULE_SETUP -#line 444 "lexer.l" +#line 457 "lexer.l" { BEGIN(INITIAL); return '}'; @@ -1777,12 +1790,12 @@ YY_RULE_SETUP YY_BREAK case 85: YY_RULE_SETUP -#line 449 "lexer.l" +#line 462 "lexer.l" ; /*ignore*/ YY_BREAK case 86: YY_RULE_SETUP -#line 451 "lexer.l" +#line 464 "lexer.l" { yylval.line = line_no; return yytext[0]; @@ -1790,15 +1803,15 @@ YY_RULE_SETUP YY_BREAK case 87: YY_RULE_SETUP -#line 456 "lexer.l" +#line 469 "lexer.l" ; /*ignore*/ YY_BREAK case 88: YY_RULE_SETUP -#line 458 "lexer.l" +#line 471 "lexer.l" ECHO; YY_BREAK -#line 1802 "lex.yy.c" +#line 1815 "lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(C_CODE): @@ -2366,11 +2379,6 @@ YY_BUFFER_STATE b; } -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO(( int )); -#endif -#endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) @@ -2688,7 +2696,7 @@ int main() return 0; } #endif -#line 458 "lexer.l" +#line 471 "lexer.l" /* Ugly warning avoiding */