Temat nie zwiazany bezposrednio z programowaniem na C64, ale byc moze znajdzie sie tutaj ktos, kto bedzie potrafil mi pomoc?
Otoz probuje napisac sobie parser w oparciu o narzedzia flex/bison... Niestety, za nic nie chca mi one ze soba wspolpracowac... Postanowilem zatem poszukac pomocy wsrod madrzejszych programistow... Ponizej przedstawiam calosc mojego projektu skompresowana do minimalnej postaci w stylu \"Hello World\".
lexer.lex Kod: |
%{: #include #include \"parser.hh\" extern YYSTYPE yylval: %}:
%option bison-bridge
%%
<*>[:^\\n]:+ {: yylval->str = strdup(:yytext):: return TOKEN_LINE: }:
%% |
parser.yy Kod: |
%{: #include int yylex (:void):: void yyerror (:char const *s): {: fprintf (:stderr, \"%s\\n\", s):: }: %}:
%union {: char *str: }: %token TOKEN_LINE
%%
content:: TOKEN_LINE {: printf(:\"[:LINE]: %s\\n\", $1):: }::
%% |
test.c Kod: |
#include #include \"parser.hh\"
extern int yyparse (:void)::
int main(:): {:  :  : printf(:\"*** TEST START ***\\n\")::  :  : int theResult = yyparse(:)::  :  : printf(:\"**** TEST END ****\\n\")::  :  : return 0: }: |
Kompilacja tego minimalnego projektu przebiega nastepujaco:
Kod: |
bash-2.05$ bison --report=all -o parser.cc -d parser.yy bash-2.05$ ls lexer.lex :  :  : parser.cc :  :  : parser.hh :  :  : parser.output : parser.yy :  :  : test.c bash-2.05$ flex -olexer.cc lexer.lex bash-2.05$ ls lexer.cc :  :  :  :lexer.lex :  :  : parser.cc :  :  : parser.hh :  :  : parser.output : parser.yy :  :  : test.c bash-2.05$ g++ -o parser.o -c parser.cc bash-2.05$ ls lexer.cc :  :  :  :lexer.lex :  :  : parser.cc :  :  : parser.hh :  :  : parser.o :  :  :  :parser.output : parser.yy :  :  : test.c bash-2.05$ g++ -o lexer.o -c lexer.cc bash-2.05$ ls lexer.cc :  :  :  :lexer.lex :  :  : lexer.o :  :  :  : parser.cc :  :  : parser.hh :  :  : parser.o :  :  :  :parser.output : parser.yy :  :  : test.c bash-2.05$ g++ -o test lexer.o parser.o -ly -lfl test.c parser.o(:.text+0x304)::: In function `yyparse(:):\':: :: undefined reference to `yylex(:):\' collect2:: ld returned 1 exit status |
Jezeli ktos bylby w stanie wskazac mi, co robie zle, albo gdzie jest blad, to wypije dzisiaj wieczorem jego zdrowie! 