Ejemplo n.º 1
0
 protected Classification classify(dynamic curr)
 {
     if (curr.GetType() == typeof(JValue))
     {
         return(LithpParser.Classify(curr.ToString()));
     }
     return(Classification.COMPILED);
 }
Ejemplo n.º 2
0
        protected ILithpOpChainMember mapParamInner(JValue v, LithpOpChain chain, string fnName)
        {
            Classification cls  = classify(v);
            string         strV = v.ToString();

            parserDebug("Classified: {0}", cls.ToString());
            if (cls.HasFlag(Classification.STRING_DOUBLE) || cls.HasFlag(Classification.STRING_SINGLE))
            {
                strV = strV.Substring(1, strV.Length - 2);
                string parsed = LithpParser.ParseEscapes(strV);
                if (cls.HasFlag(Classification.STRING_DOUBLE))
                {
                    return(new LithpLiteral(new LithpString(parsed)));
                }
                else if (cls.HasFlag(Classification.STRING_SINGLE))
                {
                    return(LithpAtom.Atom(parsed));
                }
            }
            else if (cls.HasFlag(Classification.VARIABLE))
            {
                switch (fnName)
                {
                case "get":
                case "set":
                case "var":
                    return(new LithpVariableReference(strV));

                default:
                    return(LithpFunctionCall.New("get/1", new LithpVariableReference(strV)));
                }
            }
            else if (cls.HasFlag(Classification.NUMBER))
            {
                if (cls.HasFlag(Classification.NUMBER_INTEGER))
                {
                    return(new LithpLiteral(new LithpInteger(strV)));
                }
                else if (cls.HasFlag(Classification.NUMBER_FLOAT))
                {
                    return(new LithpLiteral(new LithpFloat(strV)));
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            else if (cls.HasFlag(Classification.ATOM))
            {
                return(new LithpLiteral(LithpAtom.Atom(strV)));
            }
            throw new NotImplementedException();
        }