I'm trying to generate Cpp (not C) using flex and bison. I got a sample code from GitHub (https://github.com/ezaquarii/bison-flex-cpp-example) and trying to build it.
Here is Makefile content
all:
flex -o scanner.cpp scanner.l
bison -o parser.cpp parser.y
g++ -g main.cpp scanner.cpp parser.cpp interpreter.cpp command.cpp -o a.out
clean:
rm -rf scanner.cpp
rm -rf parser.cpp parser.hpp location.hh position.hh stack.hh
rm -rf a.out
When I run command make, I get the following error
flex -o scanner.cpp scanner.l
bison -o parser.cpp parser.y
"parser.y", line 29: junk after `%%' in definition section
Makefile:2: recipe for target 'all' failed
make: *** [all] Segmentation fault
Here is my bison version (Linux OS)
bison --version
bison++ Version 1.21.9-1, adapted from GNU bison by coetmeur@icdc.fr
Maintained by Magnus Ekdahl <magnus@debian.org>
May someone tell me what is going wrong ?
I updated my bison version.
bison --version
bison (GNU Bison) 3.0.4
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@user6556709, thanks for the fix.