Ejemplo n.º 1
0
        public void Load(TextReader reader)
        {
            var tokens = Tokenize(reader).GetEnumerator();

            if (!tokens.MoveNext() || !SkipNewlines(tokens) || tokens.Current == "{" || tokens.Current == "}")
            {
                throw new System.IO.InvalidDataException("Expected shader name.");
            }

            string name = tokens.Current;

            if (!tokens.MoveNext())
            {
                throw new System.IO.InvalidDataException("Expected group.");
            }
            Root = ParseGroup(tokens, name);

            if (tokens.MoveNext())
            {
                if (SkipNewlines(tokens))
                {
                    throw new System.IO.InvalidDataException("Expected end of file.");
                }
            }
        }
Ejemplo n.º 2
0
        private VmtGroupNode ParseGroup(IEnumerator <string> tokens, string name)
        {
            VmtGroupNode node = new VmtGroupNode();

            node.Name = name;

            if (!SkipNewlines(tokens) || tokens.Current != "{")
            {
                throw new System.IO.InvalidDataException("Expected open brace.");
            }

            while (true)
            {
                if (!tokens.MoveNext() || !SkipNewlines(tokens) || tokens.Current == "{")
                {
                    throw new System.IO.InvalidDataException("Expected node name or close brace.");
                }

                //wont find } untill here
                if (tokens.Current == "}")
                {
                    break;
                }

                string nodeName = tokens.Current;
                if (!tokens.MoveNext())
                {
                    throw new System.IO.InvalidDataException("Expected node value or open brace.");
                }

                if (tokens.Current != Environment.NewLine && tokens.Current != "{")
                {
                    node.ChildNodes.Add(ParseValue(tokens, nodeName));
                }
                else
                {
                    node.ChildNodes.Add(ParseGroup(tokens, nodeName));
                }
            }
            return(node);
        }
Ejemplo n.º 3
0
        private VmtGroupNode ParseGroup(IEnumerator<string> tokens, string name)
        {
            VmtGroupNode node = new VmtGroupNode();
            node.Name = name;

            if (!SkipNewlines(tokens) || tokens.Current != "{")
                throw new System.IO.InvalidDataException("Expected open brace.");         

            while (true)
            {
                if (!tokens.MoveNext() || !SkipNewlines(tokens) || tokens.Current == "{")
                    throw new System.IO.InvalidDataException("Expected node name or close brace.");

                //wont find } untill here 
                if (tokens.Current == "}")
                    break;

                string nodeName = tokens.Current;
                if (!tokens.MoveNext())
                    throw new System.IO.InvalidDataException("Expected node value or open brace.");
                
                if(tokens.Current != Environment.NewLine && tokens.Current != "{")
                    node.ChildNodes.Add(ParseValue(tokens, nodeName));
                else
                    node.ChildNodes.Add(ParseGroup(tokens, nodeName));
            }
            return node;
        }
Ejemplo n.º 4
0
        public void Load(TextReader reader)
        {
            var tokens = Tokenize(reader).GetEnumerator();

            if (!tokens.MoveNext() || !SkipNewlines(tokens) || tokens.Current == "{" || tokens.Current == "}")
                throw new System.IO.InvalidDataException("Expected shader name.");

            string name = tokens.Current;
            if (!tokens.MoveNext())
                throw new System.IO.InvalidDataException("Expected group.");
            Root = ParseGroup(tokens, name);

            if (tokens.MoveNext())
            {
                if (SkipNewlines(tokens))
                    throw new System.IO.InvalidDataException("Expected end of file.");
            }
        }