Lines Matching refs:token

163    Token token;
164 skipCommentTokens( token );
171 // Set error location to start of doc, ideally should be first token found in doc
172 token.type_ = tokenError;
173 token.start_ = beginDoc;
174 token.end_ = endDoc;
176 token );
187 Token token;
188 skipCommentTokens( token );
198 switch ( token.type_ )
201 successful = readObject( token );
204 successful = readArray( token );
207 successful = decodeNumber( token );
210 successful = decodeString( token );
222 return addError( "Syntax error: value, object or array expected.", token );
236 Reader::skipCommentTokens( Token &token )
242 readToken( token );
244 while ( token.type_ == tokenComment );
248 readToken( token );
254 Reader::expectToken( TokenType type, Token &token, const char *message )
256 readToken( token );
257 if ( token.type_ != type )
258 return addError( message, token );
264 Reader::readToken( Token &token )
267 token.start_ = current_;
273 token.type_ = tokenObjectBegin;
276 token.type_ = tokenObjectEnd;
279 token.type_ = tokenArrayBegin;
282 token.type_ = tokenArrayEnd;
285 token.type_ = tokenString;
289 token.type_ = tokenComment;
303 token.type_ = tokenNumber;
307 token.type_ = tokenTrue;
311 token.type_ = tokenFalse;
315 token.type_ = tokenNull;
319 token.type_ = tokenArraySeparator;
322 token.type_ = tokenMemberSeparator;
325 token.type_ = tokenEndOfStream;
332 token.type_ = tokenError;
333 token.end_ = current_;
549 Token token;
551 ok = readToken( token );
552 while ( token.type_ == tokenComment && ok )
554 ok = readToken( token );
556 bool badTokenType = ( token.type_ != tokenArraySeparator &&
557 token.type_ != tokenArrayEnd );
561 token,
564 if ( token.type_ == tokenArrayEnd )
572 Reader::decodeNumber( Token &token )
575 for ( Location inspect = token.start_; inspect != token.end_; ++inspect )
579 || ( *inspect == '-' && inspect != token.start_ );
582 return decodeDouble( token );
586 Location current = token.start_;
594 while ( current < token.end_ )
598 return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
607 current != token.end_ ||
610 return decodeDouble( token );
626 Reader::decodeDouble( Token &token )
631 int length = int(token.end_ - token.start_);
635 return addError( "Unable to parse token length", token );
648 memcpy( buffer, token.start_, length );
654 std::string buffer( token.start_, token.end_ );
659 return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
666 Reader::decodeString( Token &token )
669 if ( !decodeString( token, decoded ) )
677 Reader::decodeString( Token &token, std::string &decoded )
679 decoded.reserve( token.end_ - token.start_ - 2 );
680 Location current = token.start_ + 1; // skip '"'
681 Location end = token.end_ - 1; // do not include '"'
690 return addError( "Empty escape sequence in string", token, current );
705 if ( !decodeUnicodeCodePoint( token, current, end, unicode ) )
711 return addError( "Bad escape sequence in string", token, current );
723 Reader::decodeUnicodeCodePoint( Token &token,
729 if ( !decodeUnicodeEscapeSequence( token, current, end, unicode ) )
735 return addError( "additional six characters expected to parse unicode surrogate pair.", token, current );
739 if (decodeUnicodeEscapeSequence( token, current, end, surrogatePair ))
747 return addError( "expecting another \\u token to begin the second half of a unicode surrogate pair", token, current );
753 Reader::decodeUnicodeEscapeSequence( Token &token,
759 return addError( "Bad unicode escape sequence in string: four digits expected.", token, current );
772 return addError( "Bad unicode escape sequence in string: hexadecimal digit expected.", token, current );
780 Token &token,
784 info.token_ = token;
811 Token &token,
814 addError( message, token );