本文整理汇总了Java中org.antlr.v4.tool.GrammarSyntaxMessage类的典型用法代码示例。如果您正苦于以下问题:Java GrammarSyntaxMessage类的具体用法?Java GrammarSyntaxMessage怎么用?Java GrammarSyntaxMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GrammarSyntaxMessage类属于org.antlr.v4.tool包,在下文中一共展示了GrammarSyntaxMessage类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: error
import org.antlr.v4.tool.GrammarSyntaxMessage; //导入依赖的package包/类
@Override
public void error(ANTLRMessage antlrm) {
Token offendingToken = null;
RecognitionException e = null;
if (antlrm.getCause() instanceof RecognitionException) {
e = (RecognitionException)antlrm.getCause();
offendingToken = e.token;
}
if (antlrm instanceof GrammarSyntaxMessage) {
e = ((GrammarSyntaxMessage)antlrm).getCause();
offendingToken = ((GrammarSyntaxMessage)antlrm).offendingToken;
} else if (antlrm instanceof GrammarSemanticsMessage) {
offendingToken = ((GrammarSemanticsMessage)antlrm).offendingToken;
}
ST messageTemplate = tool.errMgr.getMessageTemplate(antlrm);
String outputMessage = messageTemplate.render();
syntaxErrors.add(new AntlrSyntaxErrorV3(getSnapshot(offendingToken), offendingToken, e, outputMessage, Severity.ERROR));
}
示例2: warning
import org.antlr.v4.tool.GrammarSyntaxMessage; //导入依赖的package包/类
@Override
public void warning(ANTLRMessage antlrm) {
Token offendingToken = null;
RecognitionException e = null;
if (antlrm.getCause() instanceof RecognitionException) {
e = (RecognitionException)antlrm.getCause();
offendingToken = e.token;
}
if (antlrm instanceof GrammarSyntaxMessage) {
offendingToken = ((GrammarSyntaxMessage)antlrm).offendingToken;
} else if (antlrm instanceof GrammarSemanticsMessage) {
offendingToken = ((GrammarSemanticsMessage)antlrm).offendingToken;
}
ST messageTemplate = tool.errMgr.getMessageTemplate(antlrm);
String outputMessage = messageTemplate.render();
syntaxErrors.add(new AntlrSyntaxErrorV3(getSnapshot(offendingToken), offendingToken, e, outputMessage, Severity.WARNING));
}