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

Function eat_comment

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

Source from the content-addressed store, hash-verified

706}
707
708static enum ParseDirective eat_comment(
709 TSLexer *lexer,
710 const bool *valid_symbols,
711 bool mark_end,
712 enum TokenType *symbol_result
713) {
714 if (lexer->lookahead != '/') {
715 return CONTINUE_PARSING_NOTHING_FOUND;
716 }
717
718 advance(lexer);
719
720 if (lexer->lookahead != '*') {
721 return CONTINUE_PARSING_SLASH_CONSUMED;
722 }
723
724 advance(lexer);
725
726 bool after_star = false;
727 unsigned nesting_depth = 1;
728 for (;;) {
729 switch (lexer->lookahead) {
730 case '\0':
731 return STOP_PARSING_END_OF_FILE;
732 case '*':
733 advance(lexer);
734 after_star = true;
735 break;
736 case '/':
737 if (after_star) {
738 advance(lexer);
739 after_star = false;
740 nesting_depth--;
741 if (nesting_depth == 0) {
742 if (mark_end) {
743 lexer->mark_end(lexer);
744 }
745 *symbol_result = BLOCK_COMMENT;
746 return STOP_PARSING_TOKEN_FOUND;
747 }
748 } else {
749 advance(lexer);
750 after_star = false;
751 if (lexer->lookahead == '*') {
752 nesting_depth++;
753 advance(lexer);
754 }
755 }
756 break;
757 default:
758 advance(lexer);
759 after_star = false;
760 break;
761 }
762 }
763}
764
765static enum ParseDirective eat_whitespace(

Callers 2

eat_whitespaceFunction · 0.85

Calls 1

advanceFunction · 0.70

Tested by

no test coverage detected