%{ #include #include %} %option main %option noyywrap DIGIT [0-9] ID [a-zA-Z][a-zA-Z0-9_]* %% {DIGIT}+ { printf("Eine Ganz-Zahl: '%s' (%d)\n", yytext, atoi(yytext)); } {DIGIT}+"."{DIGIT}* { printf("Eine Fliesskomma-Zahl: '%s' (%g)\n", yytext, atof(yytext)); } "if"|"then"|"begin"|"end"|"procedure"|"function"|"="|";" { printf("Ein Schluesselwort: '%s'\n", yytext); } {ID} { printf("Ein Bezeichner: '%s'\n", yytext); } "+" | "-" | "*" | "/" { printf("Ein Operator: '%s'\n", yytext); } "{"[^}\n]*"}" /* ueberspringe einzeilige Kommentare */ [ \t\n]+ /* ueberspringe White-Space */ . { printf("Unbekanntes Zeichen: '%s'\n", yytext);}