%option noyywrap %option nounput %{ #include using namespace std; #include #include "izrazi.hpp" #include "naredbe.hpp" #include #include #include "parser.tab.hpp" %} %% "pocetak" return pocetak_token; "kraj" return kraj_token; "ispisi" return ispisi_token; "mod" return mod_token; "unesi" return unesi_token; "ako_je" return ako_je_token; "onda" return onda_token; "inace" return inace_token; \"([^\"])*\" { string tmp(yytext); tmp = tmp.substr(1, tmp.size() - 2); yylval.s = new string(tmp); return string_token; } [0-9]+ { yylval.d = atoi(yytext); return num_token; } "0x"[a-fA-F0-9]+ { 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 karatker'" << *yytext << "'" << endl; exit(EXIT_FAILURE); } %%