Any YACC / BISON gurus out there?
Nick Crossley
ndjc at capone.UUCP
Fri Oct 27 10:37:37 AEST 1989
In article <1341 at ssf> richard at ssf.uucp (Richard Thombs) writes:
>I need to be able to get YACC (or BISON if need be) to fail a parse when an
>action tells it to.
Some versions of yacc have a YYBACKUP macro in the parser skeleton.
This allows limited backup, possibly not as much as you want. I have
found it most useful to reduce the number of 'reserved words' in a
grammar:
rule : identifier { YYBACKUP(special($1)); }
| token1 { ... }
| token2 { ... }
...
;
The lexer never returns 'token1', etc. The function 'special'
examines the identifier and returns token1, etc., as appropriate.
So token1, etc., are only recognised as keywords in the correct context;
elsewhere, they are just identifiers.
--
<<< standard disclaimers >>>
Nick Crossley, ICL NA, 9801 Muirlands, Irvine, CA 92718-2521, USA 714-458-7282
uunet!ccicpg!ndjc / ndjc at ccicpg.UUCP
More information about the Comp.unix.questions
mailing list