%{ #include #include #include #include "regex.hpp" #define YYDEBUG 1 using namespace std; void yyerror(string s) { cerr << s << endl; exit(EXIT_FAILURE); } extern int yylex(); %} %union { char c; RegEx *r; } %token basic_token %token slovo_token %type E T F %% Program: Program Naredba '\n' { } | Naredba '\n' { } ; Naredba: basic_token E { $2->basic(); cout << endl; delete $2; } ; E: E '|' T { $$ = new Disjunkcija($1, $3); } | T { $$ = $1; } ; T: T F { $$ = new Konkatenacija($1, $2); } | F { $$ = $1; } ; F: F '*' { $$ = new Klini($1); } | slovo_token { $$ = new Slovo($1); } | '(' E ')' { $$ = $2; } ; %% int main() { //yydebug = 1; yyparse(); return 0; }