/* File........ parser3.lex * Contents.... Exemple of small parser usin LEX */ /* compilation: * flex parser3.lex * gcc -o parser3.exe lexyy.c */ /* ---------------- Definitions space ----------------- */ %option noyywrap %{ #include #include #include #include int students = 0; %} DIGIT [0-9]+ STUDENT_ID [u|s]{DIGIT}{6,7} /* ------------------- Rules space -------------------- */ %% {STUDENT_ID} { ++students; } \n { } . { } %% /* ----------------- User code space ------------------ */ main() { printf("Hit ^Z followed by enter to finish\n"); yylex(); printf("--- Students : %d\n", students); }