%option noyywrap %option nounput %{ #include #include using namespace std; #include "izrazi.hpp" #include "naredbe.hpp" #include #include "parser.tab.hpp" %} %% "pocetak" return pocetak_token; "kraj" return kraj_token; "ispisi" return ispisi_token; "mod" return mod_token; \"(\\.|[^\"])*\" { string tmp = string(yytext + 1);\ tmp = tmp.substr(0, tmp.size() - 1); yylval.s = new string(tmp); return string_token; } [0-9]+ { yylval.d = atoi(yytext); return num_token; } "0x"[0-9a-fA-F]+ { sscanf(yytext, "%x", &yylval.d); return num_token; } [a-zA-Z_][a-zA-Z_0-9]* { yylval.s = new string(yytext); return id_token; } [-+*/();.:=] return *yytext; [ \t\n] { } . { cerr << "Leksicka greska: Neprepoznat karakter '" << *yytext << "'" << endl; exit(EXIT_FAILURE); } %%