Здравствуйте!
Не могу компилятором c++ собрать простейший калькулятор. Хотя аналог С функциями без проблем собрался.
Логи ниже
# cat scan.l %{ #include <sstream> %} DIGITS [0-9]+ %% [ ] {} {DIGITS} { std::istringstream str(yytext); str>>yylval; return NUM; } \n|. {return yytext[0];} %%
# cat calc.yy %{ #include <iostream> int yylex(); int yyerror(char const *m){std::cout<<m;} int yywrap(); int yyparse(void); %} %token NUM %left '+' '-' %left '*' '/' %% p : | p s ;
s : e '\n' { std::cout << $1 << std::endl; } | error '\n' ; e : e '+' e { $$ = $1 + $3; } | e '-' e { $$ = $1 - $3; } | NUM ; %%
#include "lex.yy.cc"
# flex -+ scan.l # bison calc.yy #c++ calc.tab.cc -lfl -ly /tmp/cceihXfg.o(.text+0x27d): In function `yyparse()': : undefined reference to `yylex()' /tmp/cceihXfg.o(.text+0xc9f): In function `yyFlexLexer::yylex()': : undefined reference to `yywrap()' /tmp/cceihXfg.o(.text+0x1b0a): In function `yyFlexLexer::yyinput()': : undefined reference to `yywrap()' /usr/lib/gcc-lib/i486-linux/3.3.5/../../../libfl.a(libmain.o)(.text+0x11): In function `main': : undefined reference to `yylex'