Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!uw-entropy!quick!ole!linqdev!mark From: mark@linqdev.UUCP (mark) Newsgroups: comp.lang.c Subject: Re: LEX rule, anyone??? Message-ID: <364@linqdev.UUCP> Date: 11 Dec 89 17:39:24 GMT References: <601@vice2utc.chalmers.se> <21108@mimsy.umd.edu> Reply-To: mark@linqdev.UUCP () Organization: INTERLINQ Software Corp Lines: 34 > /* this is a regular expression to match a c comment */ > /* written by cml 890922 (probably not minimal) */ >%% >"/*"([^*]|[*]*[^*/])*[*]+"/" {printf("saw a c comment.\n");} >. {putchar(*yytext);} >----snip---- > >chris... >-- As a friend the the office here pointed out, this particular way of handling C comments tends to 'grow' the parser. Here is his solution which I thought was a neat way to do it and save some space: "/*" { do { yytext[0] = yytext[1]; if( !( yytext[1] = input() ) ) yyerror( "EOF in comment. Missing \"*/\"." ); } while( yytext[0] != '*' || yytext[1] != '/' ); } 01010000010000010100001101001011010001010101010000100000010000100100001001010011 * Mark R. Holbrook-WS7M uw-beaver! Interlinq Software Corp * * Issaquah, WA 98027 sumax!ole! /mark 10230 NE Points Dr #200 * * HM:206-392-9672 Voice linqdev! Kirkland, WA 98033-???? * * HM:206-392-9673 Data \ws7m!ws7m WK:206-827-1112 Ext:152 * * Opinions..? Yes, they are mine and mine alone! I'll sell 'em cheap however! * 00100000010101110101001100110111010011010100000001010111010100110011011101001101