⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javarecognizer.java

📁 drools 一个开放源码的规则引擎
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
// $ANTLR 2.7.2: "java.g" -> "JavaRecognizer.java"$

package org.drools.semantics.java.parser;

import antlr.ASTFactory;
import antlr.ASTPair;
import antlr.NoViableAltException;
import antlr.ParserSharedInputState;
import antlr.RecognitionException;
import antlr.Token;
import antlr.TokenBuffer;
import antlr.TokenStream;
import antlr.TokenStreamException;
import antlr.collections.AST;
import antlr.collections.impl.ASTArray;
import antlr.collections.impl.BitSet;

/**
 * Java 1.3 Recognizer.
 * 
 * This grammar is in the PUBLIC DOMAIN
 * 
 * @author John Mitchell johnm@non.net
 * @author Terence Parr parrt@magelang.com
 * @author John Lilley jlilley@empathy.com
 * @author Scott Stanchfield thetick@magelang.com
 * @author Markus Mohnen mohnen@informatik.rwth-aachen.de
 * @author Peter Williams pete.williams@sun.com
 * @author Allan Jacobs Allan.Jacobs@eng.sun.com
 * @author Steve Messick messick@redhills.com
 * 
 */
public class JavaRecognizer extends antlr.LLkParser
    implements
    JavaTokenTypes
{

    protected JavaRecognizer(TokenBuffer tokenBuf,
                             int k)
    {
        super( tokenBuf,
               k );
        tokenNames = _tokenNames;
        buildTokenTypeASTClassMap();
        astFactory = new ASTFactory( getTokenTypeToASTClassMap() );
    }

    public JavaRecognizer(TokenBuffer tokenBuf)
    {
        this( tokenBuf,
              2 );
    }

    protected JavaRecognizer(TokenStream lexer,
                             int k)
    {
        super( lexer,
               k );
        tokenNames = _tokenNames;
        buildTokenTypeASTClassMap();
        astFactory = new ASTFactory( getTokenTypeToASTClassMap() );
    }

    public JavaRecognizer(TokenStream lexer)
    {
        this( lexer,
              2 );
    }

    public JavaRecognizer(ParserSharedInputState state)
    {
        super( state,
               2 );
        tokenNames = _tokenNames;
        buildTokenTypeASTClassMap();
        astFactory = new ASTFactory( getTokenTypeToASTClassMap() );
    }

    public final void compilationUnit() throws RecognitionException,
                                       TokenStreamException
    {

        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST compilationUnit_AST = null;

        {
            switch ( LA( 1 ) )
            {
                case LITERAL_package :
                {
                    packageDefinition();
                    astFactory.addASTChild( currentAST,
                                            returnAST );
                    break;
                }
                case EOF :
                case FINAL :
                case ABSTRACT :
                case STRICTFP :
                case SEMI :
                case LITERAL_import :
                case LITERAL_private :
                case LITERAL_public :
                case LITERAL_protected :
                case LITERAL_static :
                case LITERAL_transient :
                case LITERAL_native :
                case LITERAL_threadsafe :
                case LITERAL_synchronized :
                case LITERAL_volatile :
                case LITERAL_class :
                case LITERAL_interface :
                {
                    break;
                }
                default :
                {
                    throw new NoViableAltException( LT( 1 ),
                                                    getFilename() );
                }
            }
        }
        {
            _loop4 : do
            {
                if ( (LA( 1 ) == LITERAL_import) )
                {
                    importDefinition();
                    astFactory.addASTChild( currentAST,
                                            returnAST );
                }
                else
                {
                    break _loop4;
                }

            }
            while ( true );
        }
        {
            _loop6 : do
            {
                if ( (_tokenSet_0.member( LA( 1 ) )) )
                {
                    typeDefinition();
                    astFactory.addASTChild( currentAST,
                                            returnAST );
                }
                else
                {
                    break _loop6;
                }

            }
            while ( true );
        }
        match( Token.EOF_TYPE );
        compilationUnit_AST = (AST) currentAST.root;
        returnAST = compilationUnit_AST;
    }

    public final void packageDefinition() throws RecognitionException,
                                         TokenStreamException
    {

        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST packageDefinition_AST = null;
        Token p = null;
        AST p_AST = null;

        try
        { // for error handling
            p = LT( 1 );
            p_AST = astFactory.create( p );
            astFactory.makeASTRoot( currentAST,
                                    p_AST );
            match( LITERAL_package );
            if ( inputState.guessing == 0 )
            {
                p_AST.setType( PACKAGE_DEF );
            }
            identifier();
            astFactory.addASTChild( currentAST,
                                    returnAST );
            match( SEMI );
            packageDefinition_AST = (AST) currentAST.root;
        }
        catch ( RecognitionException ex )
        {
            if ( inputState.guessing == 0 )
            {
                reportError( ex );
                consume();
                consumeUntil( _tokenSet_1 );
            }
            else
            {
                throw ex;
            }
        }
        returnAST = packageDefinition_AST;
    }

    public final void importDefinition() throws RecognitionException,
                                        TokenStreamException
    {

        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST importDefinition_AST = null;
        Token i = null;
        AST i_AST = null;

        try
        { // for error handling
            i = LT( 1 );
            i_AST = astFactory.create( i );
            astFactory.makeASTRoot( currentAST,
                                    i_AST );
            match( LITERAL_import );
            if ( inputState.guessing == 0 )
            {
                i_AST.setType( IMPORT );
            }
            identifierStar();
            astFactory.addASTChild( currentAST,
                                    returnAST );
            match( SEMI );
            importDefinition_AST = (AST) currentAST.root;
        }
        catch ( RecognitionException ex )
        {
            if ( inputState.guessing == 0 )
            {
                reportError( ex );
                consume();
                consumeUntil( _tokenSet_1 );
            }
            else
            {
                throw ex;
            }
        }
        returnAST = importDefinition_AST;
    }

    public final void typeDefinition() throws RecognitionException,
                                      TokenStreamException
    {

        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST typeDefinition_AST = null;
        AST m_AST = null;

        try
        { // for error handling
            switch ( LA( 1 ) )
            {
                case FINAL :
                case ABSTRACT :
                case STRICTFP :
                case LITERAL_private :
                case LITERAL_public :
                case LITERAL_protected :
                case LITERAL_static :
                case LITERAL_transient :
                case LITERAL_native :
                case LITERAL_threadsafe :
                case LITERAL_synchronized :
                case LITERAL_volatile :
                case LITERAL_class :
                case LITERAL_interface :
                {
                    modifiers();
                    m_AST = (AST) returnAST;
                    {
                        switch ( LA( 1 ) )
                        {
                            case LITERAL_class :
                            {
                                classDefinition( m_AST );
                                astFactory.addASTChild( currentAST,
                                                        returnAST );
                                break;
                            }
                            case LITERAL_interface :
                            {
                                interfaceDefinition( m_AST );
                                astFactory.addASTChild( currentAST,
                                                        returnAST );
                                break;
                            }
                            default :
                            {
                                throw new NoViableAltException( LT( 1 ),
                                                                getFilename() );
                            }
                        }
                    }
                    typeDefinition_AST = (AST) currentAST.root;
                    break;
                }
                case SEMI :
                {
                    match( SEMI );
                    typeDefinition_AST = (AST) currentAST.root;
                    break;
                }
                default :
                {
                    throw new NoViableAltException( LT( 1 ),
                                                    getFilename() );
                }
            }
        }
        catch ( RecognitionException ex )
        {
            if ( inputState.guessing == 0 )
            {
                reportError( ex );
                consume();
                consumeUntil( _tokenSet_2 );
            }
            else
            {
                throw ex;
            }
        }
        returnAST = typeDefinition_AST;
    }

    public final void ruleFile() throws RecognitionException,
                                TokenStreamException
    {

        returnAST = null;
        ASTPair currentAST = new ASTPair();
        AST ruleFile_AST = null;

        {
            switch ( LA( 1 ) )
            {
                case LITERAL_package :
                {
                    packageDefinition();
                    astFactory.addASTChild( currentAST,
                                            returnAST );
                    break;
                }
                case RULE_SET :
                case LITERAL_import :
                {
                    break;
                }
                default :
                {
                    throw new NoViableAltException( LT( 1 ),
                                                    getFilename() );
                }
            }
        }
        {
            _loop10 : do
            {
                if ( (LA( 1 ) == LITERAL_import) )
                {
                    importDefinition();
                    astFactory.addASTChild( currentAST,
                                            returnAST );
                }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -