Java 类org.antlr.v4.runtime.ANTLRErrorStrategy 实例源码

项目:protostuff-compiler    文件:ParserModule.java   
@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));
}
项目:freelib-edtf    文件:ParserErrorListener.java   
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);
    }
}
项目:protobuf-el    文件:ProtoFiles.java   
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);
}
项目:protobuf-el    文件:ProtoFiles.java   
Builder(final ANTLRErrorStrategy errorStrategy, final IBaseProtoErrorListener errorListener) {
  this(errorStrategy, errorListener, FileDescriptors.newBuilder());
}
项目:contracts    文件:AstBuilder.java   
ErrorStrategy(ANTLRErrorStrategy delegate) {
    this.delegate = delegate;
}
项目:gdl    文件:GDLHandler.java   
/**
 * 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;
}