Fixed some lemon bugs:

* "Symbol name missing after %destructor keyword" error message displayed incorrectly.
* Line numbers in the generated file for lines that came from the template were off.
* The parser did not immediately reduce after a shift. There always needed to be
  another token input first before a reduce would occur, and then the token would
  sometimes be lost.

SVN r469 (trunk)
This commit is contained in:
Randy Heit 2007-01-31 00:15:08 +00:00
parent 323034af74
commit e8495e90f5
2 changed files with 761 additions and 739 deletions

View file

@ -2287,7 +2287,7 @@ to follow the previous rule.");
case WAITING_FOR_DESTRUCTOR_SYMBOL:
if( !isalpha(x[0]) ){
ErrorMsg(psp->filename,psp->tokenlineno,
"Symbol name missing after %destructor keyword");
"Symbol name missing after %%destructor keyword");
psp->errorcnt++;
psp->state = RESYNC_AFTER_DECL_ERROR;
}else{
@ -2300,7 +2300,7 @@ to follow the previous rule.");
case WAITING_FOR_DATATYPE_SYMBOL:
if( !isalpha(x[0]) ){
ErrorMsg(psp->filename,psp->tokenlineno,
"Symbol name missing after %destructor keyword");
"Symbol name missing after %%destructor keyword");
psp->errorcnt++;
psp->state = RESYNC_AFTER_DECL_ERROR;
}else{
@ -2450,6 +2450,23 @@ static void preprocess_input(char *z){
}
}
int strip_crlf(filebuf, filesize)
char *filebuf;
int filesize;
{
int i, j;
for (i = j = 0; i < filesize; ++i, ++j)
{
if (filebuf[i] == '\r' && filebuf[i+1] == '\n')
{
++i;
}
filebuf[j] = filebuf[i];
}
return j;
}
/* In spite of its name, this function is really a scanner. It read
** in the entire input file (all at once) then tokenizes it. Each
** token is passed to the function "parseonetoken" which builds all
@ -2498,6 +2515,7 @@ struct lemon *gp;
return;
}
fclose(fp);
filesize = strip_crlf(filebuf, filesize);
filebuf[filesize] = 0;
/* Make an initial pass through the file to handle %ifdef and %ifndef */
@ -3079,8 +3097,8 @@ int *lineno;
putc('\n',out);
(*lineno)++;
}
tplt_linedir(out,*lineno+2,lemp->outname);
(*lineno)+=2;
tplt_linedir(out,*lineno+1,lemp->outname);
(*lineno)+=1;
return;
}

View file

@ -4,6 +4,7 @@
/* First off, code is included which follows the "include" declaration
** in the input file. */
#include <stdio.h>
#include <string.h>
%%
/* Next is all token values, in a form suitable for use by makeheaders.
** This section will be null unless lemon is run with the -m switch.
@ -420,7 +421,7 @@ static void yy_shift(
#endif
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
/* Here code is inserted which will execute if the parser
** stack every overflows */
** stack ever overflows */
%%
ParseARG_STORE; /* Suppress warning about unused %extra_argument var */
return;
@ -641,6 +642,9 @@ void Parse(
yymajor = 0;
}else{
yymajor = YYNOCODE;
while( yypParser->yyidx>= 0 && (yyact = yy_find_shift_action(yypParser,YYNOCODE)) < YYNSTATE + YYNRULE ){
yy_reduce(yypParser,yyact-YYNSTATE);
}
}
}else if( yyact < YYNSTATE + YYNRULE ){
yy_reduce(yypParser,yyact-YYNSTATE);