File tree Expand file tree Collapse file tree 1 file changed +22
-20
lines changed Expand file tree Collapse file tree 1 file changed +22
-20
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,27 @@ enum TokenType {
10
10
11
11
static void advance (TSLexer * lexer ) { lexer -> advance (lexer , false); }
12
12
13
+ static bool scan_template_chars (TSLexer * lexer ) {
14
+ lexer -> result_symbol = TEMPLATE_CHARS ;
15
+ for (bool has_content = false;; has_content = true) {
16
+ lexer -> mark_end (lexer );
17
+ switch (lexer -> lookahead ) {
18
+ case '`' :
19
+ return has_content ;
20
+ case '\0' :
21
+ return false;
22
+ case '$' :
23
+ advance (lexer );
24
+ if (lexer -> lookahead == '{' ) return has_content ;
25
+ break ;
26
+ case '\\' :
27
+ return has_content ;
28
+ default :
29
+ advance (lexer );
30
+ }
31
+ }
32
+ }
33
+
13
34
static bool scan_whitespace_and_comments (TSLexer * lexer ) {
14
35
for (;;) {
15
36
while (iswspace (lexer -> lookahead )) {
@@ -49,26 +70,7 @@ static bool scan_whitespace_and_comments(TSLexer *lexer) {
49
70
static inline bool external_scanner_scan (void * payload , TSLexer * lexer , const bool * valid_symbols ) {
50
71
if (valid_symbols [TEMPLATE_CHARS ]) {
51
72
if (valid_symbols [AUTOMATIC_SEMICOLON ]) return false;
52
- lexer -> result_symbol = TEMPLATE_CHARS ;
53
- for (bool notfirst = false;; notfirst = true) {
54
- lexer -> mark_end (lexer );
55
- switch (lexer -> lookahead ) {
56
- case '`' :
57
- return notfirst ;
58
- case '\0' :
59
- return false;
60
- case '$' :
61
- advance (lexer );
62
- if (lexer -> lookahead == '{' ) return notfirst ;
63
- break ;
64
- case '\\' :
65
- advance (lexer );
66
- advance (lexer );
67
- break ;
68
- default :
69
- advance (lexer );
70
- }
71
- }
73
+ return scan_template_chars (lexer );
72
74
} else if (
73
75
valid_symbols [AUTOMATIC_SEMICOLON ] ||
74
76
valid_symbols [FUNCTION_SIGNATURE_AUTOMATIC_SEMICOLON ]
You can’t perform that action at this time.
0 commit comments