Skip to content

Instantly share code, notes, and snippets.

@mbenke
Created November 19, 2010 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbenke/706400 to your computer and use it in GitHub Desktop.
Save mbenke/706400 to your computer and use it in GitHub Desktop.
cid.l
%option noyywrap
D [0-9]
L [A-Za-z_]
%start COMMENT
%{
int depth = 0;
%}
%%
ifdef
ifndef
define
undef
include
extern
class
static
if
then
else
while
do
for
return
<INITIAL>"/*" {depth=1;BEGIN(COMMENT);}
<COMMENT>"/*" {depth++;}
<COMMENT>"*/" {depth--;
if(!depth)
BEGIN(INITIAL);
}
<COMMENT>. {}
<INITIAL>{L}({D}|{L})* { return 1; }
.
\n
%%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment