%option noyywrap %option nounput %{ #include #include #include #include #include "ast.hpp" using namespace std; #include "parser.tab.hpp" %} %% def return def_token; extern return extern_token; [0-9]+(\.[0-9]+)? { yylval.d = atof(yytext); return num_token; } [a-zA-Z][a-zA-Z0-9]* { yylval.s = new string(yytext); return id_token; } [+;(),*-] return *yytext; [\t\n ] { } . { cerr << "Leksicka greska: neprepoznat karakter '" << *yytext << "'" << endl; exit(EXIT_FAILURE); } %%