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."); } } }
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); }
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; }
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."); } }