%{ #include #include #include "pcomp.tab.h" int yylval_i; double yylval_d; char *yylval_s; %} %option noyywrap DIGIT [0-9] ID [a-zA-Z][a-zA-Z0-9_]* %% {DIGIT}+ { yylval_i = atoi(yytext); return TOK_INT; } {DIGIT}+"."{DIGIT}* { yylval_d = atof(yytext); return TOK_DOUBLE; } "if" return TOK_IF; "then" return TOK_THEN; "begin" return TOK_BEGIN; "end" return TOK_END; "procedure" return TOK_PROCEDURE; "function" return TOK_FUNCTION; "=" return TOK_EQUAL; ";" return TOK_SEMICOLON; {ID} { yylval_s = yytext; return TOK_ID; } "+" return TOK_PLUS; "-" return TOK_MINUS; "*" return TOK_TIMES; "/" return TOK_DIV; "{"[^}\n]*"}" /* ueberspringe einzeilige Kommentare */ [ \t\n]+ /* ueberspringe White-Space */ . { printf("Unbekanntes Zeichen: '%s'\n", yytext);}