我正在尝试在词法分析器中实现一个include特性,这样当它点击'#include‘filename’时,它将切换到该文件的一个流。我使用如下所示的lexer操作使其正常工作。antlr4::ANTLRInputStream new_source(new_file); // new file is an open ifstream
int pos = _input->indexstd::make_pair(_input,pos)); /
在ANTLR4中,生成的词法分析器为每个令牌包含一个公共字段,其中字段的类型是一个简单的'int‘。为什么ANTLR4不使用枚举呢?或者有没有办法让它使用枚举呢? 这是我想不到的一个简化例子。XLexer包含 public class XLexer extends Lexer{ A(1), B(2)} 这对于转储令牌时的</e