Skip to content

Instantly share code, notes, and snippets.

@maifeeulasad
Created April 25, 2020 20:13
Show Gist options
  • Save maifeeulasad/64acbbcfdc02a63b39626f3805c338e3 to your computer and use it in GitHub Desktop.
Save maifeeulasad/64acbbcfdc02a63b39626f3805c338e3 to your computer and use it in GitHub Desktop.
flex template, without token returning
flex lexer.l
gcc lex.yy.c
a.exe
%{
extern int yylex();
%}
%option noyywrap
WS [ \t\n]+
ID [a-z]
S1 "."{ID}+
S2 {ID}+.
T_DEF "def"
%%
{T_DEF} {printf("DEF found\n");}
{S1} {printf("s1 : %s\n",yytext);}
{S2} {printf("s2 : %s\n",yytext);}
%%
int main(int argc, char** argv) {
while (yylex());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment