Exemple #1
0
        public static void Include(string filename)
        {
            string path = Water.FileReader.ResolvePath(filename);

            Water.Dictionary includes = Water.Environment.Includes;
            if (includes[path] == null)
            {
                includes.Add(path, path);



                Water.FileReader reader = null;
                try
                {
                    reader = new Water.FileReader(path);

                    Water.Interpreter.Interpret(new Water.Iterator(reader));
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }
            }
        }
Exemple #2
0
        private static void ParseDictEntry(Water.TextReader reader, Water.Dictionary dict)
        {
            #region ParseDictEntry

            TrimWhitespace(reader);

            string name = ParseName(reader);

            TrimWhitespace(reader);

            if (reader.Peek() == ':')
            {
                reader.Read();
            }
            else
            {
                throw new Water.Error("Parser error: Invalid dictionary entry name: " + name);
            }

            TrimWhitespace(reader);

            dict.Add(name, Parse(reader));

            #endregion
        }
Exemple #3
0
        public static void DefineConstant(string name, object value)
        {
            if (IsConstant(name))
            {
                throw new Water.Error("Constant \"" + name + "\" is already defined.");
            }

            if (value == null)
            {
                throw new Water.Error("Cannot define \"" + name + "\" as a null value.");
            }

            _constants.Add(name, value);
        }
Exemple #4
0
        public static void DefineVariable(string name, object value)
        {
            if (IsConstant(name))
            {
                throw new Water.Error("Constant \"" + name + "\" is already defined.");
            }

            Water.Dictionary frame = (Water.Dictionary)_variables[_stackDepth - 1];
            if (frame.IsDefined(name))
            {
                frame.Remove(name);
            }
            frame.Add(name, value);
        }
Exemple #5
0
        private object CheckQuote(object o)
        {
            if (o is Water.List)
            {
                Water.List list = (Water.List)o;

                Water.List results = new Water.List();
                foreach (object item in list)
                {
                    results.Add(CheckQuote(item));
                }
                return(results);
            }
            else if (o is Water.Dictionary)
            {
                Water.Dictionary dictionary = (Water.Dictionary)o;

                Water.Dictionary results = new Water.Dictionary();
                foreach (string key in dictionary)
                {
                    results.Add(key, CheckQuote(dictionary[key]));
                }
                return(results);
            }
            else if (o is Water.Comma)
            {
                Water.Comma comma = (Water.Comma)o;

                return(comma.Evaluate(new Water.List()));
            }
            else if (o is System.String)
            {
                System.String s = (System.String)o;

                return(Water.Evaluator.EvaluateString(s));
            }
            else
            {
                return(o);
            }
        }