%option noyywrap %option nounput %{ #include #include using namespace std; #include "izraz.hpp" #include "naredba.hpp" #include "parser.tab.hpp" %} %% "pocetak" return pocetak_token; "kraj" return kraj_token; "ispisi" return ispisi_token; "mod" return mod_token; [0-9]+ { yylval.i = atoi(yytext); return num_token; } "0x"[0-9a-fA-F]+ { sscanf(yytext, "%x", &yylval.i); return num_token; } \"([^\"])*\" { yylval.s = new string(yytext + 1); yylval.s->pop_back(); return string_token; } [-+*/();.] return *yytext; [ \t\n] { } . { cerr << "Leksicka greska: neprepoznat karakter '" << *yytext << "'" << endl; return EXIT_FAILURE;} %%