| 21 | static void skip(TSLexer *lexer) { lexer->advance(lexer, true); } |
| 22 | |
| 23 | static bool scan_multiline_comments(TSLexer *lexer) { |
| 24 | |
| 25 | bool documentation_comment = false; |
| 26 | advance(lexer); |
| 27 | if (lexer->lookahead != '*') return false; |
| 28 | advance(lexer); |
| 29 | if (lexer->lookahead == '*') documentation_comment = true; |
| 30 | |
| 31 | bool after_star = false; |
| 32 | unsigned nesting_depth = 1; |
| 33 | for (;;) { |
| 34 | switch (lexer->lookahead) { |
| 35 | case '\0': |
| 36 | return false; |
| 37 | case '*': |
| 38 | advance(lexer); |
| 39 | after_star = true; |
| 40 | break; |
| 41 | case '/': |
| 42 | if (after_star) { |
| 43 | advance(lexer); |
| 44 | after_star = false; |
| 45 | nesting_depth--; |
| 46 | if (nesting_depth == 0) { |
| 47 | if (!documentation_comment) { |
| 48 | lexer->result_symbol = BLOCK_COMMENT; |
| 49 | } else { |
| 50 | lexer->result_symbol = DOCUMENTATION_BLOCK_COMMENT; |
| 51 | } |
| 52 | return true; |
| 53 | } |
| 54 | } else { |
| 55 | advance(lexer); |
| 56 | after_star = false; |
| 57 | if (lexer->lookahead == '*') { |
| 58 | nesting_depth++; |
| 59 | advance(lexer); |
| 60 | } |
| 61 | } |
| 62 | break; |
| 63 | default: |
| 64 | advance(lexer); |
| 65 | after_star = false; |
| 66 | break; |
| 67 | } |
| 68 | } |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | static bool scan_templates(TSLexer *lexer, const bool *valid_symbols) { |
no test coverage detected