예제 #1
0
inline LubeToken _GetToken()
{
    LubeToken token;

    token = s_pContext->GetToken();
    if (Token_string != token) return token;

    ParseStringToken();
    return Token_string;
}
예제 #2
0
JSONReader::Token JSONReader::ParseToken()
{
    EatWhitespaceAndComments();

    Token token(Token::INVALID_TOKEN, 0, 0);
    switch(*json_pos_)
    {
    case '\0':
        token.type = Token::END_OF_INPUT;
        break;

    case 'n':
        if(NextStringMatch(kNullString, arraysize(kNullString)-1))
        {
            token = Token(Token::NULL_TOKEN, json_pos_, 4);
        }
        break;

    case 't':
        if(NextStringMatch(kTrueString, arraysize(kTrueString)-1))
        {
            token = Token(Token::BOOL_TRUE, json_pos_, 4);
        }
        break;

    case 'f':
        if(NextStringMatch(kFalseString, arraysize(kFalseString)-1))
        {
            token = Token(Token::BOOL_FALSE, json_pos_, 5);
        }
        break;

    case '[':
        token = Token(Token::ARRAY_BEGIN, json_pos_, 1);
        break;

    case ']':
        token = Token(Token::ARRAY_END, json_pos_, 1);
        break;

    case ',':
        token = Token(Token::LIST_SEPARATOR, json_pos_, 1);
        break;

    case '{':
        token = Token(Token::OBJECT_BEGIN, json_pos_, 1);
        break;

    case '}':
        token = Token(Token::OBJECT_END, json_pos_, 1);
        break;

    case ':':
        token = Token(Token::OBJECT_PAIR_SEPARATOR, json_pos_, 1);
        break;

    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
    case '-':
        token = ParseNumberToken();
        break;

    case '"':
        token = ParseStringToken();
        break;
    }
    return token;
}