Example #1
0
 private static void ExtractText(CReal obj, StringBuilder target) { /* nothing */ }
Example #2
0
        /// <summary>
        /// Parses whatever comes until the specified stop symbol is reached.
        /// </summary>
        void ParseObject(CSequence sequence, CSymbol stop)
        {
            CSymbol symbol;
            while ((symbol = ScanNextToken()) != CSymbol.Eof)
            {
                if (symbol == stop)
                    return;

                CString s;
                COperator op;
                switch (symbol)
                {
                    case CSymbol.Comment:
                        // ignore comments
                        break;

                    case CSymbol.Integer:
                        CInteger n = new CInteger();
                        n.Value = _lexer.TokenToInteger;
                        _operands.Add(n);
                        break;

                    case CSymbol.Real:
                        CReal r = new CReal();
                        r.Value = _lexer.TokenToReal;
                        _operands.Add(r);
                        break;

                    case CSymbol.String:
                    case CSymbol.HexString:
                    case CSymbol.UnicodeString:
                    case CSymbol.UnicodeHexString:
                        s = new CString();
                        s.Value = _lexer.Token;
                        _operands.Add(s);
                        break;

                    case CSymbol.Dictionary:
                        s = new CString();
                        s.Value = _lexer.Token;
                        s.CStringType = CStringType.Dictionary;
                        _operands.Add(s);
                        op = CreateOperator(OpCodeName.Dictionary);
                        //_operands.Clear();
                        sequence.Add(op);

                        break;

                    case CSymbol.Name:
                        CName name = new CName();
                        name.Name = _lexer.Token;
                        _operands.Add(name);
                        break;

                    case CSymbol.Operator:
                        op = CreateOperator();
                        //_operands.Clear();
                        sequence.Add(op);
                        break;

                    case CSymbol.BeginArray:
                        CArray array = new CArray();
                        if (_operands.Count != 0)
                            ContentReaderDiagnostics.ThrowContentReaderException("Array within array...");

                        ParseObject(array, CSymbol.EndArray);
                        array.Add(_operands);
                        _operands.Clear();
                        _operands.Add((CObject)array);
                        break;

                    case CSymbol.EndArray:
                        ContentReaderDiagnostics.HandleUnexpectedCharacter(']');
                        break;

#if DEBUG
                    default:
                        Debug.Assert(false);
                        break;
#endif
                }
            }
        }
Example #3
0
    /// <summary>
    /// Parses whatever comes until the specified stop symbol is reached.
    /// </summary>
    void ParseObject(CSequence sequence, CSymbol stop)
    {
      CSymbol symbol;
      while ((symbol = ScanNextToken()) != CSymbol.Eof)
      {
        if (symbol == stop)
          return;

        switch (symbol)
        {
          case CSymbol.Comment:
            // ignore comments
            break;

          case CSymbol.Integer:
            CInteger n = new CInteger();
            n.Value = this.lexer.TokenToInteger;
            this.operands.Add(n);
            break;

          case CSymbol.Real:
            CReal r = new CReal();
            r.Value = this.lexer.TokenToReal;
            this.operands.Add(r);
            break;

          case CSymbol.String:
          case CSymbol.HexString:
          case CSymbol.UnicodeString:
          case CSymbol.UnicodeHexString:
            CString s = new CString();
            s.Value = this.lexer.Token;
            this.operands.Add(s);
            break;

          case CSymbol.Name:
            CName name = new CName();
            name.Name = this.lexer.Token;
            this.operands.Add(name);
            break;

          case CSymbol.Operator:
            COperator op = CreateOperator();
            this.operands.Clear();
            sequence.Add(op);
            break;

          case CSymbol.BeginArray:
            CArray array = new CArray();
            Debug.Assert(this.operands.Count == 0, "Array within array...");
            ParseObject(array, CSymbol.EndArray);
            array.Add(this.operands);
            this.operands.Clear();
            this.operands.Add((CObject)array);
            break;

          case CSymbol.EndArray:
            throw new ContentReaderException("Unexpected: ']'");
        }
      }
    }
Example #4
0
 private static void Write(CReal obj)
 {
     Console.Write("real:{0}", obj.Value);
 }
 private static void ExtractText(CReal obj, StringBuilder target) { Console.WriteLine(obj.Value); }