nescobjecttreebuilder.java

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

JAVA
2,529
字号
					if ( inputState.guessing==0 ) {
							includeFileObj.addExternal(s);
					}
					break;
				}
				case NTypeMissing:
				{
					tldObj=typelessDeclaration(_t);
					_t = _retTree;
					if ( inputState.guessing==0 ) {
							includeFileObj.addExternal(tldObj);
					}
					break;
				}
				case NText:
				{
					tn = _t==ASTNULL ? null : (TNode)_t;
					textNode(_t);
					_t = _retTree;
					if ( inputState.guessing==0 ) {
							includeFileObj.addExternal(tn);
					}
					break;
				}
				default:
				{
					if ( _cnt736>=1 ) { break _loop736; } else {throw new NoViableAltException(_t);}
				}
				}
				_cnt736++;
			} while (true);
			}
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final List  includes(AST _t) throws RecognitionException {
		List includeFileObjList;
		
		TNode includes_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
		TNode i = null;
			includeFileObjList = null;
		
		try {      // for error handling
			AST __t655 = _t;
			i = _t==ASTNULL ? null :(TNode)_t;
			match(_t,NIncludes);
			_t = _t.getFirstChild();
			includeFileObjList=includeFileNameList(_t);
			_t = _retTree;
			_t = __t655;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
		return includeFileObjList;
	}
	
	public final Interface  interfaceDeclaration(AST _t) throws RecognitionException {
		Interface interfaceObj;
		
		TNode interfaceDeclaration_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
		TNode lc = null;
		TNode i = null;
		TNode id = null;
		TNode rc = null;
			interfaceObj = null; 
																	FunctionDeclaration decl = null;
																
		
		try {      // for error handling
			AST __t663 = _t;
			lc = _t==ASTNULL ? null :(TNode)_t;
			match(_t,NInterface);
			_t = _t.getFirstChild();
			if ( inputState.guessing==0 ) {
					interfaceObj = new Interface(); 
																			interfaceObj.setDefNode(lc);
																		
			}
			i = (TNode)_t;
			match(_t,LITERAL_interface);
			_t = _t.getNextSibling();
			id = (TNode)_t;
			match(_t,ID);
			_t = _t.getNextSibling();
			if ( inputState.guessing==0 ) {
					interfaceObj.setNameNode(id);
			}
			{
			int _cnt665=0;
			_loop665:
			do {
				if (_t==null) _t=ASTNULL;
				if ((_t.getType()==NDeclaration)) {
					decl=interfaceMemberFunctionDeclaration(_t);
					_t = _retTree;
					if ( inputState.guessing==0 ) {
							if(decl instanceof FunctionDeclaration) {
							     														interfaceObj.addFunctionDeclaration(decl);
							     													} else {
							     														TypeResolutionException ex = new TypeResolutionException("Error adding declaration to interface: not function declaration", decl.getDefNode());
							     														reportError(ex);
							     													}
							     												
					}
				}
				else {
					if ( _cnt665>=1 ) { break _loop665; } else {throw new NoViableAltException(_t);}
				}
				
				_cnt665++;
			} while (true);
			}
			rc = (TNode)_t;
			match(_t,RCURLY);
			_t = _t.getNextSibling();
			_t = __t663;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
		return interfaceObj;
	}
	
	public final List  includeFileNameList(AST _t) throws RecognitionException {
		List includeFileObjList;
		
		TNode includeFileNameList_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
		TNode c = null;
			includeFileObjList = new ArrayList(); 
																	NesCIncludeFile includeFileObj = null;
																
		
		try {      // for error handling
			{
			includeFileObj=includeFileName(_t);
			_t = _retTree;
			if ( inputState.guessing==0 ) {
					includeFileObjList.add(includeFileObj);
			}
			{
			_loop659:
			do {
				if (_t==null) _t=ASTNULL;
				if ((_t.getType()==COMMA)) {
					c = (TNode)_t;
					match(_t,COMMA);
					_t = _t.getNextSibling();
					includeFileObj=includeFileName(_t);
					_t = _retTree;
					if ( inputState.guessing==0 ) {
							includeFileObjList.add(includeFileObj);
					}
				}
				else {
					break _loop659;
				}
				
			} while (true);
			}
			}
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
		return includeFileObjList;
	}
	
	public final NesCIncludeFile  includeFileName(AST _t) throws RecognitionException {
		NesCIncludeFile includeFileObj;
		
		TNode includeFileName_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
		TNode n = null;
		TNode i = null;
			includeFileObj = null;
		
		try {      // for error handling
			AST __t661 = _t;
			n = _t==ASTNULL ? null :(TNode)_t;
			match(_t,NIncludeFileName);
			_t = _t.getFirstChild();
			i = (TNode)_t;
			match(_t,ID);
			_t = _t.getNextSibling();
			if ( inputState.guessing==0 ) {
																			
																			// get the include file's AST (the parser stores it as an attribute of the NIncludeFileName node)
																			TNode includeFileAST = (TNode)i.getAttribute("includeFileAST");
				//															ASTFrameFactory.create(includeFileAST, "include file AST: "+i.getText());
																			//String includeFileName = (String)includeFileAST.getAttribute("source");
																			String includeFileName = i.getText()+".h";
																			
																			// try getting the include file object tree from the context
																			ParserMessage container = new ParserMessage(ParserMessage.INFO, "OT: Include file: "+includeFileName, new CodeLocation(i), null);
																			ctx.addMsg(container);
																			ctx.pushMessages(container);
																			NesCFile nesCFileObj = null;
																			try {
																				nesCFileObj = ctx.getObjectTree(includeFileName);
																			} catch(ParserMessage m) {
																				ctx.addMsg(m);																	
																			} finally {
																				ctx.popMessages();				
																			}
				/*															
																			if(nesCFileObj == null || !(nesCFileObj instanceof NesCInterfaceFile)) {
																				// build the object tree
																				includeFileObj = includeFile(includeFileAST);
																				// register the parsed object tree with the project
																				ctx.setFileObjectTree(includeFileName, includeFileObj);
																			} else {
																				includeFileObj = (NesCIncludeFile) nesCFileObj;
																			}
				*/
																			includeFileObj = (NesCIncludeFile) nesCFileObj;		
																		
			}
			_t = __t661;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
		return includeFileObj;
	}
	
	public final FunctionDeclaration  interfaceMemberFunctionDeclaration(AST _t) throws RecognitionException {
		FunctionDeclaration fdeclnObj = null;
		
		TNode interfaceMemberFunctionDeclaration_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
		TNode dn = null;
		TNode i = null;
			
																	SynchronySpecifier ssObj = null;
																	DirectionSpecifier dsObj = null;
																	TypeQualifier tqObj = null;
																	TypeSpecifier tsObj = null;
																	Declarator fdeclrObj = null;
																	TypeBuilder builderObj = null;
																
		
		try {      // for error handling
			AST __t667 = _t;
			dn = _t==ASTNULL ? null :(TNode)_t;
			match(_t,NDeclaration);
			_t = _t.getFirstChild();
			if ( inputState.guessing==0 ) {
					fdeclnObj = new FunctionDeclaration(); 
																			fdeclnObj.setDefNode(dn);
																			builderObj = new TypeBuilder();
																		
			}
			{
			_loop669:
			do {
				if (_t==null) _t=ASTNULL;
				switch ( _t.getType()) {
				case LITERAL_async:
				{
					ssObj=synchronySpecifier(_t);
					_t = _retTree;
					if ( inputState.guessing==0 ) {
							fdeclnObj.addSynchronySpecifier(ssObj);
					}
					break;
				}
				case LITERAL_command:
				case LITERAL_event:
				{
					dsObj=directionSpecifier(_t);
					_t = _retTree;
					if ( inputState.guessing==0 ) {
							fdeclnObj.addDirectionSpecifier(dsObj);
					}
					break;
				}
				default:
				{
					break _loop669;
				}
				}
			} while (true);
			}
			{
			_loop671:
			do {
				if (_t==null) _t=ASTNULL;
				if ((_t.getType()==LITERAL_volatile||_t.getType()==LITERAL_const)) {
					tqObj=typeQualifier(_t);
					_t = _retTree;
					if ( inputState.guessing==0 ) {
							builderObj.addTypeQualifier(tqObj);
					}
				}
				else {
					break _loop671;
				}
				
			} while (true);
			}
			{
			int _cnt673=0;
			_loop673:
			do {
				if (_t==null) _t=ASTNULL;
				if ((_tokenSet_0.member(_t.getType()))) {
					tsObj=typeSpecifier(_t);
					_t = _retTree;
					if ( inputState.guessing==0 ) {
							builderObj.addTypeSpecifier(tsObj);
																				
					}
				}
				else {
					if ( _cnt673>=1 ) { break _loop673; } else {throw new NoViableAltException(_t);}
				}
				
				_cnt673++;
			} while (true);
			}
			AST __t674 = _t;
			i = _t==ASTNULL ? null :(TNode)_t;
			match(_t,NInitDecl);
			_t = _t.getFirstChild();
			fdeclrObj=interfaceMemberFunctionDeclarator(_t);
			_t = _retTree;
			if ( inputState.guessing==0 ) {
				
																			try {
																			
																				builderObj.addDeclarator(fdeclrObj);
					                											if(builderObj.getDeclarator() instanceof Declarator) {
					                												Declarator namedDeclObj = (Declarator)builderObj.getDeclarator();
					                												fdeclnObj.setNameNode(namedDeclObj.getNameNode());
					                												
					                											}
																				fdeclnObj.setType(builderObj.getType());
																				fdeclnObj.addToScope(ctx);             												
					            												Scope scope = new Scope("function " + fdeclnObj.getName(), ctx.getCurrentScope());
					            												ctx.pushScope(scope);
					            												fdeclnObj.addParametersToScope(ctx);
					            												ctx.popScope();            												
																			} catch (TypeResolutionException ex) {
																				ctx.addMsg(new ParserMessage(ParserMessage.ERROR, ex.getMessage(), new CodeLocation(fdeclrObj.getDefNode()), ex));
																			}
																		
			}
			_t = __t674;
			_t = _t.getNextSibling();
			{
			int _cnt676=0;
			_loop676:
			do {
				if (_t==null) _t=ASTNULL;
				if ((_t.getType()==SEMI)) {
					TNode tmp1_AST_in = (TNode)_t;
					match(_t,SEMI);
					_t = _t.getNextSibling();
				}
				else {
					if ( _cnt676>=1 ) { break _loop676; } else {throw new NoViableAltException(_t);}
				}
				
				_cnt676++;
			} while (true);
			}
			_t = __t667;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
		return fdeclnObj;
	}
	
	public final SynchronySpecifier  synchronySpecifier(AST _t) throws RecognitionException {
		SynchronySpecifier ssObj;
		
		TNode synchronySpecifier_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
		TNode d = null;
			ssObj = new SynchronySpecifier();
		
		try {      // for error handling
			d = (TNode)_t;
			match(_t,LITERAL_async);
			_t = _t.getNextSibling();
			if ( inputState.guessing==0 ) {
					ssObj.setDefNode(d);
			}
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
		return ssObj;
	}
	
	public final DirectionSpecifier  directionSpecifier(AST _t) throws RecognitionException {
		DirectionSpecifier dsObj;
		
		TNode directionSpecifier_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
		TNode f = null;
		TNode g = null;
			dsObj = new DirectionSpecifier();
		
		try {      // for error handling
			if (_t==null) _t=ASTNULL;
			switch ( _t.getType()) {
			case LITERAL_command:
			{
				f = (TNode)_t;
				match(_t,LITERAL_command);
				_t = _t.getNextSibling();
				if ( inputState.guessing==0 ) {
						dsObj.setDefNode(f);
				}
				break;
			}
			case LITERAL_event:
			{
				g = (TNode)_t;
				match(_t,LITERAL_event);
				_t = _t.getNextSibling();
				if ( inputState.guessing==0 ) {
						dsObj.setDefNode(g);
				}
				break;
			}
			default:
			{
				throw new NoViableAltException(_t);
			}
			}
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
		return dsObj;
	}
	
	public final TypeQualifier  typeQualifier(AST _t) throws RecognitionException {
		TypeQualifier tqObj;
		
		TNode typeQualifier_AST_in = (_t == ASTNULL) ? null : (TNode)_t;
		TNode a = null;
		TNode b = null;
			tqObj = new TypeQualifier();
		
		try {      // for error handling
			if (_t==null) _t=ASTNULL;
			switch ( _t.getType()) {
			case LITERAL_const:
			{
				a = (TNode)_t;

⌨️ 快捷键说明

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