blob: f55054a5b80e9791d06db2a61c8d4b7a4e6a6505 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#include "tree_sitter/parser.h"
#include <wctype.h>
enum TokenType {
CONCAT,
NS_DELIM,
};
static bool is_eof(TSLexer *lexer) {
return lexer->lookahead == 0;
}
static bool is_concat_valid(TSLexer *lexer, const bool *valid_symbols) {
return valid_symbols[CONCAT] && (
iswalpha(lexer->lookahead) ||
lexer->lookahead == '$' ||
lexer->lookahead == '[' ||
lexer->lookahead == '_'
);
// return valid_symbols[CONCAT] && !(
// is_eof(lexer) ||
// iswspace(lexer->lookahead) ||
// lexer->lookahead == ']' ||
// lexer->lookahead == '$' ||
// lexer->lookahead == ')' ||
// lexer->lookahead == '}'
// );
}
static bool scan_ns_delim(TSLexer *lexer) {
if (lexer->lookahead == ':') {
lexer->advance(lexer, false);
if (lexer->lookahead == ':') {
lexer->advance(lexer, false);
if (iswalpha(lexer->lookahead)) {
lexer->result_symbol = NS_DELIM;
return true;
}
}
}
return false;
}
void *tree_sitter_tcl_external_scanner_create() {
return NULL;
}
bool tree_sitter_tcl_external_scanner_scan(void *payload, TSLexer *lexer,
const bool *valid_symbols) {
if (valid_symbols[NS_DELIM]) {
return scan_ns_delim(lexer);
}
if (is_concat_valid(lexer, valid_symbols)) {
return true;
}
return false;
}
unsigned tree_sitter_tcl_external_scanner_serialize(void *payload, char *state) {
return 0;
}
void tree_sitter_tcl_external_scanner_deserialize(void *payload, const char *state, unsigned length){ }
void tree_sitter_tcl_external_scanner_destroy(void *payload) {}
|