Bug in lex?!?
Esmond Pitt
ejp at ausmelb.oz
Wed Sep 14 11:00:57 AEST 1988
In article <14373 at hc.DSPO.GOV> siegel at hc.DSPO.GOV (josh Siegel) writes:
> (I have only tested this under SunOS 4.0 and BSD4.3)
>
> The following code makes lex produce C code with a syntax error in it:
> -----
> W [ \t]+
> %%
> ^{W}% { }
> %%
This also happens on a Pyramid under both att & bsd universes (i.e.
both lex's), probably because '%' is a special character to lex.
^{W}"%" also fails.
However the example works correctly & is in somewhat better (safer)
style if the definition of W is written as:
W ([ \t]+)
Lex definitions should _always_ be parenthesised, for the same reason
that #defines which yield expressions should always parenthesise them:
to ensure that the apparent and real precedences are the same.
--
Esmond Pitt, Austec International Ltd
...!uunet.UU.NET!munnari!ausmelb!ejp,ejp at ausmelb.oz
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list