本文整理汇总了Java中org.antlr.v4.runtime.ANTLRErrorStrategy类的典型用法代码示例。如果您正苦于以下问题:Java ANTLRErrorStrategy类的具体用法?Java ANTLRErrorStrategy怎么用?Java ANTLRErrorStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ANTLRErrorStrategy类属于org.antlr.v4.runtime包,在下文中一共展示了ANTLRErrorStrategy类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.antlr.v4.runtime.ANTLRErrorStrategy; //导入依赖的package包/类
@Override
protected void configure() {
bind(Importer.class).to(ImporterImpl.class);
bind(FileDescriptorLoader.class).to(FileDescriptorLoaderImpl.class);
bind(ANTLRErrorListener.class).to(ParseErrorLogger.class);
bind(ANTLRErrorStrategy.class).to(BailErrorStrategy.class);
bind(ProtoContext.class)
.annotatedWith(Names.named(DESCRIPTOR_PROTO))
.toProvider(DefaultDescriptorProtoProvider.class);
Multibinder<ProtoContextPostProcessor> postProcessors = Multibinder
.newSetBinder(binder(), ProtoContextPostProcessor.class);
postProcessors.addBinding().to(ImportsPostProcessor.class);
postProcessors.addBinding().to(TypeRegistratorPostProcessor.class);
postProcessors.addBinding().to(TypeResolverPostProcessor.class);
postProcessors.addBinding().to(ExtensionRegistratorPostProcessor.class);
postProcessors.addBinding().to(OptionsPostProcessor.class);
postProcessors.addBinding().to(UserTypeValidationPostProcessor.class);
install(new FactoryModuleBuilder()
.implement(FileReader.class, MultiPathFileReader.class)
.build(FileReaderFactory.class));
}
示例2: syntaxError
import org.antlr.v4.runtime.ANTLRErrorStrategy; //导入依赖的package包/类
public void syntaxError(Recognizer<?, ?> aRecognizer,
Object aOffendingSymbol, int aLine, int aCharIndex,
String aMessage, RecognitionException aException) {
ANTLRErrorStrategy errorHandler = myParser.getErrorHandler();
if (LOGGER.isWarnEnabled()) {
LOGGER.warn(aMessage + " [" + aLine + ":" + aCharIndex + "]");
}
/*
* Setting the lexer exception in the parser since I don't see a
* getNumberOfSyntaxErrors() method in the lexer (like in antlr3) and
* the lexer's errors aren't being reported by parser's method
*
* I may just be missing the correct way this should be handled(?)
*/
if (aException instanceof LexerNoViableAltException) {
NoViableAltException exception = new NoViableAltException(myParser);
errorHandler.reportError(myParser, exception);
}
else {
errorHandler.reportError(myParser, aException);
}
}
示例3: Builder
import org.antlr.v4.runtime.ANTLRErrorStrategy; //导入依赖的package包/类
Builder(final ANTLRErrorStrategy errorStrategy, final IBaseProtoErrorListener errorListener,
final FileDescriptors.Builder fileBuilder) {
dirs = new LinkedHashMap<URI, Set<URI>>();
sources = new LinkedHashMap<URI, String>();
sourceProtos = new ArrayList<FileDescriptorProto>();
this.errorStrategy = Objects.requireNonNull(errorStrategy);
this.errorListener = Objects.requireNonNull(errorListener);
this.fileBuilder = Objects.requireNonNull(fileBuilder);
}
示例4: ErrorStrategy
import org.antlr.v4.runtime.ANTLRErrorStrategy; //导入依赖的package包/类
ErrorStrategy(ANTLRErrorStrategy delegate) {
this.delegate = delegate;
}
示例5: setErrorStrategy
import org.antlr.v4.runtime.ANTLRErrorStrategy; //导入依赖的package包/类
/**
* Set the error handler strategy for ANTLR. If not set, {@link DefaultErrorStrategy} is used.
*
* @param errorStrategy ANTLR error strategy
* @return builder
*/
public Builder setErrorStrategy(ANTLRErrorStrategy errorStrategy) {
this.errorStrategy = errorStrategy;
return this;
}