Comment recognition in Lex (simple solution)
Per Bergsten
bergsten at chalmers.UUCP
Sun May 13 11:36:11 AEST 1984
%{
/*
** This solution is at least easy to understand (if you read
** the last pages in the Lex manual).
** The OTHER start-condition can, with some care, be eliminated.
** In any case .* patterns will interfere with the ones below.
**
** Per Bergsten
** Departement of Computer Sciences
** Chalmers University of Technology
** Goteborg
** Sweden
*/
%}
%Start COMMENT OTHER
%%
<OTHER>"/*" { BEGIN COMMENT; ECHO; }
<COMMENT>"*/" { BEGIN OTHER; ECHO; }
<COMMENT>(.|\n) { ECHO; };
(.|\n) ;
%%
yywrap() { return (1); }
main()
{
BEGIN OTHER;
yylex();
}
More information about the Comp.unix.wizards
mailing list