有没有一种简单的方法来终止一个lexer?
有一些标记我还不想处理。但是,如果输入中包含这些标记,我也希望Lexer发出警报。我的简单策略是在一个动作中抛出一个RuntimeException:
CHARIZING: '#@' {throw new RuntimeException("charizing op not supported yet");};但是操作会产生编译错误,因为生成的Lexer在操作之后有一个中断命令,Java编译器抱怨中断是一个无法到达的语句。
CPPDefineLexer.java:118: error: unreachable statement
case 1: throw new RuntimeException("charizing op not supported y
et"); break;是否有一个简单的策略来终止一个雷克萨斯?
发布于 2014-03-19 14:28:10
您可以欺骗编译器:
CHARIZING
: '#@'
{
if (true) { throw new RuntimeException("charizing op not supported yet"); }
}
;https://stackoverflow.com/questions/22507775
复制相似问题