示例#1
0
        //生成语法树的一个节点
        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);
        }
示例#2
0
 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;
 }
示例#3
0
        //匹配记号
        static void MatchToken(Common.Token_Type The_Token)
        {
            if (token.type != The_Token)
            {
//                Console.Error.WriteLine("Error in MatchToken");
                SyntaxError(2);
            }
            FetchToken();
        }