Flex/Bison:构建示例项目以生成 CPP 时出错

Flex/Bison: Error when building a sample project to generate Cpp

本文关键字:CPP 出错 项目 Bison 构建 Flex      更新时间:2023-10-16

我正在尝试使用flex和bison生成Cpp(不是C(。我从GitHub(https://github.com/ezaquarii/bison-flex-cpp-example(获得了一个示例代码并尝试构建它。

这是生成文件内容

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

当我运行命令制作时,出现以下错误

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操作系统(

bison --version
bison++ Version 1.21.9-1, adapted from GNU bison by coetmeur@icdc.fr
Maintained by Magnus Ekdahl <magnus@debian.org>

有人可以告诉我出了什么问题吗?

我更新了我的野牛版本。

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,感谢您的修复。