Flex/Bison: 构建示例工程生成Cpp时出错
Flex/Bison: Error when building a sample project to generate Cpp
我正在尝试使用 flex 和 bison 生成 Cpp(不是 C)。我从 GitHub (https://github.com/ezaquarii/bison-flex-cpp-example) 获得了示例代码并尝试构建它。
这里是Makefile内容
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
当我运行命令make时,我得到以下错误
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
这是我的野牛版本(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>
有人可以告诉我出了什么问题吗?
我更新了我的 bison 版本。
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,感谢修复。
我正在尝试使用 flex 和 bison 生成 Cpp(不是 C)。我从 GitHub (https://github.com/ezaquarii/bison-flex-cpp-example) 获得了示例代码并尝试构建它。
这里是Makefile内容
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
当我运行命令make时,我得到以下错误
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
这是我的野牛版本(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>
有人可以告诉我出了什么问题吗?
我更新了我的 bison 版本。
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,感谢修复。