| 54 | } |
| 55 | |
| 56 | public void next() { |
| 57 | if (data == null) { |
| 58 | tokenLength = 0; |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | while (true) { |
| 63 | // skip whitespace |
| 64 | skipwhites(); |
| 65 | if (isEof()) { |
| 66 | tokenLength = 0; |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | // skip // comments |
| 71 | if (getchar() == '/') { |
| 72 | if (nextchar() == '/') { |
| 73 | skiptoeol(); |
| 74 | // goto skip whitespace |
| 75 | continue; |
| 76 | } else { |
| 77 | prevchar(); |
| 78 | break; |
| 79 | } |
| 80 | } else |
| 81 | break; |
| 82 | } |
| 83 | |
| 84 | int c; |
| 85 | int len = 0; |
| 86 | // handle quoted strings specially |
| 87 | if (getchar() == '\"') { |
| 88 | nextchar(); |
| 89 | tokenPos = index; |
| 90 | while (true) { |
| 91 | c = getchar(); |
| 92 | nextchar(); |
| 93 | if (c == '\"' || c == 0) { |
| 94 | tokenLength = len; |
| 95 | return; |
| 96 | } |
| 97 | if (len < Defines.MAX_TOKEN_CHARS) { |
| 98 | ++len; |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // parse a regular word |
| 104 | c = getchar(); |
| 105 | tokenPos = index; |
| 106 | do { |
| 107 | if (len < Defines.MAX_TOKEN_CHARS) { |
| 108 | ++len; |
| 109 | } |
| 110 | c = nextchar(); |
| 111 | } while (c > 32); |
| 112 | |
| 113 | if (len == Defines.MAX_TOKEN_CHARS) { |