Skip whitespace and comments. Returns true if something was skipped. */
| 333 | |
| 334 | /* Skip whitespace and comments. Returns true if something was skipped. */ |
| 335 | static bool lex_skip_whitespace_comments(const char *input, int len, int *i) { |
| 336 | if (isspace((unsigned char)input[*i])) { |
| 337 | (*i)++; |
| 338 | return true; |
| 339 | } |
| 340 | if (*i + SKIP_ONE < len && input[*i] == '/' && input[*i + SKIP_ONE] == '/') { |
| 341 | while (*i < len && input[*i] != '\n') { |
| 342 | (*i)++; |
| 343 | } |
| 344 | return true; |
| 345 | } |
| 346 | /* SQL-style -- single-line comment */ |
| 347 | if (*i + SKIP_ONE < len && input[*i] == '-' && input[*i + SKIP_ONE] == '-') { |
| 348 | while (*i < len && input[*i] != '\n') { |
| 349 | (*i)++; |
| 350 | } |
| 351 | return true; |
| 352 | } |
| 353 | if (*i + SKIP_ONE < len && input[*i] == '/' && input[*i + SKIP_ONE] == '*') { |
| 354 | *i += PAIR_LEN; |
| 355 | while (*i + SKIP_ONE < len && !(input[*i] == '*' && input[*i + SKIP_ONE] == '/')) { |
| 356 | (*i)++; |
| 357 | } |
| 358 | if (*i + SKIP_ONE < len) { |
| 359 | *i += PAIR_LEN; |
| 360 | } |
| 361 | return true; |
| 362 | } |
| 363 | return false; |
| 364 | } |
| 365 | |
| 366 | int cbm_lex(const char *input, cbm_lex_result_t *out) { |
| 367 | memset(out, 0, sizeof(*out)); |