%option noyywrap %{ #include #define YYDEBUG 1 int yyLineNumber = 1; %} %% [a-zA-Z]+ myprint("Identifier"); //matcht auch if und IF! IF|if myprint("keyword"); \n yyLineNumber++; [ \t] //nix machen, "spaces und tabs überlesen" . myprint("unknown Symbol"); %% int main() { printf("Programm eingeben: \n"); yylex(); return 0; } int myprint(char token[]) { printf("\nZeile %d >>> ", yyLineNumber); printf("%s ", token); printf("%s\n", yytext); // yytext: String, der gerade gelesen wurde }