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

📄 formalparametersnode.java

📁 是有关解释器的.用JAVA编写.可以解释一般的JAVA程序.
💻 JAVA
字号:
class FormalParametersNode extends ExecutableNode
{
	VariableDeclarationNode[] vVariableDeclarationNodes;

	int vFormalParametersCount;
	int vFormalParametersSize;
	
	static FormalParametersNode parserFormalParameters(Environment env,Scanner s) throws ParserException, ScannerException
	{
		FormalParametersNode tmpFormalParametersNode= new FormalParametersNode();
		
		matchBracket(s,'(');
		if(!isBracketToken(s,')'))
		{
			tmpFormalParametersNode.mPushVariableDeclaration(VariableDeclarationNode.parserVariableDeclaration(env,s));
			while(!isBracketToken(s,')'))
			{
				matchSimple(s,',');
				tmpFormalParametersNode.mPushVariableDeclaration(VariableDeclarationNode.parserVariableDeclaration(env,s));				
			}
		}
		matchBracket(s,')');
		
		return tmpFormalParametersNode;			
	}
	void mPushVariableDeclaration(VariableDeclarationNode aVariableDeclarationNode)
	{
		if(mFullFormalParametersBuf())mAutoResizeFormalParametersBuf();
		vVariableDeclarationNodes[vFormalParametersCount]= aVariableDeclarationNode;
		vFormalParametersCount++;
	}
	VariableDeclarationNode mPopVariableDeclaration()
	{
		if(!mEmptyFormalParametersBuf())
		{
			vFormalParametersCount--;
			return vVariableDeclarationNodes[vFormalParametersCount];
		}
		else return null;
	}
	boolean mEmptyFormalParametersBuf()
	{
		return vFormalParametersCount==0;
	}
	boolean mFullFormalParametersBuf()
	{
		return vFormalParametersSize==vFormalParametersCount;
	}
	void mResizeFormalParametersBuf(int aNewFormalParametersSize)
	{		
		if(aNewFormalParametersSize>vFormalParametersCount)
		{
			VariableDeclarationNode[] tmpVariableDeclarationNodes;
			tmpVariableDeclarationNodes= new VariableDeclarationNode[aNewFormalParametersSize];
			for(int i=0;i<vFormalParametersCount;i++)
				tmpVariableDeclarationNodes[i]= vVariableDeclarationNodes[i];
			vFormalParametersSize= aNewFormalParametersSize;
			vVariableDeclarationNodes= tmpVariableDeclarationNodes;
		}
	}
	void mAutoResizeFormalParametersBuf()
	{
		mResizeFormalParametersBuf(vFormalParametersSize*2);
	}
	
	FormalParametersNode()
	{
		vFormalParametersSize= 4;
		vFormalParametersCount= 0;
		vVariableDeclarationNodes= new VariableDeclarationNode[vFormalParametersSize];
	}
	FormalParametersNode(int aFormalParametersSize)
	{
		vFormalParametersSize= aFormalParametersSize;
		vFormalParametersCount= 0;
		vVariableDeclarationNodes= new VariableDeclarationNode[aFormalParametersSize];
	}
	
	String format(int indent)
	{
		String str="(";
		if(vFormalParametersCount>0)str+= vVariableDeclarationNodes[0].format(indent);
		for(int i=1; i<vFormalParametersCount; i++)
			str+= ", "+vVariableDeclarationNodes[i].format(indent);		
		return str+")";
	}
	Environment run(Environment env) throws InterpreterException
	{
		return env;
	}
	boolean typeCheck(Environment env) throws InterpreterException
	{
		for(int i=0; i<vFormalParametersCount; i++)
			vVariableDeclarationNodes[i].typeCheck(env);
		
		return true;
	}
}

⌨️ 快捷键说明

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