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

📄 javarecognizer.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
// $ANTLR 2.7.4: "java-expression.g" -> "JavaRecognizer.java"$    package gnu.classpath.tools.gjdoc.expr; import antlr.TokenBuffer;import antlr.TokenStreamException;import antlr.TokenStreamIOException;import antlr.ANTLRException;import antlr.LLkParser;import antlr.Token;import antlr.TokenStream;import antlr.RecognitionException;import antlr.NoViableAltException;import antlr.MismatchedTokenException;import antlr.SemanticException;import antlr.ParserSharedInputState;import antlr.collections.impl.BitSet;import antlr.collections.AST;import java.util.Hashtable;import antlr.ASTFactory;import antlr.ASTPair;import antlr.collections.impl.ASTArray;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 Type  builtInTypeSpec(		boolean addImagNode	) throws RecognitionException, TokenStreamException {		Type t = null;				returnAST = null;		ASTPair currentAST = new ASTPair();		AST builtInTypeSpec_AST = null;		Token  lb = null;		AST lb_AST = null;				t=builtInType();		astFactory.addASTChild(currentAST, returnAST);		{		_loop3:		do {			if ((LA(1)==LBRACK)) {				lb = LT(1);				lb_AST = astFactory.create(lb);				astFactory.makeASTRoot(currentAST, lb_AST);				match(LBRACK);				if ( inputState.guessing==0 ) {					lb_AST.setType(ARRAY_DECLARATOR);				}				match(RBRACK);			}			else {				break _loop3;			}					} while (true);		}		if ( inputState.guessing==0 ) {			builtInTypeSpec_AST = (AST)currentAST.root;									if ( addImagNode ) {							builtInTypeSpec_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(TYPE,"TYPE")).add(builtInTypeSpec_AST));						}								currentAST.root = builtInTypeSpec_AST;			currentAST.child = builtInTypeSpec_AST!=null &&builtInTypeSpec_AST.getFirstChild()!=null ?				builtInTypeSpec_AST.getFirstChild() : builtInTypeSpec_AST;			currentAST.advanceChildToEnd();		}		builtInTypeSpec_AST = (AST)currentAST.root;		returnAST = builtInTypeSpec_AST;		return t;	}		public final Type  builtInType() throws RecognitionException, TokenStreamException {		Type t = null;				returnAST = null;		ASTPair currentAST = new ASTPair();		AST builtInType_AST = null;				switch ( LA(1)) {		case LITERAL_void:		{			AST tmp2_AST = null;			tmp2_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp2_AST);			match(LITERAL_void);			if ( inputState.guessing==0 ) {				t=Type.VOID;			}			builtInType_AST = (AST)currentAST.root;			break;		}		case LITERAL_boolean:		{			AST tmp3_AST = null;			tmp3_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp3_AST);			match(LITERAL_boolean);			if ( inputState.guessing==0 ) {				t=Type.BOOLEAN;			}			builtInType_AST = (AST)currentAST.root;			break;		}		case LITERAL_byte:		{			AST tmp4_AST = null;			tmp4_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp4_AST);			match(LITERAL_byte);			if ( inputState.guessing==0 ) {				t=Type.BYTE;			}			builtInType_AST = (AST)currentAST.root;			break;		}		case LITERAL_char:		{			AST tmp5_AST = null;			tmp5_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp5_AST);			match(LITERAL_char);			if ( inputState.guessing==0 ) {				t=Type.CHAR;			}			builtInType_AST = (AST)currentAST.root;			break;		}		case LITERAL_short:		{			AST tmp6_AST = null;			tmp6_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp6_AST);			match(LITERAL_short);			if ( inputState.guessing==0 ) {				t=Type.SHORT;			}			builtInType_AST = (AST)currentAST.root;			break;		}		case LITERAL_int:		{			AST tmp7_AST = null;			tmp7_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp7_AST);			match(LITERAL_int);			if ( inputState.guessing==0 ) {				t=Type.INTEGER;			}			builtInType_AST = (AST)currentAST.root;			break;		}		case LITERAL_float:		{			AST tmp8_AST = null;			tmp8_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp8_AST);			match(LITERAL_float);			if ( inputState.guessing==0 ) {				t=Type.FLOAT;			}			builtInType_AST = (AST)currentAST.root;			break;		}		case LITERAL_long:		{			AST tmp9_AST = null;			tmp9_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp9_AST);			match(LITERAL_long);			if ( inputState.guessing==0 ) {				t=Type.LONG;			}			builtInType_AST = (AST)currentAST.root;			break;		}		case LITERAL_double:		{			AST tmp10_AST = null;			tmp10_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp10_AST);			match(LITERAL_double);			if ( inputState.guessing==0 ) {				t=Type.DOUBLE;			}			builtInType_AST = (AST)currentAST.root;			break;		}		case LITERAL_String:		{			AST tmp11_AST = null;			tmp11_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp11_AST);			match(LITERAL_String);			if ( inputState.guessing==0 ) {				t=Type.STRING;			}			builtInType_AST = (AST)currentAST.root;			break;		}		default:		{			throw new NoViableAltException(LT(1), getFilename());		}		}		returnAST = builtInType_AST;		return t;	}		public final Type  type() throws RecognitionException, TokenStreamException {		Type t;				returnAST = null;		ASTPair currentAST = new ASTPair();		AST type_AST = null;				t=builtInType();		astFactory.addASTChild(currentAST, returnAST);		type_AST = (AST)currentAST.root;		returnAST = type_AST;		return t;	}		public final String  identifier() throws RecognitionException, TokenStreamException {		String s = null;;				returnAST = null;		ASTPair currentAST = new ASTPair();		AST identifier_AST = null;		Token  i = null;		AST i_AST = null;		Token  i2 = null;		AST i2_AST = null;				i = LT(1);		i_AST = astFactory.create(i);		astFactory.addASTChild(currentAST, i_AST);		match(IDENT);		if ( inputState.guessing==0 ) {			s=i.getText();		}		{		_loop8:		do {			if ((LA(1)==DOT)) {				AST tmp12_AST = null;				tmp12_AST = astFactory.create(LT(1));				astFactory.makeASTRoot(currentAST, tmp12_AST);				match(DOT);				i2 = LT(1);				i2_AST = astFactory.create(i2);				astFactory.addASTChild(currentAST, i2_AST);				match(IDENT);				if ( inputState.guessing==0 ) {					s+="."+i2.getText();				}			}			else {				break _loop8;			}					} while (true);		}		identifier_AST = (AST)currentAST.root;		returnAST = identifier_AST;		return s;	}		public final Expression  expression() throws RecognitionException, TokenStreamException {		Expression e = null;				returnAST = null;		ASTPair currentAST = new ASTPair();		AST expression_AST = null;				e=conditionalExpression();		astFactory.addASTChild(currentAST, returnAST);		match(Token.EOF_TYPE);		expression_AST = (AST)currentAST.root;		returnAST = expression_AST;		return e;	}		public final Expression  conditionalExpression() throws RecognitionException, TokenStreamException {		Expression e = null;				returnAST = null;		ASTPair currentAST = new ASTPair();		AST conditionalExpression_AST = null;		Expression a,b,c;				e=logicalOrExpression();		astFactory.addASTChild(currentAST, returnAST);		{		switch ( LA(1)) {		case QUESTION:		{			AST tmp14_AST = null;			tmp14_AST = astFactory.create(LT(1));			astFactory.makeASTRoot(currentAST, tmp14_AST);			match(QUESTION);			b=conditionalExpression();			astFactory.addASTChild(currentAST, returnAST);			match(COLON);			c=conditionalExpression();			astFactory.addASTChild(currentAST, returnAST);			if ( inputState.guessing==0 ) {				e=new ConditionalExpression(e,b,c);			}			break;		}		case EOF:		case COLON:		case RPAREN:		{			break;		}		default:		{			throw new NoViableAltException(LT(1), getFilename());		}		}		}		conditionalExpression_AST = (AST)currentAST.root;		returnAST = conditionalExpression_AST;		return e;	}		public final Expression  logicalOrExpression() throws RecognitionException, TokenStreamException {		Expression e = null;				returnAST = null;		ASTPair currentAST = new ASTPair();		AST logicalOrExpression_AST = null;		Expression a,b;				e=logicalAndExpression();		astFactory.addASTChild(currentAST, returnAST);		{		_loop14:		do {			if ((LA(1)==LOR)) {				AST tmp16_AST = null;				tmp16_AST = astFactory.create(LT(1));				astFactory.makeASTRoot(currentAST, tmp16_AST);				match(LOR);				b=logicalAndExpression();				astFactory.addASTChild(currentAST, returnAST);				if ( inputState.guessing==0 ) {					e=new LogicalOrExpression(e,b);				}			}			else {				break _loop14;			}					} while (true);		}		logicalOrExpression_AST = (AST)currentAST.root;		returnAST = logicalOrExpression_AST;		return e;	}		public final Expression  logicalAndExpression() throws RecognitionException, TokenStreamException {		Expression e = null;				returnAST = null;		ASTPair currentAST = new ASTPair();		AST logicalAndExpression_AST = null;		Expression a,b;				e=inclusiveOrExpression();		astFactory.addASTChild(currentAST, returnAST);		{		_loop17:		do {			if ((LA(1)==LAND)) {				AST tmp17_AST = null;				tmp17_AST = astFactory.create(LT(1));				astFactory.makeASTRoot(currentAST, tmp17_AST);				match(LAND);				b=inclusiveOrExpression();				astFactory.addASTChild(currentAST, returnAST);				if ( inputState.guessing==0 ) {					e=new LogicalAndExpression(e,b);				}			}			else {				break _loop17;			}					} while (true);		}		logicalAndExpression_AST = (AST)currentAST.root;		returnAST = logicalAndExpression_AST;		return e;	}		public final Expression  inclusiveOrExpression() throws RecognitionException, TokenStreamException {		Expression e = null;				returnAST = null;		ASTPair currentAST = new ASTPair();		AST inclusiveOrExpression_AST = null;		Expression a,b;				e=exclusiveOrExpression();		astFactory.addASTChild(currentAST, returnAST);		{		_loop20:		do {			if ((LA(1)==BOR)) {				AST tmp18_AST = null;				tmp18_AST = astFactory.create(LT(1));				astFactory.makeASTRoot(currentAST, tmp18_AST);				match(BOR);				b=exclusiveOrExpression();				astFactory.addASTChild(currentAST, returnAST);				if ( inputState.guessing==0 ) {					e=new InclusiveOrExpression(e,b);				}			}			else {				break _loop20;			}					} while (true);		}		inclusiveOrExpression_AST = (AST)currentAST.root;		returnAST = inclusiveOrExpression_AST;		return e;	}		public final Expression  exclusiveOrExpression() throws RecognitionException, TokenStreamException {		Expression e = null;				returnAST = null;

⌨️ 快捷键说明

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