| 99 | |
| 100 | |
| 101 | static NoCaseString getToken(unsigned& pos, const Tokens& toks, int symbol = SYMBOL) |
| 102 | { |
| 103 | if (pos >= toks.getCount()) |
| 104 | generate_error("", UNEXPECTED_END_OF_COMMAND); |
| 105 | |
| 106 | NoCaseString curTok(NoCaseString(toks[pos].text, toks[pos].length)); |
| 107 | |
| 108 | switch(symbol) |
| 109 | { |
| 110 | case SYMBOL: |
| 111 | break; |
| 112 | |
| 113 | case STRING: |
| 114 | if (!strchr(quotes, toks[pos].text[0])) |
| 115 | generate_error(curTok, UNEXPECTED_TOKEN); |
| 116 | return toks[pos++].stripped().ToNoCaseString(); |
| 117 | |
| 118 | case NUMERIC: |
| 119 | { |
| 120 | const char* const end = &toks[pos].text[toks[pos].length]; |
| 121 | for (const char* ptr = toks[pos].text; ptr < end; ++ptr) |
| 122 | { |
| 123 | if (*ptr < '0' || *ptr > '9') |
| 124 | generate_error(curTok, UNEXPECTED_TOKEN); |
| 125 | } |
| 126 | } |
| 127 | break; |
| 128 | |
| 129 | default: |
| 130 | if (symbol > 0 && symbol <= 127) // good ascii symbol |
| 131 | { |
| 132 | if (toks[pos].length != 1 || toks[pos].text[0] != symbol) |
| 133 | generate_error(curTok, UNEXPECTED_TOKEN); |
| 134 | } |
| 135 | fb_assert(false); |
| 136 | break; |
| 137 | } |
| 138 | |
| 139 | ++pos; |
| 140 | return curTok; |
| 141 | } |
| 142 | |
| 143 | |
| 144 | /** |
no test coverage detected