Ejemplo n.º 1
0
 private static void ExtractText(CString obj, StringBuilder target)
 {
     target.Append(obj.Value);
 }
Ejemplo n.º 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
                }
            }
        }
Ejemplo n.º 3
0
 private void ExtractText(CString obj, StringBuilder target)
 {
     lastString = obj.Value;
 }
Ejemplo n.º 4
0
 private static void Write(CString obj)
 {
     Console.Write("str:{0}", obj.Value);
 }
Ejemplo n.º 5
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: ']'");
        }
      }
    }