wrc: Change the prefix on bison-generated names to avoid the name-prefix directive.

This commit is contained in:
Alexandre Julliard 2006-09-12 09:05:20 +02:00
parent 4f0fa2608a
commit 42418fbbe8
7 changed files with 124 additions and 125 deletions

View File

@ -327,7 +327,7 @@ static int convert_bitmap(char *data, int size)
type |= FL_SIZEBE | FL_OS2;
}
else
yyerror("Invalid bitmap format, bih->biSize = %ld", bih->biSize);
parser_error("Invalid bitmap format, bih->biSize = %ld", bih->biSize);
switch(type)
{
@ -336,12 +336,12 @@ static int convert_bitmap(char *data, int size)
case FL_SIZEBE:
case FL_SIZEBE | FL_V4:
case FL_SIZEBE | FL_OS2:
yywarning("Bitmap v%c signature little-endian, but size big-endian", type & FL_V4 ? '4' : '3');
parser_warning("Bitmap v%c signature little-endian, but size big-endian", type & FL_V4 ? '4' : '3');
break;
case FL_SIGBE:
case FL_SIGBE | FL_V4:
case FL_SIGBE | FL_OS2:
yywarning("Bitmap v%c signature big-endian, but size little-endian", type & FL_V4 ? '4' : '3');
parser_warning("Bitmap v%c signature big-endian, but size little-endian", type & FL_V4 ? '4' : '3');
break;
}
@ -461,7 +461,7 @@ static void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico)
else if(BYTESWAP_WORD(ih->type) == 1)
swap = 1;
else
yyerror("Icon resource data has invalid type id %d", ih->type);
parser_error("Icon resource data has invalid type id %d", ih->type);
cnt = swap ? BYTESWAP_WORD(ih->count) : ih->count;
for(i = 0; i < cnt; i++)
@ -481,7 +481,7 @@ static void split_icons(raw_data_t *rd, icon_group_t *icog, int *nico)
}
if(ide.offset > rd->size
|| ide.offset + ide.ressize > rd->size)
yyerror("Icon resource data corrupt");
parser_error("Icon resource data corrupt");
ico->width = ide.width;
ico->height = ide.height;
ico->nclr = ide.nclr;
@ -556,7 +556,7 @@ static void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur)
else if(BYTESWAP_WORD(ch->type) == 2)
swap = 1;
else
yyerror("Cursor resource data has invalid type id %d", ch->type);
parser_error("Cursor resource data has invalid type id %d", ch->type);
cnt = swap ? BYTESWAP_WORD(ch->count) : ch->count;
for(i = 0; i < cnt; i++)
{
@ -575,7 +575,7 @@ static void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur)
}
if(cde.offset > rd->size
|| cde.offset + cde.ressize > rd->size)
yyerror("Cursor resource data corrupt");
parser_error("Cursor resource data corrupt");
cur->width = cde.width;
cur->height = cde.height;
cur->nclr = cde.nclr;
@ -598,7 +598,7 @@ static void split_cursors(raw_data_t *rd, cursor_group_t *curg, int *ncur)
cur->bits = info.biBitCount;
}
if(!win32 && (cur->planes != 1 || cur->bits != 1))
yywarning("Win16 cursor contains colors");
parser_warning("Win16 cursor contains colors");
cur->xhot = swap ? BYTESWAP_WORD(cde.xhot) : cde.xhot;
cur->yhot = swap ? BYTESWAP_WORD(cde.yhot) : cde.yhot;
cur->data = new_raw_data();
@ -745,21 +745,21 @@ static void handle_ani_icon(riff_tag_t *rtp, enum res_e type, int isswapped)
if(type == res_anicur && ctype != 2 && !once)
{
yywarning("Animated cursor contains invalid \"icon\" tag cursor-file (%d->%s)",
parser_warning("Animated cursor contains invalid \"icon\" tag cursor-file (%d->%s)",
ctype,
ctype == 1 ? "icontype" : "?");
once++;
}
else if(type == res_aniico && ctype != 1 && !once)
{
yywarning("Animated icon contains invalid \"icon\" tag icon-file (%d->%s)",
parser_warning("Animated icon contains invalid \"icon\" tag icon-file (%d->%s)",
ctype,
ctype == 2 ? "cursortype" : "?");
once++;
}
else if(ctype != 1 && ctype != 2 && !once)
{
yywarning("Animated %s contains invalid \"icon\" tag file-type (%d; neither icon nor cursor)", anistr, ctype);
parser_warning("Animated %s contains invalid \"icon\" tag file-type (%d; neither icon nor cursor)", anistr, ctype);
once++;
}
@ -768,7 +768,7 @@ static void handle_ani_icon(riff_tag_t *rtp, enum res_e type, int isswapped)
DWORD ofs = isswapped ? BYTESWAP_DWORD(cdp[i].offset) : cdp[i].offset;
DWORD sze = isswapped ? BYTESWAP_DWORD(cdp[i].ressize) : cdp[i].ressize;
if(ofs > rtp->size || ofs+sze > rtp->size)
yyerror("Animated %s's data corrupt", anistr);
parser_error("Animated %s's data corrupt", anistr);
convert_bitmap((char *)chp + ofs, 0);
cdp[i].xhot = BYTESWAP_WORD(cdp->xhot);
cdp[i].yhot = BYTESWAP_WORD(cdp->yhot);
@ -840,7 +840,7 @@ ani_curico_t *new_ani_curico(enum res_e type, raw_data_t *rd, int *memopt)
else if(rtp->size + 2*sizeof(DWORD) == rd->size)
isswapped = 0;
else
yyerror("Animated %s has an invalid RIFF length", anistr);
parser_error("Animated %s has an invalid RIFF length", anistr);
switch(byteorder)
{
@ -933,7 +933,7 @@ ani_curico_t *new_ani_curico(enum res_e type, raw_data_t *rd, int *memopt)
/* We must end correctly here */
if((char *)rtp != (char *)rd->data + rd->size)
yyerror("Animated %s contains invalid field size(s)", anistr);
parser_error("Animated %s contains invalid field size(s)", anistr);
}
ani->data = rd;
@ -1002,7 +1002,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
msg->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE;
if(rd->size < sizeof(DWORD))
yyerror("Invalid messagetable, size too small");
parser_error("Invalid messagetable, size too small");
nblk = *(DWORD *)rd->data;
lo = WRC_LOWORD(nblk);
@ -1019,7 +1019,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
if(hi && lo)
internal_error(__FILE__, __LINE__, "Messagetable contains more than 65535 blocks; cannot determine endian");
if(!hi && !lo)
yyerror("Invalid messagetable block count 0");
parser_error("Invalid messagetable block count 0");
if(!hi && lo) /* Messagetable byteorder == native byteorder */
{
@ -1032,7 +1032,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
mbp = (msgtab_block_t *)&(((DWORD *)rd->data)[1]);
if(MSGTAB_BAD_PTR(mbp, rd->data, rd->size, nblk * sizeof(*mbp)))
yyerror("Messagetable's blocks are outside of defined data");
parser_error("Messagetable's blocks are outside of defined data");
for(i = 0; i < nblk; i++)
{
msgtab_entry_t *mep, *next_mep;
@ -1043,7 +1043,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
for(id = mbp[i].idlo; id <= mbp[i].idhi; id++)
{
if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length))
yyerror("Messagetable's data for block %d, ID 0x%08lx is outside of defined data", (int)i, id);
parser_error("Messagetable's data for block %d, ID 0x%08lx is outside of defined data", (int)i, id);
if(mep->flags == 1) /* Docu says 'flags == 0x0001' for unicode */
{
WORD *wp = (WORD *)&mep[1];
@ -1051,7 +1051,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
int n;
if(mep->length & 1)
yyerror("Message 0x%08lx is unicode (block %d), but has odd length (%d)", id, (int)i, mep->length);
parser_error("Message 0x%08lx is unicode (block %d), but has odd length (%d)", id, (int)i, mep->length);
for(n = 0; n < l; n++)
wp[n] = BYTESWAP_WORD(wp[n]);
@ -1079,7 +1079,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
mbp = (msgtab_block_t *)&(((DWORD *)rd->data)[1]);
nblk = BYTESWAP_DWORD(nblk);
if(MSGTAB_BAD_PTR(mbp, rd->data, rd->size, nblk * sizeof(*mbp)))
yyerror("Messagetable's blocks are outside of defined data");
parser_error("Messagetable's blocks are outside of defined data");
for(i = 0; i < nblk; i++)
{
msgtab_entry_t *mep;
@ -1096,7 +1096,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
mep->flags = BYTESWAP_WORD(mep->flags);
if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length))
yyerror("Messagetable's data for block %d, ID 0x%08lx is outside of defined data", (int)i, id);
parser_error("Messagetable's data for block %d, ID 0x%08lx is outside of defined data", (int)i, id);
if(mep->flags == 1) /* Docu says 'flags == 0x0001' for unicode */
{
WORD *wp = (WORD *)&mep[1];
@ -1104,7 +1104,7 @@ messagetable_t *new_messagetable(raw_data_t *rd, int *memopt)
int n;
if(mep->length & 1)
yyerror("Message 0x%08lx is unicode (block %d), but has odd length (%d)", id, (int)i, mep->length);
parser_error("Message 0x%08lx is unicode (block %d), but has odd length (%d)", id, (int)i, mep->length);
for(n = 0; n < l; n++)
wp[n] = BYTESWAP_WORD(wp[n]);

View File

@ -22,18 +22,18 @@
#define __WRC_PARSER_H
/* From parser.y */
extern int yydebug;
extern int parser_debug;
extern int want_nl; /* Set when getting line-numers */
extern int want_id; /* Set when getting the resource name */
int yyparse(void);
int parser_parse(void);
/* From parser.l */
extern FILE *yyin;
extern char *yytext;
extern FILE *parser_in;
extern char *parser_text;
extern int yy_flex_debug;
int yylex(void);
int parser_lex(void);
#endif

View File

@ -89,6 +89,7 @@
%option stack
%option nounput noyy_top_state
%option 8bit never-interactive
%option prefix="parser_"
/* Some shortcut definitions */
ws [ \f\t\r]
@ -329,21 +330,21 @@ static struct keyword *iskeyword(char *kw)
yy_pop_state();
lineno = (int)strtol(yytext, &cptr, 10);
if(!lineno)
yyerror("Malformed '#...' line-directive; invalid linenumber");
parser_error("Malformed '#...' line-directive; invalid linenumber");
fname = strchr(cptr, '"');
if(!fname)
yyerror("Malformed '#...' line-directive; missing filename");
parser_error("Malformed '#...' line-directive; missing filename");
fname++;
cptr = strchr(fname, '"');
if(!cptr)
yyerror("Malformed '#...' line-directive; missing terminating \"");
parser_error("Malformed '#...' line-directive; missing terminating \"");
*cptr = '\0';
line_number = lineno - 1; /* We didn't read the newline */
input_name = xstrdup(fname);
}
<pp_pragma>code_page[^\n]* yyless(9); yy_pop_state(); yy_push_state(pp_code_page);
<pp_pragma>[^\n]* yy_pop_state(); if (pedantic) yywarning("Unrecognized #pragma directive '%s'",yytext);
<pp_pragma>[^\n]* yy_pop_state(); if (pedantic) parser_warning("Unrecognized #pragma directive '%s'",yytext);
<pp_code_page>\({ws}*default{ws}*\)[^\n]* current_codepage = -1; yy_pop_state();
<pp_code_page>\({ws}*[0-9]+{ws}*\)[^\n]* {
@ -353,11 +354,11 @@ static struct keyword *iskeyword(char *kw)
current_codepage = strtol( p, NULL, 10 );
if (current_codepage && !wine_cp_get_table( current_codepage ))
{
yyerror("Codepage %d not supported", current_codepage);
parser_error("Codepage %d not supported", current_codepage);
current_codepage = 0;
}
}
<pp_code_page>[^\n]* yy_pop_state(); yyerror("Malformed #pragma code_page directive");
<pp_code_page>[^\n]* yy_pop_state(); parser_error("Malformed #pragma code_page directive");
/*
* Strip everything until a ';' taking
@ -392,9 +393,9 @@ static struct keyword *iskeyword(char *kw)
\{ return tBEGIN;
\} return tEND;
[0-9]+[lL]? { yylval.num = strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[xX][0-9A-Fa-f]+[lL]? { yylval.num = strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[oO][0-7]+[lL]? { yylval.num = strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
[0-9]+[lL]? { parser_lval.num = strtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[xX][0-9A-Fa-f]+[lL]? { parser_lval.num = strtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[oO][0-7]+[lL]? { parser_lval.num = strtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
/*
* The next two rules scan identifiers and filenames.
@ -410,7 +411,7 @@ static struct keyword *iskeyword(char *kw)
{
if(wanted_id && !tok->alwayskw)
{
yylval.str = make_string(yytext);
parser_lval.str = make_string(yytext);
return tIDENT;
}
else
@ -418,11 +419,11 @@ static struct keyword *iskeyword(char *kw)
}
else
{
yylval.str = make_string(yytext);
parser_lval.str = make_string(yytext);
return tIDENT;
}
}
[A-Za-z_0-9./\\]+ yylval.str = make_string(yytext); return tFILENAME;
[A-Za-z_0-9./\\]+ parser_lval.str = make_string(yytext); return tFILENAME;
/*
* Wide string scanning
@ -431,19 +432,19 @@ L\" {
yy_push_state(tklstr);
wbufidx = 0;
if(!win32)
yywarning("16bit resource contains unicode strings\n");
parser_warning("16bit resource contains unicode strings\n");
}
<tklstr>\"{ws}+ |
<tklstr>\" {
yy_pop_state();
yylval.str = get_buffered_wstring();
parser_lval.str = get_buffered_wstring();
return tSTRING;
}
<tklstr>\\[0-7]{1,6} { /* octal escape sequence */
unsigned int result;
result = strtoul(yytext+1, 0, 8);
if ( result > 0xffff )
yyerror("Character constant out of range");
parser_error("Character constant out of range");
addwchar((WCHAR)result);
}
<tklstr>\\x[0-9a-fA-F]{4} { /* hex escape sequence */
@ -451,9 +452,9 @@ L\" {
result = strtoul(yytext+2, 0, 16);
addwchar((WCHAR)result);
}
<tklstr>\\x[0-9a-fA-F]{1,3} { yyerror("Invalid hex escape sequence '%s'", yytext); }
<tklstr>\\x[0-9a-fA-F]{1,3} { parser_error("Invalid hex escape sequence '%s'", yytext); }
<tklstr>\\[0-9]+ yyerror("Bad escape sequence");
<tklstr>\\[0-9]+ parser_error("Bad escape sequence");
<tklstr>\\\n{ws}* line_number++; char_number = 1; /* backslash at EOL continues string after leading whitespace on next line */
<tklstr>\\a addwchar('\a');
<tklstr>\\b addwchar('\b');
@ -472,7 +473,7 @@ L\" {
while(*yptr) /* FIXME: codepage translation */
addwchar(*yptr++ & 0xff);
}
<tklstr>\n yyerror("Unterminated string");
<tklstr>\n parser_error("Unterminated string");
/*
* Normal string scanning
@ -481,14 +482,14 @@ L\" {
<tkstr>\"{ws}+ |
<tkstr>\" {
yy_pop_state();
yylval.str = get_buffered_cstring();
parser_lval.str = get_buffered_cstring();
return tSTRING;
}
<tkstr>\\[0-7]{1,3} { /* octal escape sequence */
int result;
result = strtol(yytext+1, 0, 8);
if ( result > 0xff )
yyerror("Character constant out of range");
parser_error("Character constant out of range");
addcchar((char)result);
}
<tkstr>\\x[0-9a-fA-F]{2} { /* hex escape sequence */
@ -496,9 +497,9 @@ L\" {
result = strtol(yytext+2, 0, 16);
addcchar((char)result);
}
<tkstr>\\x[0-9a-fA-F] { yyerror("Invalid hex escape sequence '%s'", yytext); }
<tkstr>\\x[0-9a-fA-F] { parser_error("Invalid hex escape sequence '%s'", yytext); }
<tkstr>\\[0-9]+ yyerror("Bad escape sequence");
<tkstr>\\[0-9]+ parser_error("Bad escape sequence");
<tkstr>\\\n{ws}* line_number++; char_number = 1; /* backslash at EOL continues string after leading whitespace on next line */
<tkstr>\\a addcchar('\a');
<tkstr>\\b addcchar('\b');
@ -517,7 +518,7 @@ L\" {
<tkstr>\"\" addcchar('\"'); /* "bla""bla" -> "bla\"bla" */
<tkstr>\\\"\" addcchar('\"'); /* "bla\""bla" -> "bla\"bla" */
<tkstr>\"{ws}+\" ; /* "bla" "bla" -> "blabla" */
<tkstr>\n yyerror("Unterminated string");
<tkstr>\n parser_error("Unterminated string");
/*
* Raw data scanning
@ -525,10 +526,10 @@ L\" {
\' yy_push_state(tkrcd); cbufidx = 0;
<tkrcd>\' {
yy_pop_state();
yylval.raw = new_raw_data();
yylval.raw->size = cbufidx;
yylval.raw->data = xmalloc(yylval.raw->size);
memcpy(yylval.raw->data, cbuffer, yylval.raw->size);
parser_lval.raw = new_raw_data();
parser_lval.raw->size = cbufidx;
parser_lval.raw->data = xmalloc(parser_lval.raw->size);
memcpy(parser_lval.raw->data, cbuffer, parser_lval.raw->size);
return tRAWDATA;
}
<tkrcd>[0-9a-fA-F]{2} {
@ -538,7 +539,7 @@ L\" {
}
<tkrcd>{ws}+ ; /* Ignore space */
<tkrcd>\n line_number++; char_number = 1;
<tkrcd>. yyerror("Malformed data-line");
<tkrcd>. parser_error("Malformed data-line");
/*
* Comment stripping
@ -548,7 +549,7 @@ L\" {
yy_push_state(comment);
save_wanted_id = wanted_id;
if(!no_preprocess)
yywarning("Found comments after preprocessing, please report");
parser_warning("Found comments after preprocessing, please report");
}
<comment>[^*\n]* ;
<comment>"*"+[^*/\n]* ;
@ -556,7 +557,7 @@ L\" {
<comment>"*"+"/" yy_pop_state(); want_id = save_wanted_id;
;[^\n]* want_id = wanted_id; /* not really comment, but left-over c-junk */
"//"[^\n]* want_id = wanted_id; if(!no_preprocess) yywarning("Found comments after preprocessing, please report");
"//"[^\n]* want_id = wanted_id; if(!no_preprocess) parser_warning("Found comments after preprocessing, please report");
\n {
want_id = wanted_id;
@ -574,7 +575,7 @@ L\" {
<<EOF>> {
if(YY_START == pp_strips || YY_START == pp_stripe || YY_START == pp_stripp || YY_START == pp_stripp_final)
yyerror("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline);
parser_error("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline);
else
yyterminate();
}
@ -586,14 +587,14 @@ L\" {
line_number++;
char_number = 1;
}
yywarning("Unmatched text '%c' (0x%02x) YY_START=%d stripslevel=%d",
parser_warning("Unmatched text '%c' (0x%02x) YY_START=%d stripslevel=%d",
isprint(*yytext & 0xff) ? *yytext : '.', *yytext, YY_START,stripslevel);
}
%%
#ifndef yywrap
int yywrap(void)
#ifndef parser_wrap
int parser_wrap(void)
{
#if 0
if(bufferstackidx > 0)
@ -615,7 +616,7 @@ static void addcchar(char c)
cbufalloc += 1024;
cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
if(cbufalloc > 65536)
yywarning("Reallocating string buffer larger than 64kB");
parser_warning("Reallocating string buffer larger than 64kB");
}
cbuffer[cbufidx++] = c;
}
@ -627,7 +628,7 @@ static void addwchar(WCHAR s)
wbufalloc += 1024;
wbuffer = xrealloc(wbuffer, wbufalloc * sizeof(wbuffer[0]));
if(wbufalloc > 65536)
yywarning("Reallocating wide string buffer larger than 64kB");
parser_warning("Reallocating wide string buffer larger than 64kB");
}
wbuffer[wbufidx++] = s;
}
@ -644,14 +645,14 @@ static string_t *get_buffered_cstring(void)
if (!current_codepage || current_codepage == -1 || !win32) /* store as ANSI string */
{
if (!current_codepage) yyerror("Codepage set to Unicode only, cannot use ASCII string here");
if (!current_codepage) parser_error("Codepage set to Unicode only, cannot use ASCII string here");
return str;
}
else /* convert to Unicode before storing */
{
string_t *str_w = convert_string( str, str_unicode, current_codepage );
if (!check_unicode_conversion( str, str_w, current_codepage ))
yyerror("String %s does not convert identically to Unicode and back in codepage %d. "
parser_error("String %s does not convert identically to Unicode and back in codepage %d. "
"Try using a Unicode string instead.", str->str.cstr, current_codepage );
free_string( str );
return str_w;

View File

@ -282,8 +282,6 @@ static int rsrcid_to_token(int lookahead);
ani_any_t *ani;
}
%name-prefix="yy"
%token tNL
%token <num> tNUMBER tLNUMBER
%token <str> tSTRING tIDENT tFILENAME
@ -421,7 +419,7 @@ resources
&& rsc->lan->sub == head->lan->sub
&& !compare_name_id(rsc->name, head->name))
{
yyerror("Duplicate resource name '%s'", get_nameid_str(rsc->name));
parser_error("Duplicate resource name '%s'", get_nameid_str(rsc->name));
}
rsc = rsc->prev;
}
@ -478,7 +476,7 @@ resource
if($$)
{
if($1 > 65535 || $1 < -32768)
yyerror("Resource's ID out of range (%d)", $1);
parser_error("Resource's ID out of range (%d)", $1);
$$->name = new_name_id();
$$->name->type = name_ord;
$$->name->name.i_name = $1;
@ -527,16 +525,16 @@ resource
yychar = YYEMPTY; /* Could use 'yyclearin', but we already need the*/
/* direct access to yychar in rule 'usrcvt' below. */
else if(yychar == tIDENT)
yywarning("LANGUAGE statement not delimited with newline; next identifier might be wrong");
parser_warning("LANGUAGE statement not delimited with newline; next identifier might be wrong");
want_nl = 0; /* We don't want it anymore if we didn't get it */
if(!win32)
yywarning("LANGUAGE not supported in 16-bit mode");
parser_warning("LANGUAGE not supported in 16-bit mode");
if(currentlanguage)
free(currentlanguage);
if (get_language_codepage($3, $5) == -1)
yyerror( "Language %04x is not supported", ($5<<10) + $3);
parser_error( "Language %04x is not supported", ($5<<10) + $3);
currentlanguage = new_language($3, $5);
$$ = NULL;
chat("Got LANGUAGE %d,%d (0x%04x)", $3, $5, ($5<<10) + $3);
@ -555,7 +553,7 @@ usrcvt : /* Empty */ { yychar = rsrcid_to_token(yychar); }
*/
nameid : expr {
if($1 > 65535 || $1 < -32768)
yyerror("Resource's ID out of range (%d)", $1);
parser_error("Resource's ID out of range (%d)", $1);
$$ = new_name_id();
$$->type = name_ord;
$$->name.i_name = $1;
@ -724,7 +722,7 @@ fontdir : tFONTDIR loadmemopts file_raw { $$ = new_fontdir($3, $2); }
messagetable
: tMESSAGETABLE loadmemopts file_raw {
if(!win32)
yywarning("MESSAGETABLE not supported in 16-bit mode");
parser_warning("MESSAGETABLE not supported in 16-bit mode");
$$ = new_messagetable($3, $2);
}
;
@ -748,7 +746,7 @@ userres : usertype loadmemopts file_raw {
#else
if(pedantic && byteorder == WRC_BO_BIG)
#endif
yywarning("Byteordering is not little-endian and type cannot be interpreted");
parser_warning("Byteordering is not little-endian and type cannot be interpreted");
$$ = new_user($1, $3, $2);
}
;
@ -779,7 +777,7 @@ accelerators
$$->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE;
}
if(!$5)
yyerror("Accelerator table must have at least one entry");
parser_error("Accelerator table must have at least one entry");
$$->events = get_event_head($5);
if($3)
{
@ -1030,7 +1028,7 @@ ctlclass
dialogex: tDIALOGEX loadmemopts expr ',' expr ',' expr ',' expr helpid dlgex_attribs
tBEGIN exctrls tEND {
if(!win32)
yywarning("DIALOGEX not supported in 16-bit mode");
parser_warning("DIALOGEX not supported in 16-bit mode");
if($2)
{
$11->memopt = *($2);
@ -1227,7 +1225,7 @@ opt_expr: /* Empty */ { $$ = NULL; }
/* ------------------------------ Menu ------------------------------ */
menu : tMENU loadmemopts opt_lvc menu_body {
if(!$4)
yyerror("Menu must contain items");
parser_error("Menu must contain items");
$$ = new_menu();
if($2)
{
@ -1299,9 +1297,9 @@ item_options
/* ------------------------------ MenuEx ------------------------------ */
menuex : tMENUEX loadmemopts opt_lvc menuex_body {
if(!win32)
yywarning("MENUEX not supported in 16-bit mode");
parser_warning("MENUEX not supported in 16-bit mode");
if(!$4)
yyerror("MenuEx must contain items");
parser_error("MenuEx must contain items");
$$ = new_menuex();
if($2)
{
@ -1435,7 +1433,7 @@ stringtable
: stt_head tBEGIN strings tEND {
if(!$3)
{
yyerror("Stringtable must have at least one entry");
parser_error("Stringtable must have at least one entry");
}
else
{
@ -1489,12 +1487,12 @@ strings : /* Empty */ { $$ = NULL; }
int i;
assert(tagstt != NULL);
if($2 > 65535 || $2 < -32768)
yyerror("Stringtable entry's ID out of range (%d)", $2);
parser_error("Stringtable entry's ID out of range (%d)", $2);
/* Search for the ID */
for(i = 0; i < tagstt->nentries; i++)
{
if(tagstt->entries[i].id == $2)
yyerror("Stringtable ID %d already in use", $2);
parser_error("Stringtable ID %d already in use", $2);
}
/* If we get here, then we have a new unique entry */
tagstt->nentries++;
@ -1509,11 +1507,11 @@ strings : /* Empty */ { $$ = NULL; }
tagstt->entries[tagstt->nentries-1].characts = tagstt_characts;
if(pedantic && !$4->size)
yywarning("Zero length strings make no sense");
parser_warning("Zero length strings make no sense");
if(!win32 && $4->size > 254)
yyerror("Stringtable entry more than 254 characters");
parser_error("Stringtable entry more than 254 characters");
if(win32 && $4->size > 65534) /* Hmm..., does this happen? */
yyerror("Stringtable entry more than 65534 characters (probably something else that went wrong)");
parser_error("Stringtable entry more than 65534 characters (probably something else that went wrong)");
$$ = tagstt;
}
;
@ -1544,7 +1542,7 @@ fix_version
: /* Empty */ { $$ = new_versioninfo(); }
| fix_version tFILEVERSION expr ',' expr ',' expr ',' expr {
if($1->gotit.fv)
yyerror("FILEVERSION already defined");
parser_error("FILEVERSION already defined");
$$ = $1;
$$->filever_maj1 = $3;
$$->filever_maj2 = $5;
@ -1554,7 +1552,7 @@ fix_version
}
| fix_version tPRODUCTVERSION expr ',' expr ',' expr ',' expr {
if($1->gotit.pv)
yyerror("PRODUCTVERSION already defined");
parser_error("PRODUCTVERSION already defined");
$$ = $1;
$$->prodver_maj1 = $3;
$$->prodver_maj2 = $5;
@ -1564,35 +1562,35 @@ fix_version
}
| fix_version tFILEFLAGS expr {
if($1->gotit.ff)
yyerror("FILEFLAGS already defined");
parser_error("FILEFLAGS already defined");
$$ = $1;
$$->fileflags = $3;
$$->gotit.ff = 1;
}
| fix_version tFILEFLAGSMASK expr {
if($1->gotit.ffm)
yyerror("FILEFLAGSMASK already defined");
parser_error("FILEFLAGSMASK already defined");
$$ = $1;
$$->fileflagsmask = $3;
$$->gotit.ffm = 1;
}
| fix_version tFILEOS expr {
if($1->gotit.fo)
yyerror("FILEOS already defined");
parser_error("FILEOS already defined");
$$ = $1;
$$->fileos = $3;
$$->gotit.fo = 1;
}
| fix_version tFILETYPE expr {
if($1->gotit.ft)
yyerror("FILETYPE already defined");
parser_error("FILETYPE already defined");
$$ = $1;
$$->filetype = $3;
$$->gotit.ft = 1;
}
| fix_version tFILESUBTYPE expr {
if($1->gotit.fst)
yyerror("FILESUBTYPE already defined");
parser_error("FILESUBTYPE already defined");
$$ = $1;
$$->filesubtype = $3;
$$->gotit.fst = 1;
@ -1735,25 +1733,25 @@ lama : tLOADONCALL { $$ = new_int(~WRC_MO_PRELOAD); }
opt_lvc : /* Empty */ { $$ = new_lvc(); }
| opt_lvc opt_language {
if(!win32)
yywarning("LANGUAGE not supported in 16-bit mode");
parser_warning("LANGUAGE not supported in 16-bit mode");
if($1->language)
yyerror("Language already defined");
parser_error("Language already defined");
$$ = $1;
$1->language = $2;
}
| opt_lvc opt_characts {
if(!win32)
yywarning("CHARACTERISTICS not supported in 16-bit mode");
parser_warning("CHARACTERISTICS not supported in 16-bit mode");
if($1->characts)
yyerror("Characteristics already defined");
parser_error("Characteristics already defined");
$$ = $1;
$1->characts = $2;
}
| opt_lvc opt_version {
if(!win32)
yywarning("VERSION not supported in 16-bit mode");
parser_warning("VERSION not supported in 16-bit mode");
if($1->version)
yyerror("Version already defined");
parser_error("Version already defined");
$$ = $1;
$1->version = $2;
}
@ -1769,7 +1767,7 @@ opt_lvc : /* Empty */ { $$ = new_lvc(); }
opt_language
: tLANGUAGE expr ',' expr { $$ = new_language($2, $4);
if (get_language_codepage($2, $4) == -1)
yyerror( "Language %04x is not supported", ($4<<10) + $2);
parser_error( "Language %04x is not supported", ($4<<10) + $2);
}
;
@ -1859,7 +1857,7 @@ static dialog_t *dialog_style(style_t * st, dialog_t *dlg)
if(dlg->gotstyle)
{
yywarning("Style already defined, or-ing together");
parser_warning("Style already defined, or-ing together");
}
else
{
@ -1883,7 +1881,7 @@ static dialog_t *dialog_exstyle(style_t *st, dialog_t *dlg)
if(dlg->gotexstyle)
{
yywarning("ExStyle already defined, or-ing together");
parser_warning("ExStyle already defined, or-ing together");
}
else
{
@ -1901,7 +1899,7 @@ static dialog_t *dialog_caption(string_t *s, dialog_t *dlg)
{
assert(dlg != NULL);
if(dlg->title)
yyerror("Caption already defined");
parser_error("Caption already defined");
dlg->title = s;
return dlg;
}
@ -1910,7 +1908,7 @@ static dialog_t *dialog_font(font_id_t *f, dialog_t *dlg)
{
assert(dlg != NULL);
if(dlg->font)
yyerror("Font already defined");
parser_error("Font already defined");
dlg->font = f;
return dlg;
}
@ -1919,7 +1917,7 @@ static dialog_t *dialog_class(name_id_t *n, dialog_t *dlg)
{
assert(dlg != NULL);
if(dlg->dlgclass)
yyerror("Class already defined");
parser_error("Class already defined");
dlg->dlgclass = n;
return dlg;
}
@ -2031,7 +2029,7 @@ static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control
defaultstyle |= WS_TABSTOP;
break;
default:
yywarning("Unknown default button control-style 0x%08x", special_style);
parser_warning("Unknown default button control-style 0x%08x", special_style);
case BS_GROUPBOX:
case BS_RADIOBUTTON:
break;
@ -2049,7 +2047,7 @@ static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control
case SS_ICON: /* Special case */
break;
default:
yywarning("Unknown default static control-style 0x%08x", special_style);
parser_warning("Unknown default static control-style 0x%08x", special_style);
break;
}
break;
@ -2134,7 +2132,7 @@ static dialogex_t *dialogex_style(style_t * st, dialogex_t *dlg)
if(dlg->gotstyle)
{
yywarning("Style already defined, or-ing together");
parser_warning("Style already defined, or-ing together");
}
else
{
@ -2158,7 +2156,7 @@ static dialogex_t *dialogex_exstyle(style_t * st, dialogex_t *dlg)
if(dlg->gotexstyle)
{
yywarning("ExStyle already defined, or-ing together");
parser_warning("ExStyle already defined, or-ing together");
}
else
{
@ -2336,7 +2334,7 @@ static raw_data_t *int2raw_data(int i)
if( ( i >= 0 && (int)((unsigned short)i) != i) ||
( i < 0 && (int)((short)i) != i) )
yywarning("Integer constant out of 16bit range (%d), truncated to %d\n", i, (short)i);
parser_warning("Integer constant out of 16bit range (%d), truncated to %d\n", i, (short)i);
rd = new_raw_data();
rd->size = sizeof(short);
@ -2554,12 +2552,12 @@ static stringtable_t *find_stringtable(lvc_t *lvc)
if((stt->lvc.version && lvc->version && *(stt->lvc.version) != *(lvc->version))
|| (!stt->lvc.version && lvc->version)
|| (stt->lvc.version && !lvc->version))
yywarning("Stringtable's versions are not the same, using first definition");
parser_warning("Stringtable's versions are not the same, using first definition");
if((stt->lvc.characts && lvc->characts && *(stt->lvc.characts) != *(lvc->characts))
|| (!stt->lvc.characts && lvc->characts)
|| (stt->lvc.characts && !lvc->characts))
yywarning("Stringtable's characteristics are not the same, using first definition");
parser_warning("Stringtable's characteristics are not the same, using first definition");
*/
return stt;
}
@ -3029,13 +3027,13 @@ static int rsrcid_to_token(int lookahead)
case WRC_RT_ANIICON:
case WRC_RT_GROUP_CURSOR:
case WRC_RT_GROUP_ICON:
yywarning("Usertype uses reserved type ID %d, which is auto-generated", yylval.num);
parser_warning("Usertype uses reserved type ID %d, which is auto-generated", yylval.num);
return lookahead;
case WRC_RT_DLGINCLUDE:
case WRC_RT_PLUGPLAY:
case WRC_RT_VXD:
yywarning("Usertype uses reserved type ID %d, which is not supported by wrc yet", yylval.num);
parser_warning("Usertype uses reserved type ID %d, which is not supported by wrc yet", yylval.num);
default:
return lookahead;
}

View File

@ -68,21 +68,21 @@ static void generic_msg(const char *s, const char *t, const char *n, va_list ap)
}
int yyerror(const char *s, ...)
int parser_error(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Error", yytext, ap);
generic_msg(s, "Error", parser_text, ap);
va_end(ap);
exit(1);
return 1;
}
int yywarning(const char *s, ...)
int parser_warning(const char *s, ...)
{
va_list ap;
va_start(ap, s);
generic_msg(s, "Warning", yytext, ap);
generic_msg(s, "Warning", parser_text, ap);
va_end(ap);
return 0;
}

View File

@ -33,8 +33,8 @@ char *xstrdup(const char *str);
#define __attribute__(X)
#endif
int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
int parser_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4), noreturn));
void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));

View File

@ -166,7 +166,7 @@ int char_number = 1; /* The current char pos within the line */
char *cmdline; /* The entire commandline */
time_t now; /* The time of start of wrc */
int yydebug, yy_flex_debug;
int parser_debug, yy_flex_debug;
resource_t *resource_top; /* The top of the parsed resources */
@ -424,7 +424,7 @@ int main(int argc,char *argv[])
setbuf(stderr,0);
}
yydebug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
parser_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
yy_flex_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
wpp_set_debug( (debuglevel & DEBUGLEVEL_PPLEX) != 0,
@ -486,12 +486,12 @@ int main(int argc,char *argv[])
/* Go from .rc to .res */
chat("Starting parse");
if(!(yyin = fopen(input_name, "rb")))
if(!(parser_in = fopen(input_name, "rb")))
error("Could not open %s for input\n", input_name);
ret = yyparse();
ret = parser_parse();
if(input_name) fclose(yyin);
if(input_name) fclose(parser_in);
if(ret) exit(1); /* Error during parse */