%option noyywrap %option nounput %{ #include #include #include using namespace std; #include "parser.tab.hpp" %} %% "pocetak" return pocetak_token; "kraj" return kraj_token; "ispisi" return ispisi_token; "mod" return mod_token; [:=.();+*/-] return *yytext; [a-zA-Z_][a-zA-Z_0-9]* { for (unsigned i = 0; i < strlen(yytext); i++) yytext[i] = tolower(yytext[i]); yylval.s = new string(yytext); return id_token; } ["](\\["]|[^"])*["] { string tmp(yytext); tmp = tmp.substr(1, tmp.size() - 2); yylval.s = new string(tmp); return string_token; } [0-9]+ { yylval.i = atoi(yytext); return broj_token; } 0x[0-9a-fA-F]+ { yylval.i = (int)strtol(yytext, NULL, 16); return broj_token; } [ \t\n] { } . { fprintf(stderr, "Leksicka greska: neprepoznat karakter '%c'\n", *yytext); exit(EXIT_FAILURE); } %%