Esempio n. 1
0
        public static int GetLhsObj(string lhs)
        {
            int result;

            if (Int32.TryParse(lhs, out result))
            {
                return(result);
            }
            else if (lhs.IndexOf(".") != -1)
            {
                Game   g    = Game.GetInstance();
                string left = lhs.Substring(0, lhs.IndexOf("."));

                if (g.IsVariable(left))
                {
                    return(g.GetVarVal(left));
                }
                else
                {
                    return(g.GetObjectId(left));
                }
            }
            else
            {
                Game g = Game.GetInstance();
                return(g.GetObjectId(lhs));
            }
        }
Esempio n. 2
0
        public static Node ToNode(string rhs)
        {
            Game g = Game.GetInstance();

            rhs = rhs.Trim();
            int result;

            if (Int32.TryParse(rhs, out result))
            {
                return(new Constant(result));
            }
            else if (rhs.ToUpper() == "TRUE")
            {
                return(new Constant(1));
            }
            else if (rhs.ToUpper() == "FALSE")
            {
                return(new Constant(0));
            }
            else if (rhs.IndexOf('"') == 0)
            {
                rhs = rhs.Replace("\"", string.Empty);
                return(new Constant(g.GetStringId(rhs)));
            }
            else if (rhs.IndexOf('.') != -1)
            {
                string left  = rhs.Substring(0, rhs.IndexOf('.'));
                string right = rhs.Substring(rhs.IndexOf('.') + 1, rhs.Length - rhs.IndexOf('.') - 1);
                return(new Attr(left, right));
            }
            else if (g.GetObjectId(rhs) != -1)
            {
                return(new Constant(g.GetObjectId(rhs)));
            }
            else if (g.IsVariable(rhs))
            {
                return(new GameVar(rhs));
            }
            else
            {
                throw new Exception("Don't know what to do with " + rhs);
            }
        }