Ejemplo n.º 1
0
        private void ReadNullType(bool trailingWhitespace)
        {
            var kwt = trailingWhitespace ? TextConstants.KeywordNone : _scanner.PeekNullTypeSymbol();

            switch (kwt)
            {
            case TextConstants.KeywordNull:
                _valueType = IonType.Null;
                break;

            case TextConstants.KeywordBool:
                _valueType = IonType.Bool;
                break;

            case TextConstants.KeywordInt:
                _valueType = IonType.Int;
                break;

            case TextConstants.KeywordFloat:
                _valueType = IonType.Float;
                break;

            case TextConstants.KeywordDecimal:
                _valueType = IonType.Decimal;
                break;

            case TextConstants.KeywordTimestamp:
                _valueType = IonType.Timestamp;
                break;

            case TextConstants.KeywordSymbol:
                _valueType = IonType.Symbol;
                break;

            case TextConstants.KeywordString:
                _valueType = IonType.String;
                break;

            case TextConstants.KeywordBlob:
                _valueType = IonType.Blob;
                break;

            case TextConstants.KeywordClob:
                _valueType = IonType.Clob;
                break;

            case TextConstants.KeywordList:
                _valueType = IonType.List;
                break;

            case TextConstants.KeywordSexp:
                _valueType = IonType.Sexp;
                break;

            case TextConstants.KeywordStruct:
                _valueType = IonType.Struct;
                break;

            case TextConstants.KeywordNone:
                _valueType = IonType.Null;
                break;     // this happens when there isn't a '.' otherwise peek

            // throws the error or returns none
            default:
                throw new IonException($"invalid keyword id ({kwt}) encountered while parsing a null");
            }

            // at this point we've consumed a dot '.' and it's preceding
            // whitespace
            // clear_value();
            _v.SetNull(_valueType);
        }