nescparser.java

来自「plugin for eclipse」· Java 代码 · 共 2,369 行 · 第 1/5 页

JAVA
2,369
字号
		
	public final void aliasedComponentName() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		TNode aliasedComponentName_AST = null;
		Token  i = null;
		TNode i_AST = null;
		
		try {      // for error handling
			i = LT(1);
			i_AST = (TNode)astFactory.create(i);
			astFactory.addASTChild(currentAST, i_AST);
			match(ID);
			if ( inputState.guessing==0 ) {
				aliasedComponentName_AST = (TNode)currentAST.root;
				
																String inputFileName = i.getText()+".nc";			
																AST componentFileAST = null;
														
																ParserMessage container = new ParserMessage(ParserMessage.INFO, "Component file: "+inputFileName, new CodeLocation((CToken)i), null);
																getParserContext().addMsg(container);
																getParserContext().pushMessages(container);
																try {
																	componentFileAST = getParserContext().getAST(inputFileName);
																	aliasedComponentName_AST.setAttribute("componentFileAST", componentFileAST);	        
																} catch(ParserMessage m) {
																	getParserContext().addMsg(m);
																} finally {
																	getParserContext().popMessages();				
																}
														
			}
			{
			switch ( LA(1)) {
			case LITERAL_as:
			{
				TNode tmp39_AST = null;
				tmp39_AST = (TNode)astFactory.create(LT(1));
				astFactory.addASTChild(currentAST, tmp39_AST);
				match(LITERAL_as);
				TNode tmp40_AST = null;
				tmp40_AST = (TNode)astFactory.create(LT(1));
				astFactory.addASTChild(currentAST, tmp40_AST);
				match(ID);
				break;
			}
			case SEMI:
			case COMMA:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			aliasedComponentName_AST = (TNode)currentAST.root;
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				recover(ex,_tokenSet_6);
			} else {
			  throw ex;
			}
		}
		returnAST = aliasedComponentName_AST;
	}
	
	public final void endpoint() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		TNode endpoint_AST = null;
		
		try {      // for error handling
			TNode tmp41_AST = null;
			tmp41_AST = (TNode)astFactory.create(LT(1));
			astFactory.addASTChild(currentAST, tmp41_AST);
			match(ID);
			{
			_loop2912:
			do {
				if ((LA(1)==DOT)) {
					TNode tmp42_AST = null;
					tmp42_AST = (TNode)astFactory.create(LT(1));
					astFactory.addASTChild(currentAST, tmp42_AST);
					match(DOT);
					TNode tmp43_AST = null;
					tmp43_AST = (TNode)astFactory.create(LT(1));
					astFactory.addASTChild(currentAST, tmp43_AST);
					match(ID);
				}
				else {
					break _loop2912;
				}
				
			} while (true);
			}
			{
			switch ( LA(1)) {
			case LBRACKET:
			{
				interfaceParams();
				astFactory.addASTChild(currentAST, returnAST);
				break;
			}
			case SEMI:
			case ASSIGN:
			case PTR:
			case BACKPTR:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			endpoint_AST = (TNode)currentAST.root;
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				recover(ex,_tokenSet_23);
			} else {
			  throw ex;
			}
		}
		returnAST = endpoint_AST;
	}
	
	public final void interfaceParams() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		TNode interfaceParams_AST = null;
		TNode a_AST = null;
		
		try {      // for error handling
			TNode tmp44_AST = null;
			tmp44_AST = (TNode)astFactory.create(LT(1));
			astFactory.makeASTRoot(currentAST, tmp44_AST);
			match(LBRACKET);
			{
			argExprList();
			a_AST = (TNode)returnAST;
			astFactory.addASTChild(currentAST, returnAST);
			}
			TNode tmp45_AST = null;
			tmp45_AST = (TNode)astFactory.create(LT(1));
			astFactory.addASTChild(currentAST, tmp45_AST);
			match(RBRACKET);
			if ( inputState.guessing==0 ) {
				interfaceParams_AST = (TNode)currentAST.root;
				
				interfaceParams_AST.setType( NInterfaceParamArgs );
				
			}
			interfaceParams_AST = (TNode)currentAST.root;
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				recover(ex,_tokenSet_24);
			} else {
			  throw ex;
			}
		}
		returnAST = interfaceParams_AST;
	}
	
	public final String  declarator(
		boolean isFunctionDefinition
	) throws RecognitionException, TokenStreamException {
		String declName;
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		TNode declarator_AST = null;
		Token  id = null;
		TNode id_AST = null;
		Token  id2 = null;
		TNode id2_AST = null;
		declName = "";
		
		try {      // for error handling
			{
			switch ( LA(1)) {
			case STAR:
			{
				pointerGroup();
				astFactory.addASTChild(currentAST, returnAST);
				break;
			}
			case ID:
			case LPAREN:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			{
			switch ( LA(1)) {
			case ID:
			{
				{
				id = LT(1);
				id_AST = (TNode)astFactory.create(id);
				astFactory.addASTChild(currentAST, id_AST);
				match(ID);
				if ( inputState.guessing==0 ) {
					declName = id.getText();
				}
				{
				switch ( LA(1)) {
				case DOT:
				{
					TNode tmp46_AST = null;
					tmp46_AST = (TNode)astFactory.create(LT(1));
					astFactory.addASTChild(currentAST, tmp46_AST);
					match(DOT);
					id2 = LT(1);
					id2_AST = (TNode)astFactory.create(id2);
					astFactory.addASTChild(currentAST, id2_AST);
					match(ID);
					if ( inputState.guessing==0 ) {
						declName = declName + "." + id2.getText();
					}
					break;
				}
				case LITERAL_typedef:
				case LITERAL_asm:
				case LITERAL_volatile:
				case LCURLY:
				case SEMI:
				case LITERAL_struct:
				case LITERAL_union:
				case LITERAL_enum:
				case LITERAL_auto:
				case LITERAL_register:
				case LITERAL_extern:
				case LITERAL_static:
				case LITERAL_const:
				case LITERAL_void:
				case LITERAL_char:
				case LITERAL_short:
				case LITERAL_int:
				case LITERAL_long:
				case LITERAL_float:
				case LITERAL_double:
				case LITERAL_signed:
				case LITERAL_unsigned:
				case ID:
				case COMMA:
				case COLON:
				case ASSIGN:
				case LPAREN:
				case RPAREN:
				case LBRACKET:
				case RBRACKET:
				case VARARGS:
				case LITERAL_default:
				case LITERAL_inline:
				case LITERAL_typeof:
				case LITERAL___complex:
				case LITERAL___attribute:
				case LITERAL_norace:
				case LITERAL_async:
				case LITERAL_command:
				case LITERAL_event:
				case LITERAL_task:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				}
				}
				}
				break;
			}
			case LPAREN:
			{
				TNode tmp47_AST = null;
				tmp47_AST = (TNode)astFactory.create(LT(1));
				astFactory.addASTChild(currentAST, tmp47_AST);
				match(LPAREN);
				declName=declarator(false);
				astFactory.addASTChild(currentAST, returnAST);
				TNode tmp48_AST = null;
				tmp48_AST = (TNode)astFactory.create(LT(1));
				astFactory.addASTChild(currentAST, tmp48_AST);
				match(RPAREN);
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			{
			if (((LA(1)==LPAREN||LA(1)==LBRACKET) && (_tokenSet_25.member(LA(2))))&&(isFunctionDefinition)) {
				{
				{
				if ((LA(1)==LPAREN||LA(1)==LBRACKET) && (_tokenSet_25.member(LA(2)))) {
					interfaceParameterList();
					astFactory.addASTChild(currentAST, returnAST);
				}
				else if ((LA(1)==LPAREN) && (_tokenSet_26.member(LA(2)))) {
				}
				else {
					throw new NoViableAltException(LT(1), getFilename());
				}
				
				}
				declaratorParamaterList(isFunctionDefinition, declName);
				astFactory.addASTChild(currentAST, returnAST);
				}
			}
			else if ((_tokenSet_17.member(LA(1))) && (_tokenSet_27.member(LA(2)))) {
				{
				_loop2924:
				do {
					switch ( LA(1)) {
					case LPAREN:
					{
						declaratorParamaterList(isFunctionDefinition, declName);
						astFactory.addASTChild(currentAST, returnAST);
						break;
					}
					case LBRACKET:
					{
						TNode tmp49_AST = null;
						tmp49_AST = (TNode)astFactory.create(LT(1));
						astFactory.addASTChild(currentAST, tmp49_AST);
						match(LBRACKET);
						{
						switch ( LA(1)) {
						case LITERAL_asm:
						case ID:
						case STAR:
						case LPAREN:
						case LAND:
						case BAND:
						case PLUS:
						case MINUS:
						case INC:
						case DEC:
						case LITERAL_sizeof:
						case BNOT:
						case LNOT:
						case CharLiteral:
						case StringLiteral:
						case Number:
						case LITERAL___alignof:
						case LITERAL___real:
						case LITERAL___imag:
						case LITERAL_call:
						case LITERAL_signal:
						case LITERAL_post:
						{
							expr();
							astFactory.addASTChild(currentAST, returnAST);
							break;
						}
						case RBRACKET:
						{
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						}
						}
						TNode tmp50_AST = null;
						tmp50_AST = (TNode)astFactory.create(LT(1));
						astFactory.addASTChild(currentAST, tmp50_AST);
						match(RBRACKET);
						break;
					}
					default:
					{
						break _loop2924;
					}
					}
				} while (true);
				}
			}
			else {
				throw new NoViableAltException(LT(1), getFilename());
			}
			
			}
			if ( inputState.guessing==0 ) {
				declarator_AST = (TNode)currentAST.root;
				declarator_AST = (TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NDeclarator)).add(declarator_AST));
				currentAST.root = declarator_AST;
				currentAST.child = declarator_AST!=null &&declarator_AST.getFirstChild()!=null ?
					declarator_AST.getFirstChild() : declarator_AST;
				currentAST.advanceChildToEnd();
			}
			declarator_AST = (TNode)currentAST.root;
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				recover(ex,_tokenSet_28);
			} else {
			  throw ex;
			}
		}
		returnAST = declarator_AST;
		return declName;
	}
	
	public final void pointerGroup() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		TNode pointerGroup_AST = null;
		
		try {      // for error handling
			{
			int _cnt3188=0;
			_loop3188:
			do {
				if ((LA(1)==STAR)) {
					TNode tmp51_AST = null;
					tmp51_AST = (TNode)astFactory.create(LT(1));
					astFactory.addASTChild(currentAST, tmp51_AST);
					match(STAR);
					{
					_loop3187:
					do {
						if ((LA(1)==LITERAL_volatile||LA(1)==LITERAL_const)) {
							typeQualifier();
							astFactory.addASTChild(currentAST, returnAST);
						}
						else {
							break _loop3187;
						}
						
					} while (true);
					}
				}
				else {
					if ( _cnt3188>=1 ) { break _loop3188; } else {throw new NoViableAltException(LT(1), getFilename());}
				}
				
				_cnt3188++;
			} while (true);
			}
			if ( inputState.guessing==0 ) {
				pointerGroup_AST = (TNode)currentAST.root;
				pointerGroup_AST = (TNode)astFactory.make( (new ASTArray(2)).add((TNode)astFactory.create(NPointerGroup)).add(pointerGroup_AST));
				currentAST.root = pointerGroup_AST;
				currentAST.child = pointerGroup_AST!=null &&pointerGroup_AST.getFirstChild()!=null ?
					pointerGroup_AST.getFirstChild() : pointerGroup_AST;
				currentAST.advanceChildToEnd();
			}
			pointerGroup_AST 

⌨️ 快捷键说明

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