/* File........ parser1.lex * Contents.... Exemple of small parser usin LEX * * compilation: * flex parser1.lex * gcc -o parser1.exe lexyy.c */ /* ---------------- Definitions space ----------------- */ %option noyywrap %{ #include #include #include #include int num_lines = 0; %} /* ------------------- Rules space -------------------- */ %% ^[ab]*aa[ab]*$ {++num_lines; printf("\nThe match was : %s", yytext);} . {} %% /* ----------------- User code space ------------------ */ main() { printf("Listing matches for 'All words containing aa'", num_lines); yylex(); }