MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / eat_comment

Function eat_comment

codegraph-kernel/grammars/swift/scanner.c:541–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541static enum ParseDirective eat_comment(
542 TSLexer *lexer,
543 const bool *valid_symbols,
544 bool mark_end,
545 enum TokenType *symbol_result
546) {
547 if (lexer->lookahead != '/') {
548 return CONTINUE_PARSING_NOTHING_FOUND;
549 }
550
551 advance(lexer);
552
553 if (lexer->lookahead != '*') {
554 return CONTINUE_PARSING_SLASH_CONSUMED;
555 }
556
557 advance(lexer);
558
559 bool after_star = false;
560 unsigned nesting_depth = 1;
561 for (;;) {
562 switch (lexer->lookahead) {
563 case '\0':
564 return STOP_PARSING_END_OF_FILE;
565 case '*':
566 advance(lexer);
567 after_star = true;
568 break;
569 case '/':
570 if (after_star) {
571 advance(lexer);
572 after_star = false;
573 nesting_depth--;
574 if (nesting_depth == 0) {
575 if (mark_end) {
576 lexer->mark_end(lexer);
577 }
578 *symbol_result = BLOCK_COMMENT;
579 return STOP_PARSING_TOKEN_FOUND;
580 }
581 } else {
582 advance(lexer);
583 after_star = false;
584 if (lexer->lookahead == '*') {
585 nesting_depth++;
586 advance(lexer);
587 }
588 }
589 break;
590 default:
591 advance(lexer);
592 after_star = false;
593 break;
594 }
595 }
596}
597
598static enum ParseDirective eat_whitespace(

Callers 2

eat_whitespaceFunction · 0.85

Calls 1

advanceFunction · 0.70

Tested by

no test coverage detected