This class contains methods used to tokenize HOCON (Human-Optimized Config Object Notation) configuration strings.
Inheritance: Tokenizer
Example #1
0
        /// <summary>
        /// Parses the text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns>HoconValue.</returns>
        /// <exception cref="System.Exception">Unresolved substitution: + sub.Path</exception>
        private HoconRoot ParseText(string text)
        {
            root = new HoconValue();
            reader = new HoconTokenizer(text);
            reader.PullWhitespaceAndComments();
            ParseObject(root, true);

            var c = new Config(new HoconRoot(root,Enumerable.Empty<HoconSubstitution>()));
            foreach (HoconSubstitution sub in substitutions)
            {
                HoconValue res = c.GetValue(sub.Path);
                if (res == null)
                    throw new Exception("Unresolved substitution:" + sub.Path);
                sub.ResolvedValue = res;
            }
            return new HoconRoot(root, substitutions);
        }
Example #2
0
        private HoconRoot ParseText(string text,Func<string,HoconRoot> includeCallback)
        {
            _includeCallback = includeCallback;
            _root = new HoconValue();
            _reader = new HoconTokenizer(text);
            _reader.PullWhitespaceAndComments();
            ParseObject(_root, true,"");

            var c = new Config(new HoconRoot(_root, Enumerable.Empty<HoconSubstitution>()));
            foreach (HoconSubstitution sub in _substitutions)
            {
                HoconValue res = c.GetValue(sub.Path);
                if (res == null)
                    throw new FormatException("Unresolved substitution:" + sub.Path);
                sub.ResolvedValue = res;
            }
            return new HoconRoot(_root, _substitutions);
        }
Example #3
0
        private HoconValue ParseText(string text)
        {
            root   = new HoconValue();
            reader = new HoconTokenizer(text);
            reader.PullWhitespaceAndComments();
            ParseObject(root, true);

            var c = new Config(root);

            foreach (HoconSubstitution sub in substitutions)
            {
                HoconValue res = c.GetValue(sub.Path);
                if (res == null)
                {
                    throw new Exception("Unresolved substitution:" + sub.Path);
                }
                sub.ResolvedValue = res;
            }
            return(root);
        }
Example #4
0
        /// <summary>
        ///     Parses the text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns>HoconValue.</returns>
        /// <exception cref="System.Exception">Unresolved substitution: + sub.Path</exception>
        private HoconRoot ParseText(string text)
        {
            _root   = new HoconValue();
            _reader = new HoconTokenizer(text);
            _reader.PullWhitespaceAndComments();
            ParseObject(_root, true);

            var c = new Config(new HoconRoot(_root, Enumerable.Empty <HoconSubstitution>()));

            foreach (HoconSubstitution sub in _substitutions)
            {
                HoconValue res = c.GetValue(sub.Path);
                if (res == null)
                {
                    throw new Exception("Unresolved substitution:" + sub.Path);
                }
                sub.ResolvedValue = res;
            }
            return(new HoconRoot(_root, _substitutions));
        }
Example #5
0
        private HoconRoot ParseText(string text, Func <string, HoconRoot> includeCallback)
        {
            _includeCallback = includeCallback;
            _root            = new HoconValue();
            _reader          = new HoconTokenizer(text);
            _reader.PullWhitespaceAndComments();
            ParseObject(_root, true, "");

            var c = new Config(new HoconRoot(_root, Enumerable.Empty <HoconSubstitution>()));

            foreach (HoconSubstitution sub in _substitutions)
            {
                HoconValue res = c.GetValue(sub.Path);
                if (res == null)
                {
                    throw new FormatException($"Unresolved substitution: {sub.Path}");
                }
                sub.ResolvedValue = res;
            }
            return(new HoconRoot(_root, _substitutions));
        }