De komentator

edytuj
%x COMMENT
%x STRING
%%
<INITIAL>\/\/.*		;
<INITIAL>\"		ECHO;BEGIN(STRING);
<INITIAL>\/\*		BEGIN(COMMENT);

<STRING>[^\"\\]		ECHO;
<STRING>\\(.|\n)	ECHO;
<STRING>\"		ECHO;BEGIN(INITIAL);

<COMMENT>[^\*\/]	;
<COMMENT>\*		;
<COMMENT>\*\/		BEGIN(INITIAL);

<INITIAL>.|\n		ECHO;
%%
int	yywrap	(void)
	{
	return 1;
	}

int	main	(int argc,char** argv)
	{
	return yylex();
	}