Path: utzoo!attcan!uunet!munnari!mulga!ausmelb!ejp From: ejp@ausmelb.oz (Esmond Pitt) Newsgroups: comp.bugs.4bsd Subject: Re: Bug in lex?!? Summary: yes indeed + better workaround Message-ID: <759@ausmelb.oz> Date: 14 Sep 88 01:00:57 GMT References: <14373@hc.DSPO.GOV> Reply-To: ejp@ausmelb.oz (Esmond Pitt) Organization: Austec International Limited, Melbourne Lines: 26 In article <14373@hc.DSPO.GOV> siegel@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@ausmelb.oz