/* 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]{5,5})*$ {++num_matches; printf("\nThe match was : %s", yytext);} . {} %% /* ----------------- User code space ------------------ */ main() { printf("Listing matches for 'All words which length is a multiple of 5'.\n"); yylex(); printf("--- Number of matches found: %d\n", num_matches); }