コード例 #1
0
        public DoubleNode Double(string value)
        {
            DoubleNode doubleNode = new DoubleNode();

            Match(TokenType.DOUBLE);
            doubleNode.Value = double.Parse(value);
            return(doubleNode);
        }
コード例 #2
0
        protected void MethodCallNodeExecuteCall <T>(T objectValue, AbstractSyntaxTreeNode item)
        {
            var method = objectValue.GetType().GetMethod(((MethodCallNode)item).Name);

            if (method != null)
            {
                var objectList = new List <object>();
                for (int parameterCount = 0; parameterCount < ((MethodCallNode)item).parameterList.Count; parameterCount++)
                {
                    var parameter = ((MethodCallNode)item).parameterList[parameterCount];
                    if (parameter is StringNode)
                    {
                        var      value    = ((StringNode)parameter).Value;
                        DateTime dateTime = new DateTime();
                        if (DateTime.TryParse(value, out dateTime))
                        {
                            objectList.Add(dateTime);
                        }
                        else
                        {
                            objectList.Add(value);
                        }
                    }
                    else if (parameter is DateTimeNode)
                    {
                        var value = ((DateTimeNode)parameter).Value;
                        objectList.Add(value);
                    }
                    else if (parameter is BooleanNode)
                    {
                        var value = ((BooleanNode)parameter).Value;
                        objectList.Add(value);
                    }
                    else if (parameter is DoubleNode)
                    {
                        var value = ((DoubleNode)parameter).Value;
                        objectList.Add(value);
                    }
                    else if (parameter is IntegerNode)
                    {
                        var value = ((IntegerNode)parameter).Value;
                        objectList.Add(value);
                    }
                }
                var      result = method.Invoke(objectValue, objectList.ToArray());
                int      intOutValue;
                double   doubleOutValue;
                bool     boolOutValue;
                DateTime dateTimeOutValue;
                if (result == null)
                {
                    NullNode nullNode = new NullNode();
                    valueStack.Push(nullNode);
                }
                else if (int.TryParse(result.ToString(), out intOutValue))
                {
                    IntegerNode integerNode = new IntegerNode();
                    integerNode.Value = intOutValue;
                    valueStack.Push(integerNode);
                }
                else if (double.TryParse(result.ToString(), out doubleOutValue))
                {
                    DoubleNode doubleNode = new DoubleNode();
                    doubleNode.Value = doubleOutValue;
                    valueStack.Push(doubleNode);
                }
                else if (bool.TryParse(result.ToString(), out boolOutValue))
                {
                    BooleanNode booleanNode = new BooleanNode();
                    booleanNode.Value = boolOutValue;
                    valueStack.Push(booleanNode);
                }
                else if (DateTime.TryParse(result.ToString(), out dateTimeOutValue))
                {
                    DateTimeNode dateTimeNode = new DateTimeNode();
                    dateTimeNode.Value = dateTimeOutValue;
                    valueStack.Push(dateTimeNode);
                }
                else
                {
                    StringNode stringNode = new StringNode();
                    stringNode.Value = result.ToString();
                    valueStack.Push(stringNode);
                }
            }
        }