%{ #define NUMBER 1234 #define PARZYSTA 1 #define NIEPARZYSTA 78 int wynik_koncowy = 1; int attr; %} LICZBA_P [0-9]*[02468] LICZBA_NP [0-9]*[13579] %% {LICZBA_P} { attr = atoi(yytext); return PARZYSTA; } {LICZBA_NP} { attr = atoi(yytext); return NIEPARZYSTA; } .|\n ; %% int main() { int result; int wynik_koncowy = 1; while((result = yylex())) { if(result == PARZYSTA) { wynik_koncowy += attr; } if(result == NIEPARZYSTA) { wynik_koncowy *= attr; } } printf("Wynik koncowy: %d", wynik_koncowy); }