Skip to content

Instantly share code, notes, and snippets.

@sunliang711
Forked from fay59/comments.lex
Created February 29, 2020 07:41
Show Gist options
  • Save sunliang711/67960dcae578edb2bd944ed7781bd850 to your computer and use it in GitHub Desktop.
Save sunliang711/67960dcae578edb2bd944ed7781bd850 to your computer and use it in GitHub Desktop.
Tiny Flex lexer that skips C-style block comments
%option noyywrap
%x C_COMMENT
%%
"/*" { BEGIN(C_COMMENT); }
<C_COMMENT>"*/" { BEGIN(INITIAL); }
<C_COMMENT>. { }
<C_COMMENT>\n { }
. { printf("%s", yytext); }
%%
int main() {
yylex();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment