javarecognizer.java

来自「Groovy动态语言 运行在JVM中的动态语言 可以方便的处理业务逻辑变化大的业」· Java 代码 · 共 2,519 行 · 第 1/5 页

JAVA
2,519
字号
			case LITERAL_class:			case LITERAL_interface:			case LITERAL_enum:			{				modifiers();				m_AST = (AST)returnAST;				typeDefinitionInternal(m_AST);				astFactory.addASTChild(currentAST, returnAST);				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_3);			} else {			  throw ex;			}		}		returnAST = typeDefinition_AST;	}		public final void identifier() throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST identifier_AST = null;				AST tmp6_AST = null;		tmp6_AST = astFactory.create(LT(1));		astFactory.addASTChild(currentAST, tmp6_AST);		match(IDENT);		{		_loop48:		do {			if ((LA(1)==DOT)) {				AST tmp7_AST = null;				tmp7_AST = astFactory.create(LT(1));				astFactory.makeASTRoot(currentAST, tmp7_AST);				match(DOT);				AST tmp8_AST = null;				tmp8_AST = astFactory.create(LT(1));				astFactory.addASTChild(currentAST, tmp8_AST);				match(IDENT);			}			else {				break _loop48;			}					} while (true);		}		identifier_AST = (AST)currentAST.root;		returnAST = identifier_AST;	}		public final void identifierStar() throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST identifierStar_AST = null;				AST tmp9_AST = null;		tmp9_AST = astFactory.create(LT(1));		astFactory.addASTChild(currentAST, tmp9_AST);		match(IDENT);		{		_loop51:		do {			if ((LA(1)==DOT) && (LA(2)==IDENT)) {				AST tmp10_AST = null;				tmp10_AST = astFactory.create(LT(1));				astFactory.makeASTRoot(currentAST, tmp10_AST);				match(DOT);				AST tmp11_AST = null;				tmp11_AST = astFactory.create(LT(1));				astFactory.addASTChild(currentAST, tmp11_AST);				match(IDENT);			}			else {				break _loop51;			}					} while (true);		}		{		switch ( LA(1)) {		case DOT:		{			AST tmp12_AST = null;			tmp12_AST = astFactory.create(LT(1));			astFactory.makeASTRoot(currentAST, tmp12_AST);			match(DOT);			AST tmp13_AST = null;			tmp13_AST = astFactory.create(LT(1));			astFactory.addASTChild(currentAST, tmp13_AST);			match(STAR);			break;		}		case SEMI:		{			break;		}		default:		{			throw new NoViableAltException(LT(1), getFilename());		}		}		}		identifierStar_AST = (AST)currentAST.root;		returnAST = identifierStar_AST;	}		public final void modifiers() throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST modifiers_AST = null;		Token first = LT(1);				{		_loop55:		do {			if ((_tokenSet_4.member(LA(1)))) {				modifier();				astFactory.addASTChild(currentAST, returnAST);			}			else if (((LA(1)==AT) && (LA(2)==IDENT))&&(LA(1)==AT && !LT(2).getText().equals("interface"))) {				annotation();				astFactory.addASTChild(currentAST, returnAST);			}			else {				break _loop55;			}					} while (true);		}		if ( inputState.guessing==0 ) {			modifiers_AST = (AST)currentAST.root;			modifiers_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(MODIFIERS,"MODIFIERS",first,LT(1))).add(modifiers_AST));			currentAST.root = modifiers_AST;			currentAST.child = modifiers_AST!=null &&modifiers_AST.getFirstChild()!=null ?				modifiers_AST.getFirstChild() : modifiers_AST;			currentAST.advanceChildToEnd();		}		modifiers_AST = (AST)currentAST.root;		returnAST = modifiers_AST;	}		protected final void typeDefinitionInternal(		AST mods	) throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST typeDefinitionInternal_AST = null;				switch ( LA(1)) {		case LITERAL_class:		{			classDefinition(mods);			astFactory.addASTChild(currentAST, returnAST);			typeDefinitionInternal_AST = (AST)currentAST.root;			break;		}		case LITERAL_interface:		{			interfaceDefinition(mods);			astFactory.addASTChild(currentAST, returnAST);			typeDefinitionInternal_AST = (AST)currentAST.root;			break;		}		case LITERAL_enum:		{			enumDefinition(mods);			astFactory.addASTChild(currentAST, returnAST);			typeDefinitionInternal_AST = (AST)currentAST.root;			break;		}		case AT:		{			annotationDefinition(mods);			astFactory.addASTChild(currentAST, returnAST);			typeDefinitionInternal_AST = (AST)currentAST.root;			break;		}		default:		{			throw new NoViableAltException(LT(1), getFilename());		}		}		returnAST = typeDefinitionInternal_AST;	}		public final void classDefinition(		AST modifiers	) throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST classDefinition_AST = null;		AST tp_AST = null;		AST sc_AST = null;		AST ic_AST = null;		AST cb_AST = null;		Token first = LT(1);				match(LITERAL_class);		AST tmp15_AST = null;		tmp15_AST = astFactory.create(LT(1));		match(IDENT);		{		switch ( LA(1)) {		case LT:		{			typeParameters();			tp_AST = (AST)returnAST;			break;		}		case LITERAL_extends:		case LCURLY:		case LITERAL_implements:		{			break;		}		default:		{			throw new NoViableAltException(LT(1), getFilename());		}		}		}		superClassClause();		sc_AST = (AST)returnAST;		implementsClause();		ic_AST = (AST)returnAST;		classBlock();		cb_AST = (AST)returnAST;		if ( inputState.guessing==0 ) {			classDefinition_AST = (AST)currentAST.root;			classDefinition_AST = (AST)astFactory.make( (new ASTArray(7)).add(create(CLASS_DEF,"CLASS_DEF",first,LT(1))).add(modifiers).add(tmp15_AST).add(tp_AST).add(sc_AST).add(ic_AST).add(cb_AST));			currentAST.root = classDefinition_AST;			currentAST.child = classDefinition_AST!=null &&classDefinition_AST.getFirstChild()!=null ?				classDefinition_AST.getFirstChild() : classDefinition_AST;			currentAST.advanceChildToEnd();		}		returnAST = classDefinition_AST;	}		public final void interfaceDefinition(		AST modifiers	) throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST interfaceDefinition_AST = null;		AST tp_AST = null;		AST ie_AST = null;		AST ib_AST = null;		Token first = LT(1);				match(LITERAL_interface);		AST tmp17_AST = null;		tmp17_AST = astFactory.create(LT(1));		match(IDENT);		{		switch ( LA(1)) {		case LT:		{			typeParameters();			tp_AST = (AST)returnAST;			break;		}		case LITERAL_extends:		case LCURLY:		{			break;		}		default:		{			throw new NoViableAltException(LT(1), getFilename());		}		}		}		interfaceExtends();		ie_AST = (AST)returnAST;		interfaceBlock();		ib_AST = (AST)returnAST;		if ( inputState.guessing==0 ) {			interfaceDefinition_AST = (AST)currentAST.root;			interfaceDefinition_AST = (AST)astFactory.make( (new ASTArray(6)).add(create(INTERFACE_DEF,"INTERFACE_DEF",first,LT(1))).add(modifiers).add(tmp17_AST).add(tp_AST).add(ie_AST).add(ib_AST));			currentAST.root = interfaceDefinition_AST;			currentAST.child = interfaceDefinition_AST!=null &&interfaceDefinition_AST.getFirstChild()!=null ?				interfaceDefinition_AST.getFirstChild() : interfaceDefinition_AST;			currentAST.advanceChildToEnd();		}		returnAST = interfaceDefinition_AST;	}		public final void enumDefinition(		AST modifiers	) throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST enumDefinition_AST = null;		AST ic_AST = null;		AST eb_AST = null;		Token first = LT(1);				match(LITERAL_enum);		AST tmp19_AST = null;		tmp19_AST = astFactory.create(LT(1));		match(IDENT);		implementsClause();		ic_AST = (AST)returnAST;		enumBlock();		eb_AST = (AST)returnAST;		if ( inputState.guessing==0 ) {			enumDefinition_AST = (AST)currentAST.root;			enumDefinition_AST = (AST)astFactory.make( (new ASTArray(5)).add(create(ENUM_DEF,"ENUM_DEF",first,LT(1))).add(modifiers).add(tmp19_AST).add(ic_AST).add(eb_AST));			currentAST.root = enumDefinition_AST;			currentAST.child = enumDefinition_AST!=null &&enumDefinition_AST.getFirstChild()!=null ?				enumDefinition_AST.getFirstChild() : enumDefinition_AST;			currentAST.advanceChildToEnd();		}		returnAST = enumDefinition_AST;	}		public final void annotationDefinition(		AST modifiers	) throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST annotationDefinition_AST = null;		AST ab_AST = null;		Token first = LT(1);				AST tmp20_AST = null;		tmp20_AST = astFactory.create(LT(1));		match(AT);		match(LITERAL_interface);		AST tmp22_AST = null;		tmp22_AST = astFactory.create(LT(1));		match(IDENT);		annotationBlock();		ab_AST = (AST)returnAST;		if ( inputState.guessing==0 ) {			annotationDefinition_AST = (AST)currentAST.root;			annotationDefinition_AST = (AST)astFactory.make( (new ASTArray(4)).add(create(ANNOTATION_DEF,"ANNOTATION_DEF",first,LT(1))).add(modifiers).add(tmp22_AST).add(ab_AST));			currentAST.root = annotationDefinition_AST;			currentAST.child = annotationDefinition_AST!=null &&annotationDefinition_AST.getFirstChild()!=null ?				annotationDefinition_AST.getFirstChild() : annotationDefinition_AST;			currentAST.advanceChildToEnd();		}		returnAST = annotationDefinition_AST;	}		public final void declaration() throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST declaration_AST = null;		AST m_AST = null;		AST t_AST = null;		AST v_AST = null;				modifiers();		m_AST = (AST)returnAST;		typeSpec(false);		t_AST = (AST)returnAST;		variableDefinitions(m_AST,t_AST);		v_AST = (AST)returnAST;		if ( inputState.guessing==0 ) {			declaration_AST = (AST)currentAST.root;			declaration_AST = v_AST;			currentAST.root = declaration_AST;			currentAST.child = declaration_AST!=null &&declaration_AST.getFirstChild()!=null ?				declaration_AST.getFirstChild() : declaration_AST;			currentAST.advanceChildToEnd();		}		returnAST = declaration_AST;	}		public final void typeSpec(		boolean addImagNode	) throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST typeSpec_AST = null;				switch ( LA(1)) {		case IDENT:		{			classTypeSpec(addImagNode);			astFactory.addASTChild(currentAST, returnAST);			typeSpec_AST = (AST)currentAST.root;			break;		}		case LITERAL_void:		case LITERAL_boolean:		case LITERAL_byte:		case LITERAL_char:		case LITERAL_short:		case LITERAL_int:		case LITERAL_float:		case LITERAL_long:		case LITERAL_double:		{			builtInTypeSpec(addImagNode);			astFactory.addASTChild(currentAST, returnAST);			typeSpec_AST = (AST)currentAST.root;			break;		}		default:		{			throw new NoViableAltException(LT(1), getFilename());		}		}		returnAST = typeSpec_AST;	}		public final void variableDefinitions(		AST mods, AST t	) throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST variableDefinitions_AST = null;				variableDeclarator(getASTFactory().dupTree(mods),							getASTFactory().dupTree(t));		astFactory.addASTChild(currentAST, returnAST);		{		_loop155:		do {			if ((LA(1)==COMMA)) {				match(COMMA);				variableDeclarator(getASTFactory().dupTree(mods),							getASTFactory().dupTree(t));				astFactory.addASTChild(currentAST, returnAST);			}			else {				break _loop155;			}					} while (true);		}		variableDefinitions_AST = (AST)currentAST.root;		returnAST = variableDefinitions_AST;	}		public final void classTypeSpec(		boolean addImagNode	) throws RecognitionException, TokenStreamException {				returnAST = null;		ASTPair currentAST = new ASTPair();		AST classTypeSpec_AST = null;		Token  lb = null;		AST lb_AST = null;		Token first = LT(1);				classOrInterfaceType(false);		astFactory.addASTChild(currentAST, returnAST);		{		_loop18:		do {			if ((LA(1)==LBRACK) && (LA(2)==RBRACK)) {				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 _loop18;			}					} while (true);		}		if ( inputState.guessing==0 ) {			classTypeSpec_AST = (AST)currentAST.root;									if ( addImagNode ) {							classTypeSpec_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(TYPE,"TYPE",first,LT(1))).add(classTypeSpec_AST));						}					

⌨️ 快捷键说明

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