/* 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_matches = 0; %} /* ------------------- Rules space -------------------- */ %% ^([ab][ab])*$ {++num_matches; printf("\nThe match was : %s", yytext);} . {} %% /* ----------------- User code space ------------------ */ main() { printf("Listing matches for 'All words containing an even number of letters'."); yylex(); printf("--- Number of matches found: %d\n", num_matches); }