Created
April 25, 2020 20:13
-
-
Save maifeeulasad/64acbbcfdc02a63b39626f3805c338e3 to your computer and use it in GitHub Desktop.
flex template, without token returning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flex lexer.l | |
gcc lex.yy.c | |
a.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ | |
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