Exemplo n.º 1
0
 private void InnerParse()
 {
     try
     {
         for (int c = _indexOfTheChar; c < _sourceString.Length; c++)
         {
             ParseNextSymbol();
         }
     }
     catch
     {
         if (_sourceString.Length > (_indexOfTheChar + 1)) //if inccorrect symbol is inside of the string
         {
             Debug.WriteLine($"Unexpected symbol under index: {_indexOfTheChar}. Total Length : {_sourceString.Length}");
             InnerParse();
         }
     }
     if (_itemStack.Count == 1 && _keyValueStack.Count == 1)
     {
         _currentItem = _itemStack.Peek();
         if (_currentItem is JRoot && !_currentItem.HasItems())
         {
             (_currentItem as JRoot).Add(JItemFactory.JSingleValue(_JItemContentsBuffer.Replace(" ", "").ToString(), _currentItem));
             _JItemContentsBuffer.Clear();
         }
     }
 }
Exemplo n.º 2
0
 private void HandleColon()
 {
     _currentKeyValuePair = _keyValueStack.Peek();
     _currentItem         = _itemStack.Peek();
     _syntaxChars.Push(':');
     if (!_pendingForPairValue)
     {
         JKeyValuePair pair =
             new JKeyValuePair(JItemFactory.JSingleValue(_JItemContentsBuffer.ToString()), null);
         (_currentItem as JCollection).Add(pair);
         _keyValueStack.Push(pair);
     }
     else
     {
         //throw new InvalidEnumArgumentException();
     }
     _pendingForPairValue = true;
     _JItemContentsBuffer.Clear();
 }
Exemplo n.º 3
0
 private void HandleClosingCurlyBracket()
 {
     _currentKeyValuePair = _keyValueStack.Peek();
     _currentItem         = _itemStack.Peek();
     if (_pendingForPairValue)
     {
         JItem item = JItemFactory.JSingleValue(_JItemContentsBuffer.ToString(), _currentItem);
         _currentKeyValuePair.Value = item;
         _JItemContentsBuffer.Clear();
         _keyValueStack.Pop();
         _pendingForPairValue = false;
     }
     else
     {
         if (!string.IsNullOrWhiteSpace(_JItemContentsBuffer.ToString()))
         {
             _currentItem.Add(JItemFactory.JSingleValue(_JItemContentsBuffer.ToString(), _currentItem));
             _JItemContentsBuffer.Clear();
         }
     }
     _itemStack.Pop();
 }
Exemplo n.º 4
0
 private void HandleComma()
 {
     _currentKeyValuePair = _keyValueStack.Peek();
     _currentItem         = _itemStack.Peek();
     if (_pendingForPairValue)
     {
         JItem jI = JItemFactory.JSingleValue(_JItemContentsBuffer.ToString(), _currentItem);
         _currentKeyValuePair.Value = jI;
         _keyValueStack.Pop();
         _pendingForPairValue = false;
     }
     else
     {
         if (!string.IsNullOrWhiteSpace(_JItemContentsBuffer.ToString()))
         {
             (_currentItem as JCollection).Add(JItemFactory.JSingleValue(_JItemContentsBuffer.ToString(), _currentItem));
             _JItemContentsBuffer.Clear();
             return;
         }
     }
     _syntaxChars.Push(',');
     _JItemContentsBuffer.Clear();
 }