Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Node ParseText1(string text)
- {
- List<Node> last = new List<Node>();
- Node cur = new Node();
- string buf = "";
- bool quotes = false;
- for (int i = 1; i < text.Length - 1; i++)
- {
- char c = text[i];
- if (c == '{')
- {
- last.Add(cur);
- cur = new Node();
- continue;
- }
- if (c == '}')
- {
- if (!(text[i - 1] == '}'))
- {
- cur.Nodes.Add(new Node() { Value = buf });
- buf = "";
- }
- last.Last().Nodes.Add(cur);
- cur = last.Last();
- last.Remove(cur);
- continue;
- }
- if (c == '"')
- quotes = !quotes;
- if (!(text[i - 1] == '}'))
- {
- if (c == ',' && !quotes)
- {
- cur.Nodes.Add(new Node() { Value = buf });
- buf = "";
- }
- else
- {
- buf += c;
- }
- }
- }
- return cur;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement