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

📄 debug.java

📁 JAVA 数学程序库 提供常规的数值计算程序包
💻 JAVA
字号:
package jmathlib.toolbox.jmathlib.system;

import jmathlib.core.interpreter.*;
import jmathlib.core.functions.ExternalFunction;
import jmathlib.core.tokens.Token;
import jmathlib.core.tokens.CharToken;
import jmathlib.core.tokens.OperandToken;

/**Display the debug information of an expression*/
public class debug extends ExternalFunction
{
	/**Executes an expression, displaying the parse tree.
	@param operand[0] = the string containing the expression
	@return the result of the expression*/
	public OperandToken evaluate(Token[] operands)
	{
		String answer = "";
		if(operands[0] instanceof CharToken)
		{
			Parser p = new Parser();
		
			String expression = ((CharToken)operands[0]).toString();
			// separate expression into tokens and return tree of expressions
            OperandToken expressionTree = p.parseExpression(expression);

			// open a tree to show the expression-tree for a parsed command
            jmathlib.tools.treeanalyser.TreeAnalyser treeAnalyser = new jmathlib.tools.treeanalyser.TreeAnalyser(expressionTree);

	        OperandToken answerToken = expressionTree.evaluate(null);
			//while(answerToken != null)
			//{        
	        	if(answerToken != null)
	        	{
		            //storeAnswer(answerToken);
	
					//if(answerToken.display)
		            //	answer += answerToken.toString() + "\n";

		            answerToken = expressionTree.evaluate(null);
		          
		        }
	        //}
		}

		return new CharToken(answer);				
	}
}

/*
@GROUP
system
@SYNTAX
DEBUG(expression)
@DOC
This evaluates expression, displaying the op tree which is created.
@NOTES
@EXAMPLES
DEBUG("3*5")=15
@SEE
*/

⌨️ 快捷键说明

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