bug in yacc -- or is it a feature
Craig Wylie
craig at comp.lancs.ac.uk
Thu Jan 8 02:42:21 AEST 1987
Firstly if I'm repeating an old point then sorry.
The following yacc fragment is passed by yaqcc as correct but
would appear to include a syntax error.
%token IDENT COMMA FOR_ALL THERE_EXISTS
%%
program : ident_list quantifier
quantifier : FOR_ALL
| THERE_EXISTS ident_list
: ident_list COMMA IDENT /* error here is ':' correct */
| IDENT
%%
On closer examination it appears that yacc is treating this as
%token IDENT COMMA FOR_ALL THERE_EXISTS
%%
program : ident_list quantifier
quantifier : FOR_ALL
| THERE_EXISTS
ident_list : ident_list COMMA IDENT
| IDENT
%%
now this would still seem to be wrong as the semi colons at the end of
each rule seem to be missing. Adding them in produces the same parser
as when they are not included. Can't be a bug, must be a feature -- yet the
first example is not an inconcievable mistake made in the heat of the moment.
If there is anybody there who knows -- bug or feature ?
Craig.
--
UUCP: ...!seismo!mcvax!ukc!dcl-cs!craig| Post: University of Lancaster,
DARPA: craig%lancs.comp at ucl-cs | Department of Computing,
JANET: craig at uk.ac.lancs.comp | Bailrigg, Lancaster, UK.
Phone: +44 524 65201 Ext. 4146 | LA1 4YR
More information about the Comp.unix.questions
mailing list