org.antlr.runtime.BaseRecognizer Java Examples

The following examples show how to use org.antlr.runtime.BaseRecognizer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ErrorCollector.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void syntaxError(BaseRecognizer recognizer, String[] tokenNames, RecognitionException e)
{
    String hdr = recognizer.getErrorHeader(e);
    String msg = recognizer.getErrorMessage(e, tokenNames);

    StringBuilder builder = new StringBuilder().append(hdr)
            .append(' ')
            .append(msg);

    if (recognizer instanceof Parser)
        appendQuerySnippet((Parser) recognizer, builder);

    errorMsgs.add(builder.toString());
}
 
Example #2
Source File: CFMLLexer.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
public DFA21(BaseRecognizer recognizer) {
    this.recognizer = recognizer;
    this.decisionNumber = 21;
    this.eot = DFA21_eot;
    this.eof = DFA21_eof;
    this.min = DFA21_min;
    this.max = DFA21_max;
    this.accept = DFA21_accept;
    this.special = DFA21_special;
    this.transition = DFA21_transition;
}
 
Example #3
Source File: QueryFilterLexer.java    From usergrid with Apache License 2.0 5 votes vote down vote up
public DFA19( BaseRecognizer recognizer ) {
    this.recognizer = recognizer;
    this.decisionNumber = 19;
    this.eot = DFA19_eot;
    this.eof = DFA19_eof;
    this.min = DFA19_min;
    this.max = DFA19_max;
    this.accept = DFA19_accept;
    this.special = DFA19_special;
    this.transition = DFA19_transition;
}
 
Example #4
Source File: QueryFilterLexer.java    From usergrid with Apache License 2.0 5 votes vote down vote up
public DFA11( BaseRecognizer recognizer ) {
    this.recognizer = recognizer;
    this.decisionNumber = 11;
    this.eot = DFA11_eot;
    this.eof = DFA11_eof;
    this.min = DFA11_min;
    this.max = DFA11_max;
    this.accept = DFA11_accept;
    this.special = DFA11_special;
    this.transition = DFA11_transition;
}
 
Example #5
Source File: QueryParserDriver.java    From spork with Apache License 2.0 5 votes vote down vote up
private static void checkError(BaseRecognizer recognizer)
        throws ParserException {
    int errorCount = recognizer.getNumberOfSyntaxErrors();
    if (0 < errorCount)
        throw new ParserException("Encountered " + errorCount
                + " parsing errors in the query");
}
 
Example #6
Source File: RecognizerErrorHandler.java    From legstar-core2 with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Format an error message as expected by ANTLR. It is basically the
 * same error message that ANTL BaseRecognizer generates with some
 * additional data.
 * Also used to log debugging information.
 * @param log the logger to use at debug time
 * @param recognizer the lexer or parser who generated the error
 * @param e the exception that occured
 * @param superMessage the error message that the super class generated
 * @param tokenNames list of token names
 * @return a formatted error message
 */
public static String getErrorMessage(
        final Logger log,
        final BaseRecognizer recognizer,
        final RecognitionException e,
        final String superMessage,
        final String[] tokenNames) {
    if (log.isDebugEnabled()) {
        List < ? > stack = BaseRecognizer.getRuleInvocationStack(
                e, recognizer.getClass().getSuperclass().getName());
        String debugMsg = recognizer.getErrorHeader(e)
            + " " + e.getClass().getSimpleName()
            + ": " + superMessage
            + ":";
        if (e instanceof NoViableAltException) {
            NoViableAltException nvae = (NoViableAltException) e;
            debugMsg += " (decision=" + nvae.decisionNumber
            + " state=" + nvae.stateNumber + ")"
            + " decision=<<" + nvae.grammarDecisionDescription + ">>";
        } else if (e instanceof UnwantedTokenException) {
            UnwantedTokenException ute = (UnwantedTokenException) e;
            debugMsg += " (unexpected token=" + toString(ute.getUnexpectedToken(), tokenNames) + ")";

        } else if (e instanceof EarlyExitException) {
            EarlyExitException eea = (EarlyExitException) e;
            debugMsg += " (decision=" + eea.decisionNumber + ")";
        }
        debugMsg += " ruleStack=" + stack.toString();
        log.debug(debugMsg);
    }

    return makeUserMsg(e, superMessage);
}
 
Example #7
Source File: CFMLLexer.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
public DFA24(BaseRecognizer recognizer) {
    this.recognizer = recognizer;
    this.decisionNumber = 24;
    this.eot = DFA24_eot;
    this.eof = DFA24_eof;
    this.min = DFA24_min;
    this.max = DFA24_max;
    this.accept = DFA24_accept;
    this.special = DFA24_special;
    this.transition = DFA24_transition;
}
 
Example #8
Source File: JavaLexer.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public DFA16(BaseRecognizer recognizer) {
	this.recognizer = recognizer;
	this.decisionNumber = 16;
	this.eot = DFA16_eot;
	this.eof = DFA16_eof;
	this.min = DFA16_min;
	this.max = DFA16_max;
	this.accept = DFA16_accept;
	this.special = DFA16_special;
	this.transition = DFA16_transition;
}
 
Example #9
Source File: InternalTaxonomyLexer.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
public DFA5(BaseRecognizer recognizer) {
    this.recognizer = recognizer;
    this.decisionNumber = 5;
    this.eot = DFA5_eot;
    this.eof = DFA5_eof;
    this.min = DFA5_min;
    this.max = DFA5_max;
    this.accept = DFA5_accept;
    this.special = DFA5_special;
    this.transition = DFA5_transition;
}
 
Example #10
Source File: InternalTaxonomyLexer.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
public DFA5(BaseRecognizer recognizer) {
    this.recognizer = recognizer;
    this.decisionNumber = 5;
    this.eot = DFA5_eot;
    this.eof = DFA5_eof;
    this.min = DFA5_min;
    this.max = DFA5_max;
    this.accept = DFA5_accept;
    this.special = DFA5_special;
    this.transition = DFA5_transition;
}
 
Example #11
Source File: FilterLexer.java    From binnavi with Apache License 2.0 5 votes vote down vote up
public DFA1(final BaseRecognizer recognizer) {
  this.recognizer = recognizer;
  this.decisionNumber = 1;
  this.eot = DFA1_eot;
  this.eof = DFA1_eof;
  this.min = DFA1_min;
  this.max = DFA1_max;
  this.accept = DFA1_accept;
  this.special = DFA1_special;
  this.transition = DFA1_transition;
}
 
Example #12
Source File: JavaLexer.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public DFA32(BaseRecognizer recognizer) {
	this.recognizer = recognizer;
	this.decisionNumber = 32;
	this.eot = DFA32_eot;
	this.eof = DFA32_eof;
	this.min = DFA32_min;
	this.max = DFA32_max;
	this.accept = DFA32_accept;
	this.special = DFA32_special;
	this.transition = DFA32_transition;
}
 
Example #13
Source File: MemoryExpressionLexer.java    From binnavi with Apache License 2.0 5 votes vote down vote up
public DFA4(final BaseRecognizer recognizer) {
  this.recognizer = recognizer;
  decisionNumber = 4;
  eot = DFA4_eot;
  eof = DFA4_eof;
  min = DFA4_min;
  max = DFA4_max;
  accept = DFA4_accept;
  special = DFA4_special;
  transition = DFA4_transition;
}
 
Example #14
Source File: ConditionLexer.java    From binnavi with Apache License 2.0 5 votes vote down vote up
public DFA4(final BaseRecognizer recognizer) {
  this.recognizer = recognizer;
  decisionNumber = 4;
  eot = DFA4_eot;
  eof = DFA4_eof;
  min = DFA4_min;
  max = DFA4_max;
  accept = DFA4_accept;
  special = DFA4_special;
  transition = DFA4_transition;
}
 
Example #15
Source File: CTFLexer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
public DFA30(BaseRecognizer recognizer) {
	this.recognizer = recognizer;
	this.decisionNumber = 30;
	this.eot = DFA30_eot;
	this.eof = DFA30_eof;
	this.min = DFA30_min;
	this.max = DFA30_max;
	this.accept = DFA30_accept;
	this.special = DFA30_special;
	this.transition = DFA30_transition;
}
 
Example #16
Source File: IgnoreFirstEntranceUnorderedGroupHelper.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initializeWith(BaseRecognizer recognizer) {
	helper.initializeWith(recognizer);
}
 
Example #17
Source File: UnorderedGroupHelper.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected BaseRecognizer getRecognizer() {
	return recognizer;
}
 
Example #18
Source File: UnorderedGroupHelper.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initializeWith(BaseRecognizer recognizer) {
	this.recognizer = recognizer;
}
 
Example #19
Source File: ErrorCollector.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void syntaxError(BaseRecognizer recognizer, String errorMsg)
{
    errorMsgs.add(errorMsg);
}
 
Example #20
Source File: CqlParserTest.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
@Override
public void syntaxError(BaseRecognizer recognizer, String[] tokenNames, RecognitionException e)
{
    count++;
}
 
Example #21
Source File: CqlParserTest.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
@Override
public void syntaxError(BaseRecognizer recognizer, String errorMsg)
{
    count++;
}
 
Example #22
Source File: IUnorderedGroupHelper.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initializeWith(BaseRecognizer recognizer) {
	// ignore
}
 
Example #23
Source File: ParsingFailureException.java    From spork with Apache License 2.0 4 votes vote down vote up
public ParsingFailureException(Class<? extends BaseRecognizer> clazz) {
    super( "Parsing failures dected by " + clazz.getSimpleName() );
    this.parsingClass = clazz;
}
 
Example #24
Source File: ParsingFailureException.java    From spork with Apache License 2.0 4 votes vote down vote up
public Class<? extends BaseRecognizer> getParsingClass() {
    return parsingClass;
}
 
Example #25
Source File: ErrorListener.java    From stratio-cassandra with Apache License 2.0 2 votes vote down vote up
/**
 * Invoked when a syntax error occurs.
 *
 * @param recognizer the parser or lexer that emitted the error
 * @param tokenNames the token names
 * @param e the exception
 */
void syntaxError(BaseRecognizer recognizer, String[] tokenNames, RecognitionException e);
 
Example #26
Source File: ErrorListener.java    From stratio-cassandra with Apache License 2.0 2 votes vote down vote up
/**
 * Invoked when a syntax error with a specified message occurs.
 *
 * @param recognizer the parser or lexer that emitted the error
 * @param errorMsg the error message
 */
void syntaxError(BaseRecognizer recognizer, String errorMsg);
 
Example #27
Source File: IUnorderedGroupHelper.java    From xtext-core with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Initializes this helper with the given recognizer.
 */
void initializeWith(BaseRecognizer recognizer);