Flex/Bison problems

Good evening!! Apparently i am having problems with this languages and it is very hard to find answers on the web about it.
I am trying to run a program from Oreily Flex and Bison

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* simplest version of calculator */
%{
#include <stdio.h>
%}
/* declare tokens */
%token NUMBER
%token ADD SUB MUL DIV ABS
%token EOL
%%
calclist: 
| calclist exp EOL { printf("= %d\n", $1); }
;
exp: factor default $$ = $1  
| exp ADD factor { $$ = $1 + $3; }
| exp SUB factor { $$ = $1 - $3; }
;
factor: term default $$ = $1<----I deleted "default $$ = $1"
| factor MUL term { $$ = $1 * $3; }
| factor DIV term { $$ = $1 / $3; }
;
term: NUMBER default $$ = $1<----I deleted "default $$ = $1"
| ABS term { $$ = $2 >= 0? $2 : - $2; }
;
%%
main(int argc, char **argv)
{
yyparse();
}
yyerror(char *s)
{
fprintf(stderr, "error: %s\n", s);
}


I am making a .y file in visual studio 2008 and i get the followin error

error LNK2019: unresolved external symbol _grammar1lex referenced in function _grammar1parse

Any ideas?
Last edited on
I only found a book from Oreilly media "Flex and Bison" about text processing.

THe code your posted has little C++ to it, in fact nothing of it afaik, only a little C on line 11 in printf and 3 #include <stdio.h>.

I think you're on the wrong language board.
Topic archived. No new replies allowed.