Example usage for org.antlr.v4.runtime.atn PredictionMode LL_EXACT_AMBIG_DETECTION

List of usage examples for org.antlr.v4.runtime.atn PredictionMode LL_EXACT_AMBIG_DETECTION

Introduction

In this page you can find the example usage for org.antlr.v4.runtime.atn PredictionMode LL_EXACT_AMBIG_DETECTION.

Prototype

PredictionMode LL_EXACT_AMBIG_DETECTION

To view the source code for org.antlr.v4.runtime.atn PredictionMode LL_EXACT_AMBIG_DETECTION.

Click Source Link

Document

The LL(*) prediction mode with exact ambiguity detection.

Usage

From source file:com.blazebit.persistence.impl.expression.AbstractTestExpressionFactory.java

License:Apache License

@Override
protected void configureParser(JPQLSelectExpressionParser parser) {
    if (LOG.isLoggable(Level.FINEST)) {
        parser.setTrace(true);/*from   w w w . j ava  2  s  .  c o  m*/
    }

    parser.removeErrorListeners();
    parser.addErrorListener(ERR_LISTENER);
    parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);
}

From source file:org.openpplsoft.pt.peoplecode.PeopleCodeProg.java

License:MIT License

public void lexAndParse() {

    if (this.haveLexedAndParsed) {
        return;//from  www.  j a  v a2 s. c o  m
    }
    this.haveLexedAndParsed = true;

    log.debug("Lexing and parsing: {}", this.getDescriptor());

    /*
     * Write program text to cache if necessary.
     */
    if (System.getProperty("cacheProgText").equals("true")) {
        try (final BufferedWriter writer = new BufferedWriter(
                new FileWriter(new File("/home/opsdev/ops/cache/" + this.getDescriptor() + ".pc")))) {
            writer.write(this.programText);
        } catch (final IOException ioe) {
            throw new OPSVMachRuntimeException(ioe.getMessage(), ioe);
        }
    }

    InputStream progTextInputStream = new ByteArrayInputStream(this.programText.getBytes());

    try {
        final ANTLRInputStream input = new ANTLRInputStream(progTextInputStream);
        final NoErrorTolerancePeopleCodeLexer lexer = new NoErrorTolerancePeopleCodeLexer(input);
        this.tokenStream = new CommonTokenStream(lexer);
        final PeopleCodeParser parser = new PeopleCodeParser(this.tokenStream);

        parser.removeErrorListeners();
        parser.addErrorListener(new OPSDiagErrorListener());
        parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);
        parser.setErrorHandler(new OPSErrorStrategy());

        this.parseTree = parser.program();
    } catch (final IOException ioe) {
        throw new OPSVMachRuntimeException(ioe.getMessage(), ioe);
    }

    //log.debug(">>> Parse Tree >>>>>>>>>>>>");
    //log.debug(this.parseTree.toStringTree(parser));
    //log.debug("====================================================");
}