Skip to content

Commit 1d21bcf

Browse files
committed
feat: added error sentinel for external scanners so that llvm_ir is no longer scanned for no reason
1 parent c4d90f0 commit 1d21bcf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

grammar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ module.exports = grammar({
2222
conflicts: $ => [
2323
],
2424

25-
externals: $ => [$.llvm_ir],
25+
externals: $ => [
26+
$.llvm_ir,
27+
$.error_sential,
28+
],
2629

2730
reserved: {
2831
global: _ => [

src/scanner.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
enum TokenType {
66
LLVM_IR,
7+
ERROR_SENTINEL,
78
};
89

910
void *tree_sitter_autolang_external_scanner_create() { return NULL; }
@@ -23,6 +24,10 @@ static inline void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
2324

2425
bool tree_sitter_autolang_external_scanner_scan(void *payload, TSLexer *lexer,
2526
const bool *valid_symbols) {
27+
if (valid_symbols[ERROR_SENTINEL]) {
28+
return false;
29+
}
30+
2631
if (valid_symbols[LLVM_IR]) {
2732
int depth = 0;
2833
for (;; advance(lexer)) {

0 commit comments

Comments
 (0)