[prog] Yacc - double errors
Sue Stones
suzo at spin.net.au
Tue Feb 10 14:55:49 EST 2004
On Tue, 10 Feb 2004 11:01 am, Jimen Ching wrote:
> On Mon, 9 Feb 2004, Sue Stones wrote:
> >---------------------------------------
> >end_statement: END SEMI { fprintf(stdout, "end;\n"); }
> >
> > | END error {
> >
> > errorstr = strdup("Missing semicolon after
> > \"end\""); yyerror(errorstr); }
> > ;
> >---------------------------------------
>
> Exactly what errors are you seeing?
>
> --jc
Well I have rewritten it a number of times, and seen diferent things,
sometimes I get the line number followed by "syntax error" the first time,
then the same line number followed by my own error. Sometimes I have "syntax
error" twice for the same line. sometimes I have "Missing semicolon" twice
for each error.
The error count is double what it should be too. Also I am getting an error
at the end of the file, even when I shouldn't be.
The impression I get is that it is calling the yyerror routine twice, once
automaticaly, and once when I call it. But there is nothing in the
documentation that I have that mentions how this miht be happening.
Somewhere there was a mention of errok and double errors, but it doens't seem
to make any diference whether I use errok or not.
Here is an example:
---------------------------------
plus.b:1: syntax error
plus.b:1: Missing semicolon after 'do'
plus.b:3: syntax error
3 errors
--------------------------------
input:
------
while name2 <> 0 do
incr name1;
decr name2;
end;
incr name2;
---------------------------------
sue
More information about the Programming
mailing list