Try to lex a number starting at position i. Returns true if matched. */
| 307 | |
| 308 | /* Try to lex a number starting at position i. Returns true if matched. */ |
| 309 | static bool lex_try_number(const char *input, int len, int *i, cbm_lex_result_t *out) { |
| 310 | char c = input[*i]; |
| 311 | if (!isdigit((unsigned char)c) && |
| 312 | !(c == '.' && *i + SKIP_ONE < len && isdigit((unsigned char)input[*i + SKIP_ONE]))) { |
| 313 | return false; |
| 314 | } |
| 315 | int start = *i; |
| 316 | while (*i < len && (isdigit((unsigned char)input[*i]) || |
| 317 | (input[*i] == '.' && *i + SKIP_ONE < len && input[*i + SKIP_ONE] != '.'))) { |
| 318 | (*i)++; |
| 319 | } |
| 320 | lex_push_n(out, TOK_NUMBER, input + start, *i - start, start); |
| 321 | return true; |
| 322 | } |
| 323 | |
| 324 | /* Skip whitespace and comments. Returns true if something was skipped. */ |
| 325 | static bool lex_skip_whitespace_comments(const char *input, int len, int *i) { |