类org.antlr.runtime.RecognitionException源码实例Demo

下面列出了怎么用org.antlr.runtime.RecognitionException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: codebuff   文件: ParserATNFactory.java
protected void _createATN(Collection<Rule> rules) {
	createRuleStartAndStopATNStates();

	GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
	for (Rule r : rules) {
		// find rule's block
		GrammarAST blk = (GrammarAST)r.ast.getFirstChildWithType(ANTLRParser.BLOCK);
		CommonTreeNodeStream nodes = new CommonTreeNodeStream(adaptor,blk);
		ATNBuilder b = new ATNBuilder(nodes,this);
		try {
			setCurrentRuleName(r.name);
			Handle h = b.ruleBlock(null);
			rule(r.ast, r.name, h);
		}
		catch (RecognitionException re) {
			ErrorManager.fatalInternalError("bad grammar AST structure", re);
		}
	}
}
 
源代码2 项目: openbd-core   文件: CFMLLexer.java
public final void mFUNCTION() throws RecognitionException {
    try {
        int _type = FUNCTION;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:258:9: ( 'FUNCTION' )
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:258:11: 'FUNCTION'
        {
        match("FUNCTION"); 


        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
    }
}
 
源代码3 项目: binnavi   文件: MemoryExpressionLexer.java
public final void mOPERAND_MINUS() throws RecognitionException {
  try {
    final int _type = OPERAND_MINUS;
    final int _channel = DEFAULT_TOKEN_CHANNEL;
    // C:\\Dokumente und
    // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:29:15:
    // ( '-' )
    // C:\\Dokumente und
    // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:29:17:
    // '-'
    {
      match('-');

    }

    state.type = _type;
    state.channel = _channel;
  } finally {
  }
}
 
源代码4 项目: codebuff   文件: STLexerMessage.java
@Override
public String toString() {
    RecognitionException re = (RecognitionException)cause;
    int line = re.line;
    int charPos = re.charPositionInLine;
    if ( templateToken!=null ) {
        int templateDelimiterSize = 1;
        if ( templateToken.getType() ==GroupParser.BIGSTRING ) {
            templateDelimiterSize = 2;
        }
        line += templateToken.getLine()-1;
        charPos += templateToken.getCharPositionInLine()+templateDelimiterSize;
    }

    String filepos = line+":"+charPos;
    if ( srcName!=null ) {
        return srcName+" "+filepos+": "+String.format(error.message, msg);
    }
    return filepos+": "+String.format(error.message, msg);
}
 
源代码5 项目: kogito-runtimes   文件: JavaLexer.java
public final void mT__123() throws RecognitionException {
	try {
		int _type = T__123;
		int _channel = DEFAULT_TOKEN_CHANNEL;
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:104:8: ( '|=' )
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:104:10: '|='
		{
		match("|="); 

		}

		state.type = _type;
		state.channel = _channel;
	}
	finally {
		// do for sure before leaving
	}
}
 
源代码6 项目: openbd-core   文件: CFMLLexer.java
public final void mDIGIT() throws RecognitionException {
    try {
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:202:2: ( '\\u0030' .. '\\u0039' | '\\u0660' .. '\\u0669' | '\\u06f0' .. '\\u06f9' | '\\u0966' .. '\\u096f' | '\\u09e6' .. '\\u09ef' | '\\u0a66' .. '\\u0a6f' | '\\u0ae6' .. '\\u0aef' | '\\u0b66' .. '\\u0b6f' | '\\u0be7' .. '\\u0bef' | '\\u0c66' .. '\\u0c6f' | '\\u0ce6' .. '\\u0cef' | '\\u0d66' .. '\\u0d6f' | '\\u0e50' .. '\\u0e59' | '\\u0ed0' .. '\\u0ed9' | '\\u1040' .. '\\u1049' )
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:
        {
        if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='\u0660' && input.LA(1)<='\u0669')||(input.LA(1)>='\u06F0' && input.LA(1)<='\u06F9')||(input.LA(1)>='\u0966' && input.LA(1)<='\u096F')||(input.LA(1)>='\u09E6' && input.LA(1)<='\u09EF')||(input.LA(1)>='\u0A66' && input.LA(1)<='\u0A6F')||(input.LA(1)>='\u0AE6' && input.LA(1)<='\u0AEF')||(input.LA(1)>='\u0B66' && input.LA(1)<='\u0B6F')||(input.LA(1)>='\u0BE7' && input.LA(1)<='\u0BEF')||(input.LA(1)>='\u0C66' && input.LA(1)<='\u0C6F')||(input.LA(1)>='\u0CE6' && input.LA(1)<='\u0CEF')||(input.LA(1)>='\u0D66' && input.LA(1)<='\u0D6F')||(input.LA(1)>='\u0E50' && input.LA(1)<='\u0E59')||(input.LA(1)>='\u0ED0' && input.LA(1)<='\u0ED9')||(input.LA(1)>='\u1040' && input.LA(1)<='\u1049') ) {
            input.consume();

        }
        else {
            MismatchedSetException mse = new MismatchedSetException(null,input);
            recover(mse);
            throw mse;}


        }

    }
    finally {
    }
}
 
源代码7 项目: openbd-core   文件: CFMLLexer.java
public final void mTHREAD() throws RecognitionException {
    try {
        int _type = THREAD;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:315:7: ( 'THREAD' )
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:315:9: 'THREAD'
        {
        match("THREAD"); 


        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
    }
}
 
源代码8 项目: openbd-core   文件: CFMLLexer.java
public final void mEQUALSOP() throws RecognitionException {
    try {
        int _type = EQUALSOP;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:286:9: ( '=' )
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:286:11: '='
        {
        match('='); 

        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
    }
}
 
public final FastSimpleGenericEdifactDirectXMLParser.tag_name_return tag_name() throws RecognitionException {
  FastSimpleGenericEdifactDirectXMLParser.tag_name_return retval =
    new FastSimpleGenericEdifactDirectXMLParser.tag_name_return();
  retval.start = input.LT( 1 );

  try {
    // C:\\workspace-sts\\Kettle trunk -
    // restruct\\engine\\src\\org\\pentaho\\di\\trans\\steps\\edi2xml\\grammar\\
    // FastSimpleGenericEdifactDirectXML.g:112:11:
    // ( txt )
    // C:\\workspace-sts\\Kettle trunk -
    // restruct\\engine\\src\\org\\pentaho\\di\\trans\\steps\\edi2xml\\grammar\\
    // FastSimpleGenericEdifactDirectXML.g:112:13:
    // txt

    pushFollow( FOLLOW_txt_in_tag_name239 );
    txt();
    state._fsp--;
    retval.stop = input.LT( -1 );

  } catch ( RecognitionException e ) {
    // do not try to recover from parse errors, propagate the error instead
    throw e;
  }
  return retval;
}
 
源代码10 项目: usergrid   文件: QueryFilterLexer.java
public final void mT__30() throws RecognitionException {
    try {
        int _type = T__30;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // org/usergrid/persistence/query/QueryFilter.g:35:7: ( 'of' )
        // org/usergrid/persistence/query/QueryFilter.g:35:9: 'of'
        {
            match( "of" );
        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
    }
}
 
源代码11 项目: tracecompass   文件: CTFLexer.java
public final void mBOOLTOK() throws RecognitionException {
	try {
		int _type = BOOLTOK;
		int _channel = DEFAULT_TOKEN_CHANNEL;
		// org/eclipse/tracecompass/ctf/parser/CTFLexer.g:54:18: ( '_Bool' )
		// org/eclipse/tracecompass/ctf/parser/CTFLexer.g:54:20: '_Bool'
		{
		match("_Bool"); 

		}

		state.type = _type;
		state.channel = _channel;
	}
	finally {
		// do for sure before leaving
	}
}
 
源代码12 项目: kogito-runtimes   文件: JavaLexer.java
public final void mT__105() throws RecognitionException {
	try {
		int _type = T__105;
		int _channel = DEFAULT_TOKEN_CHANNEL;
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:86:8: ( 'short' )
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:86:10: 'short'
		{
		match("short"); 

		}

		state.type = _type;
		state.channel = _channel;
	}
	finally {
		// do for sure before leaving
	}
}
 
源代码13 项目: kogito-runtimes   文件: JavaLexer.java
public final void mT__119() throws RecognitionException {
	try {
		int _type = T__119;
		int _channel = DEFAULT_TOKEN_CHANNEL;
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:100:8: ( 'volatile' )
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:100:10: 'volatile'
		{
		match("volatile"); 

		}

		state.type = _type;
		state.channel = _channel;
	}
	finally {
		// do for sure before leaving
	}
}
 
源代码14 项目: codebuff   文件: STGroup.java
/** Load template stream into this group. {@code unqualifiedFileName} is
 *  {@code "a.st"}. The {@code prefix} is path from group root to
 *  {@code unqualifiedFileName} like {@code "/subdir"} if file is in
 *  {@code /subdir/a.st}.
 */

public CompiledST loadTemplateFile(String prefix, String unqualifiedFileName, CharStream templateStream) {
    GroupLexer lexer = new GroupLexer(templateStream);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    GroupParser parser = new GroupParser(tokens);
    parser.group = this;
    lexer.group = this;
    try {
        parser.templateDef(prefix);
    }
    catch (RecognitionException re) {
        errMgr.groupSyntaxError(ErrorType.SYNTAX_ERROR, unqualifiedFileName, re, re.getMessage());
    }

    String templateName = Misc.getFileNameNoSuffix(unqualifiedFileName);
    if ( prefix!=null && prefix.length()>0 ) templateName = prefix+templateName;
    CompiledST impl = rawGetTemplate(templateName);
    impl.prefix = prefix;
    return impl;
}
 
源代码15 项目: openbd-core   文件: CFMLLexer.java
public final void mTHAN() throws RecognitionException {
    try {
        int _type = THAN;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:238:5: ( 'THAN' )
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:238:7: 'THAN'
        {
        match("THAN"); 


        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
    }
}
 
源代码16 项目: binnavi   文件: ConditionLexer.java
public final void mEQ_SIGN() throws RecognitionException {
  try {
    final int _type = EQ_SIGN;
    final int _channel = DEFAULT_TOKEN_CHANNEL;
    // C:\\Dokumente und
    // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:35:10:
    // ( '==' )
    // C:\\Dokumente und
    // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:35:13:
    // '=='
    {
      match("==");


    }

    state.type = _type;
    state.channel = _channel;
  } finally {
  }
}
 
源代码17 项目: spork   文件: TestQueryParser.java
@Test
public void test() throws IOException, RecognitionException  {
    CharStream input = new QueryParserFileStream( "test/org/apache/pig/parser/TestParser.pig" );
    QueryLexer lexer = new QueryLexer(input);
    CommonTokenStream tokens = new  CommonTokenStream(lexer);

    QueryParser parser = new QueryParser(tokens);
    QueryParser.query_return result = parser.query();

    Tree ast = (Tree)result.getTree();

    System.out.println( ast.toStringTree() );
    TreePrinter.printTree( (CommonTree)ast, 0 );
    Assert.assertEquals( 0, lexer.getNumberOfSyntaxErrors() );
    Assert.assertEquals( 0, parser.getNumberOfSyntaxErrors() );
}
 
源代码18 项目: kogito-runtimes   文件: JavaLexer.java
public final void mT__32() throws RecognitionException {
	try {
		int _type = T__32;
		int _channel = DEFAULT_TOKEN_CHANNEL;
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:13:7: ( '%=' )
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:13:9: '%='
		{
		match("%="); 

		}

		state.type = _type;
		state.channel = _channel;
	}
	finally {
		// do for sure before leaving
	}
}
 
源代码19 项目: kogito-runtimes   文件: JavaLexer.java
public final void mT__35() throws RecognitionException {
	try {
		int _type = T__35;
		int _channel = DEFAULT_TOKEN_CHANNEL;
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:16:7: ( '&=' )
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:16:9: '&='
		{
		match("&="); 

		}

		state.type = _type;
		state.channel = _channel;
	}
	finally {
		// do for sure before leaving
	}
}
 
源代码20 项目: usergrid   文件: QueryFilterParser.java
public final QueryFilterParser.property_return property() throws RecognitionException {
    QueryFilterParser.property_return retval = new QueryFilterParser.property_return();
    retval.start = input.LT( 1 );

    try {
        // org/usergrid/persistence/query/QueryFilter.g:102:2: ( ( ID ) )
        // org/usergrid/persistence/query/QueryFilter.g:102:5: ( ID )
        {
            // org/usergrid/persistence/query/QueryFilter.g:102:5: ( ID )
            // org/usergrid/persistence/query/QueryFilter.g:102:6: ID
            {
                match( input, ID, FOLLOW_ID_in_property597 );
            }
        }

        retval.stop = input.LT( -1 );
    }
    catch ( RecognitionException re ) {
        reportError( re );
        recover( input, re );
    }
    finally {
    }
    return retval;
}
 
源代码21 项目: openbd-core   文件: CFMLLexer.java
public final void mTO() throws RecognitionException {
    try {
        int _type = TO;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:241:3: ( 'TO' )
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:241:5: 'TO'
        {
        match("TO"); 


        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
    }
}
 
源代码22 项目: codebuff   文件: STGroup.java
/** Load template stream into this group. {@code unqualifiedFileName} is
 *  {@code "a.st"}. The {@code prefix} is path from group root to
 *  {@code unqualifiedFileName} like {@code "/subdir"} if file is in
 *  {@code /subdir/a.st}.
 */

public CompiledST loadTemplateFile(String prefix, String unqualifiedFileName, CharStream templateStream) {
    GroupLexer lexer = new GroupLexer(templateStream);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    GroupParser parser = new GroupParser(tokens);
    parser.group = this;
    lexer.group = this;
    try {
        parser.templateDef(prefix);
    }
    catch (RecognitionException re) {
        errMgr.groupSyntaxError(ErrorType.SYNTAX_ERROR, unqualifiedFileName, re, re.getMessage());
    }

    String templateName = Misc.getFileNameNoSuffix(unqualifiedFileName);
    if ( prefix !=null && prefix.length()>0 ) templateName = prefix+templateName;
    CompiledST impl = rawGetTemplate(templateName);
    impl.prefix = prefix;
    return impl;
}
 
源代码23 项目: codebuff   文件: STLexer.java
void LINEBREAK() {
    match('\\'); // only kill 2nd \ as ESCAPE() kills first one
    match(delimiterStopChar);
    while ( c==' ' || c=='\t' ) consume(); // scarf WS after <\\>
    if ( c==EOF ) {
        RecognitionException re = new RecognitionException(input);
        re.line = input.getLine();
        re.charPositionInLine = input.getCharPositionInLine();
        errMgr.lexerError(input.getSourceName(), "Missing newline after newline escape <\\\\>", templateToken, re);
        return;
    }

    if ( c=='\r' ) consume();
    match('\n');
    while ( c==' ' || c=='\t' ) consume(); // scarf any indent
}
 
源代码24 项目: codebuff   文件: STGroupCompiletimeMessage.java
@Override
public String toString() {
    RecognitionException re = (RecognitionException)cause;
    int line = 0;
    int charPos = -1;
    if ( token!=null ) {
        line = token.getLine();
        charPos = token.getCharPositionInLine();
    }
    else if ( re!=null ) {
             line = re.line;
             charPos = re.charPositionInLine;
    }
    String filepos = line+":"+charPos;
    if ( srcName!=null ) {
        return srcName+" "+filepos+": "+String.format(error.message, arg, arg2);
    }
    return filepos+": "+String.format(error.message, arg, arg2);
}
 
源代码25 项目: binnavi   文件: FilterLexer.java
public final void mT__9() throws RecognitionException {
  try {
    final int _type = T__9;
    final int _channel = DEFAULT_TOKEN_CHANNEL;
    // C:\\Dokumente und
    // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\filter\\Filter.g:3:6: (
    // '(' )
    // C:\\Dokumente und
    // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\filter\\Filter.g:3:8:
    // '('
    {
      match('(');

    }

    state.type = _type;
    state.channel = _channel;
  } finally {
  }
}
 
源代码26 项目: openbd-core   文件: CFMLLexer.java
public final void mLOCK() throws RecognitionException {
    try {
        int _type = LOCK;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:314:5: ( 'LOCK' )
        // E:\\BlueDragon\\OpenBD_ANTLR\\src\\com\\naryx\\tagfusion\\cfm\\parser\\CFML.g:314:7: 'LOCK'
        {
        match("LOCK"); 


        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
    }
}
 
源代码27 项目: kogito-runtimes   文件: JavaLexer.java
public final void mT__52() throws RecognitionException {
	try {
		int _type = T__52;
		int _channel = DEFAULT_TOKEN_CHANNEL;
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:33:7: ( ';' )
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:33:9: ';'
		{
		match(';'); 
		}

		state.type = _type;
		state.channel = _channel;
	}
	finally {
		// do for sure before leaving
	}
}
 
源代码28 项目: slr-toolkit   文件: InternalTaxonomyLexer.java
public final void mT__10() throws RecognitionException {
    try {
        int _type = T__10;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // InternalTaxonomy.g:12:7: ( '{' )
        // InternalTaxonomy.g:12:9: '{'
        {
        match('{'); 

        }

        state.type = _type;
        state.channel = _channel;
    }
    finally {
    }
}
 
源代码29 项目: kogito-runtimes   文件: JavaLexer.java
public final void mT__104() throws RecognitionException {
	try {
		int _type = T__104;
		int _channel = DEFAULT_TOKEN_CHANNEL;
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:85:8: ( 'return' )
		// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:85:10: 'return'
		{
		match("return"); 

		}

		state.type = _type;
		state.channel = _channel;
	}
	finally {
		// do for sure before leaving
	}
}
 
源代码30 项目: codebuff   文件: STLexerMessage.java
@Override
public String toString() {
    RecognitionException re = (RecognitionException)cause;
    int line = re.line;
    int charPos = re.charPositionInLine;
    if ( templateToken!=null ) {
        int templateDelimiterSize = 1;
        if ( templateToken.getType()==GroupParser.BIGSTRING ) {
            templateDelimiterSize = 2;
        }
        line += templateToken.getLine()-1;
        charPos += templateToken.getCharPositionInLine()+templateDelimiterSize;
    }

    String filepos = line+":"+charPos;
    if ( srcName!=null ) {
        return srcName+" "+filepos+": "+String.format(error.message, msg);
    }
    return filepos+": "+String.format(error.message, msg);
}