Kod: |
%{: #include #include \"parser.hh\" extern YYSTYPE yylval: %}: %option bison-bridge %% <*>[:^\\n]:+ {: yylval->str = strdup(:yytext):: return TOKEN_LINE: }: %% |
Kod: |
%{: #include int yylex (:void):: void yyerror (:char const *s): {: fprintf (:stderr, \"%s\\n\", s):: }: %}: %union {: char *str: }: %token %% content:: TOKEN_LINE {: printf(:\"[:LINE]: %s\\n\", $1):: }:: %% |
Kod: |
#include #include \"parser.hh\" extern int yyparse (:void):: int main(:): {:  :  : printf(:\"*** TEST START ***\\n\")::  :  : int theResult = yyparse(:)::  :  : printf(:\"**** TEST END ****\\n\")::  :  : return 0: }: |
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 |
Stg napisal: |
Moze tez nie pomoge ale jakis czas temu na forum.gamedev.pl byl temat parserow i bison gdzies tam tez przemknal. |