1
4. ročník / Re: Konstrukcia prekladacov
« on: 02.12.2012, 00:07:05 »To test:
Ahoj. Skusal som pod ubuntu upravit si cviko 1 - kalkulacku. Najprv bolo nutne si nainstalovat cez apt-get install flex. Bison som instaloval podla navodu z netu Ale asi aj ten sa da nainstalovat do ubuntu z repozitara.. Ok, tak na ukazku pripajam upravene subory CALC1.L a CALC1.Y v prilohe. Bolo ich nutne upravit, ale aj to som robil narychlo podla navodu z netu Ok, kroky po rozbaleni prilohy:
1. yacc -d CALC1.Y
-- vytvori subor y.tab.h a subor y.tab.c
2. lex CALC.L
-- vytvori subor lex.yy.c
3. g++ y.tab.c lex.yy.c -lfl -o test
-- skompiluje program s nazvom test (sice s warningami - tie dnes neriesim )
4. ./test -- spustenie kalkulatora
Ok, snad ma linuxaci nezastrelia a poradia aj mne ako na to Na dnes len tolko
cawte....pri kompilacii na linuxe mi vyhadzjue errory aj z *.L suboru (kompilacia na stiahnutom zip archive)
nejake napady?
Vystup z kompilacie:
Code: [Select]
g++ y.tab.c lex.yy.cc -lfl -o test
y.tab.c: In function ‘int yyparse()’:
y.tab.c:1459: warning: deprecated conversion from string constant to ‘char*’
y.tab.c:1602: warning: deprecated conversion from string constant to ‘char*’
CALC1.L: In member function ‘virtual int yyFlexLexer::yylex()’:
CALC1.L:11: error: ‘PAMAT’ was not declared in this scope
CALC1.L:12: error: ‘PRIRAD’ was not declared in this scope
CALC1.L:13: error: ‘PLUS’ was not declared in this scope
CALC1.L:14: error: ‘MINUS’ was not declared in this scope
CALC1.L:15: error: ‘KRAT’ was not declared in this scope
CALC1.L:16: error: ‘DELENE’ was not declared in this scope
CALC1.L:17: error: ‘LZAT’ was not declared in this scope
CALC1.L:18: error: ‘PZAT’ was not declared in this scope
CALC1.L:19: error: ‘CR’ was not declared in this scope
CALC1.L:22: error: ‘CISLO’ was not declared in this scope
CALC1.L:24: error: ‘INY’ was not declared in this scope
make: *** [all] Error 1