@@ -63,5 +63,33 @@ bool tree_sitter_glimmer_javascript_external_scanner_scan(void *payload, TSLexer
6363 if (valid_symbols [RAW_TEXT ]) {
6464 return scan_raw_text (payload , lexer );
6565 }
66+
67+ // The upstream JS scanner refuses to insert an automatic semicolon before `<`
68+ // because in standard JS it could be a less-than operator. In GJS/GTS, `<template>`
69+ // is a valid class body member, so we handle the AUTOMATIC_SEMICOLON case ourselves:
70+ // we call scan_automatic_semicolon directly (accessible from the included scanner.h),
71+ // and when it refuses due to `<`, we check whether `<template>` follows and insert
72+ // the semicolon if so.
73+ if (valid_symbols [AUTOMATIC_SEMICOLON ]) {
74+ bool scanned_comment = false;
75+ bool result = scan_automatic_semicolon (lexer , !valid_symbols [LOGICAL_OR ], & scanned_comment );
76+ if (!result && !scanned_comment ) {
77+ if (lexer -> lookahead == '<' ) {
78+ skip (lexer );
79+ const char * tag = "template>" ;
80+ for (unsigned i = 0 ; tag [i ] != '\0' ; i ++ ) {
81+ if ((char )lexer -> lookahead != tag [i ]) return false;
82+ skip (lexer );
83+ }
84+ lexer -> result_symbol = AUTOMATIC_SEMICOLON ;
85+ return true;
86+ }
87+ if (valid_symbols [TERNARY_QMARK ] && lexer -> lookahead == '?' ) {
88+ return scan_ternary_qmark (lexer );
89+ }
90+ }
91+ return result ;
92+ }
93+
6694 return tree_sitter_javascript_external_scanner_scan (payload , lexer , valid_symbols );
6795}
0 commit comments