我生成了一个带有antlr4 c++目标的c++ python解析器,但当我尝试使用它时,出现了以下错误: Python3Lexer.h:48:5: error:在程序中丢失了‘@’
这个Python3Lexpen.h(用Antlr4 c++目标生成)看起来不好吗?错误行是@Override,它是一个java关键字,而不是c++!你知道我做错了什么吗?
下面是Python3Lexpen.h的样子:
#include "antlr4-runtime.h"
class Python3Lexer : public antlr4::Lexer {
public:
(...)
Python3Lexer(antlr4::CharStream *input);
~Python3Lexer();
// A queue where extra tokens are pushed on (see the NEWLINE lexer rule).
private java.util.LinkedList<Token> tokens = new java.util.LinkedList<>();
// The stack that keeps track of the indentation level.
private java.util.Stack<Integer> indents = new java.util.Stack<>();
// The amount of opened braces, brackets and parenthesis.
private int opened = 0;
// The most recently produced token.
private Token lastToken = null;
@Override
public void emit(Token t) {
super.setToken(t);
tokens.offer(t);
}
@Override
public Token nextToken() {
(...)发布于 2019-02-19 23:11:54
如果您查看正在使用的语法文件(已在注释中链接),您将看到它包含Java代码。为了在C++中使用这种语法,首先必须将Java代码转换为C++。
https://stackoverflow.com/questions/54764600
复制相似问题