//生成语法树的一个节点 static ExprNode MakeExprNode(Common.Token_Type opcode, params Object[] exprNodes) { ExprNode ExprPtr = new ExprNode(); ExprPtr.OpCode = opcode; switch (opcode) { case Common.Token_Type.CONST_ID: ExprPtr.CaseConst = (double)exprNodes[0]; break; case Common.Token_Type.T: // ExprPtr.CaseParmPtr = double.Parse((string)exprNodes[0]);// can find &Parameter in C# ExprPtr.CaseParmPtr = Common.Change; break; case Common.Token_Type.FUNC: ExprPtr.MathFuncPtr = (Common.FuncPtr)exprNodes[0]; ExprPtr.Child = (ExprNode)exprNodes[1]; break; default: ExprPtr.Left = (ExprNode)exprNodes[0]; ExprPtr.Right = (ExprNode)exprNodes[1]; break; } return(ExprPtr); }
public Token(Common.Token_Type type, string lexeme, double value, Common.FuncPtr func) { this.type = type; this.lexeme = lexeme; this.value = value; this.func = func; }
//匹配记号 static void MatchToken(Common.Token_Type The_Token) { if (token.type != The_Token) { // Console.Error.WriteLine("Error in MatchToken"); SyntaxError(2); } FetchToken(); }