예제 #1
0
        private Tuple <ParsedObject, int> ParseJsonObject(string text, int currentPoint)
        {
            ParsedObject parsedObject = new ParsedObject(ParsedObject.Type.NestedType);

            while (true)
            {
                Tuple <string, int> nextKey = GetJsonKey(text, currentPoint);
                currentPoint = nextKey.Item2 + 1;
                Tuple <ParsedObject, int> nextValue = GetJsonValue(text, currentPoint);
                currentPoint = nextValue.Item2;
                parsedObject.AddSubObjectByKey(nextKey.Item1, nextValue.Item1);
                while (gapSymbols.Contains(Convert.ToString(text[currentPoint])))
                {
                    currentPoint++;
                }
                if (text[currentPoint] == '}')
                {
                    break;
                }
                currentPoint++;
            }

            return(new Tuple <ParsedObject, int>(parsedObject, currentPoint));
        }
예제 #2
0
파일: XMLParser.cs 프로젝트: Miuroku/3_Term
        private ParsedObject Go()
        {
            ParsedObject newObject;

            if (!isNextSymbolIsBracket())
            {
                newObject = new ParsedObject(ParsedObject.Type.SingleValue);
                newObject.SetValue(ReadTillBracket());
                return(newObject);
            }

            newObject = new ParsedObject(ParsedObject.Type.NestedType);
            while (true)
            {
                string tag = ReadTag();
                newObject.AddSubObjectByKey(tag, Go());
                ReadTag(); // closing
                if (isNextTagIsClosing())
                {
                    break;
                }
            }
            return(newObject);
        }