Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!targon!andre From: andre@targon.UUCP (andre) Newsgroups: comp.lang.c Subject: Re: Unixworld competition - SOLUTIONS Message-ID: <1692@targon.UUCP> Date: 17 Apr 91 11:08:10 GMT References: <1991Apr2.012639.25454@cbnewsh.att.com> Organization: Siemens Nixdorf Informationsystems BV.,SWZ, Vianen, the Netherlands. Lines: 46 In article <1991Apr2.012639.25454@cbnewsh.att.com> gls@corona.ATT.COM (Col. G. L. Sicherman) writes: >As I promised, here are the bugs in the prize-winning comment- [ removed other two programs ] Now the lex program: >%} >([^\\]\")|(\\\\\") | >([^.\\]\')|(\\\\\') | >\n { ECHO; BEGIN CODE; } >"*/" { two_space(); BEGIN CODE; } >. { output(*yytext=='\t'?'\t':' ');} >"/*" { two_space(); BEGIN CCOM ; } >"//" { two_space(); BEGIN CPLUS ;} >\" { ECHO; BEGIN STRING; } >\' { ECHO; BEGIN CHAR; } >. { ECHO; } >%% > >This one doesn't handle multiple backslashes, though lex has the power >to do so easily. A program like this will break it: > > main() > { > char *str = "This string has everything \\\" /* and more!\n"; > > printf(str); > } Oke oke you win, I made a mistake (blush) how about with the following ? This should fix it no? Just change the first three lines of the lex part to: \\. { ECHO; } \" | \' | \n { ECHO; BEGIN CODE; } happy lexing... -- The mail| AAA DDDD It's not the kill, but the thrill of the chase. demon...| AA AAvv vvDD DD Ketchup is a vegetable. hits!.@&| AAAAAAAvv vvDD DD {nixbur|nixtor}!adalen.via --more--| AAA AAAvvvDDDDDD Andre van Dalen, uunet!hp4nl!targon!andre