| 375 | typename set |
| 376 | > |
| 377 | void cpp_tokenizer_kernel_1<tok,queue,set>:: |
| 378 | get_token ( |
| 379 | int& type, |
| 380 | std::string& token |
| 381 | ) |
| 382 | { |
| 383 | if (!have_peeked) |
| 384 | { |
| 385 | |
| 386 | if (buffer.size() > 0) |
| 387 | { |
| 388 | // just return what is in the buffer |
| 389 | token_text_pair temp; |
| 390 | buffer.dequeue(temp); |
| 391 | type = temp.type; |
| 392 | token = temp.token; |
| 393 | return; |
| 394 | } |
| 395 | |
| 396 | tokenizer.get_token(type,token); |
| 397 | |
| 398 | switch (type) |
| 399 | { |
| 400 | case tok::END_OF_FILE: |
| 401 | { |
| 402 | type = END_OF_FILE; |
| 403 | } break; |
| 404 | |
| 405 | case tok::END_OF_LINE: |
| 406 | case tok::WHITE_SPACE: |
| 407 | { |
| 408 | type = tokenizer.peek_type(); |
| 409 | if (type == tok::END_OF_LINE || type == tok::WHITE_SPACE) |
| 410 | { |
| 411 | std::string temp; |
| 412 | do |
| 413 | { |
| 414 | tokenizer.get_token(type,temp); |
| 415 | token += temp; |
| 416 | type = tokenizer.peek_type(); |
| 417 | }while (type == tok::END_OF_LINE || type == tok::WHITE_SPACE); |
| 418 | } |
| 419 | type = WHITE_SPACE; |
| 420 | |
| 421 | } break; |
| 422 | |
| 423 | case tok::NUMBER: |
| 424 | { |
| 425 | // this could be a hex number such as 0xa33. we should check for this. |
| 426 | if (tokenizer.peek_type() == tok::IDENTIFIER && token == "0" && |
| 427 | (tokenizer.peek_token()[0] == 'x' || tokenizer.peek_token()[0] == 'X')) |
| 428 | { |
| 429 | // this is a hex number so accumulate all the numbers and identifiers that follow |
| 430 | // because they have to be part of the number |
| 431 | std::string temp; |
| 432 | tokenizer.get_token(type,temp); |
| 433 | token = "0" + temp; |
| 434 | |