I have a project for a school where we need to use flex and bison. I want to use C ++ to have access to the STL and my own classes that I wrote. We were provided with the following Makefile:
CC = gcc CFLAGS = -g OBJs = parse.tab.o symtab.o attr.o lex.yy.o default: parser parser: ${OBJs} ${CC} ${CFLAGS} ${OBJs} -o parser -lfl lex.yy.c: scan.l parse.tab.h attr.h flex -i scan.l parse.tab.c: parse.y attr.h symtab.h bison -dv parse.y parse.tab.h: parse.tab.c clean: rm -f parser lex.yy.c *.o parse.tab.[ch] parse.output depend: makedepend -I. *.c
scan.l and parse.y have some initial flex / bison properties for generating a scanner and analyzer. I need to add my own materials to these files. symtab {h, c} must be a character table implementation. attr. {h, c} - for attribute magic. I want to make a symtab.c.cc file to use STL. I also have other reasons for using C ++.
I tried using the parse.ypp file to create a .cpp file. But the problem is that I am not getting the correct .h file. I modified the Makefile to look like this:
CC = g++
Can someone tell me what I need to add or do to make C ++ work? It should be noted that I added some things to the .y (or .ypp) file to deal with the transition from C to C ++. In particular, I had to declare something like extern. My main problem is that when I run make, scan.l has a bunch of syntax errors, and they seem to be related to the fact that it cannot include parse.tab.h (because it is never generated).
source share