tree-sitter-ucode 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +49 -58
  2. package/grammar.js +214 -28
  3. package/markup/grammar.js +1057 -0
  4. package/markup/queries/folds.scm +20 -0
  5. package/markup/queries/highlights.scm +38 -0
  6. package/markup/queries/indents.scm +51 -0
  7. package/markup/queries/injections.scm +40 -0
  8. package/markup/queries/locals.scm +107 -0
  9. package/markup/queries/tags.scm +65 -0
  10. package/markup/queries/textobjects.scm +56 -0
  11. package/markup/src/grammar.json +5786 -0
  12. package/markup/src/node-types.json +3211 -0
  13. package/markup/src/parser.c +134461 -0
  14. package/markup/src/scanner.c +22 -0
  15. package/package.json +8 -7
  16. package/prebuilds/darwin-arm64/tree-sitter-ucode.node +0 -0
  17. package/prebuilds/linux-arm64/tree-sitter-ucode.node +0 -0
  18. package/prebuilds/linux-x64/tree-sitter-ucode.node +0 -0
  19. package/prebuilds/win32-x64/tree-sitter-ucode.node +0 -0
  20. package/queries/folds.scm +38 -0
  21. package/queries/highlights.scm +6 -0
  22. package/queries/indents.scm +63 -0
  23. package/queries/locals.scm +1 -0
  24. package/queries/textobjects.scm +84 -0
  25. package/scripts/generate-markup-grammar.js +93 -0
  26. package/src/grammar.json +1069 -226
  27. package/src/node-types.json +662 -8
  28. package/src/parser.c +106401 -25117
  29. package/src/scanner.c +16 -193
  30. package/src/scanner_impl.h +494 -0
  31. package/tree-sitter-ucode.wasm +0 -0
  32. package/tree-sitter-ucode_markup.wasm +0 -0
  33. package/tree-sitter.json +24 -12
  34. package/tmpl/grammar.js +0 -67
  35. package/tmpl/queries/highlights.scm +0 -23
  36. package/tmpl/queries/injections.scm +0 -8
  37. package/tmpl/queries/locals.scm +0 -3
  38. package/tmpl/src/grammar.json +0 -243
  39. package/tmpl/src/node-types.json +0 -230
  40. package/tmpl/src/parser.c +0 -707
  41. package/tmpl/src/scanner.c +0 -169
  42. package/tree-sitter-ucode_tmpl.wasm +0 -0
  43. /package/{tmpl → markup}/src/tree_sitter/alloc.h +0 -0
  44. /package/{tmpl → markup}/src/tree_sitter/array.h +0 -0
  45. /package/{tmpl → markup}/src/tree_sitter/parser.h +0 -0
@@ -1,169 +0,0 @@
1
- #include "tree_sitter/parser.h"
2
-
3
- /* Must match the order of externals in grammar.js */
4
- enum TokenType {
5
- RAW_TEXT,
6
- STMT_CODE,
7
- EXPR_CODE,
8
- COMMENT_BODY,
9
- };
10
-
11
- void *tree_sitter_ucode_tmpl_external_scanner_create(void) { return NULL; }
12
- void tree_sitter_ucode_tmpl_external_scanner_destroy(void *p) { (void)p; }
13
- unsigned tree_sitter_ucode_tmpl_external_scanner_serialize(void *p, char *buf) {
14
- (void)p; (void)buf; return 0;
15
- }
16
- void tree_sitter_ucode_tmpl_external_scanner_deserialize(void *p, const char *buf, unsigned n) {
17
- (void)p; (void)buf; (void)n;
18
- }
19
-
20
- static inline void advance(TSLexer *lexer) {
21
- lexer->advance(lexer, false);
22
- }
23
-
24
- /*
25
- * Scan raw text: everything outside a tag delimiter.
26
- *
27
- * Stops (without consuming) when it sees '{' followed by '%', '{', or '#'.
28
- * Characters advanced past without a subsequent mark_end call are treated as
29
- * lookahead and reset by tree-sitter after the token is returned.
30
- */
31
- static bool scan_raw_text(TSLexer *lexer) {
32
- lexer->result_symbol = RAW_TEXT;
33
- for (bool has_content = false;; has_content = true) {
34
- lexer->mark_end(lexer);
35
- if (lexer->lookahead == '\0') return has_content;
36
-
37
- if (lexer->lookahead == '{') {
38
- advance(lexer); /* peek at the char after '{' */
39
- if (lexer->lookahead == '%' ||
40
- lexer->lookahead == '{' ||
41
- lexer->lookahead == '#') {
42
- /* '{' starts a tag — stop before it */
43
- return has_content;
44
- }
45
- /* '{' is not a tag opener; it will be committed on the next
46
- iteration when mark_end is called at the top of the loop */
47
- } else {
48
- advance(lexer);
49
- }
50
- }
51
- }
52
-
53
- /*
54
- * Scan statement code: content between {%/{%-/{%+ and %}/-%}.
55
- *
56
- * Stops (without consuming) before '%}' or '-%}'.
57
- */
58
- static bool scan_stmt_code(TSLexer *lexer) {
59
- lexer->result_symbol = STMT_CODE;
60
- for (bool has_content = false;; has_content = true) {
61
- lexer->mark_end(lexer);
62
- if (lexer->lookahead == '\0') return has_content;
63
-
64
- if (lexer->lookahead == '-') {
65
- advance(lexer);
66
- if (lexer->lookahead == '%') {
67
- advance(lexer);
68
- if (lexer->lookahead == '}') {
69
- /* found '-%}' — stop before '-' */
70
- return has_content;
71
- }
72
- /* was '-%' + something else; commit on next iteration */
73
- }
74
- /* was '-' + non-'%'; commit on next iteration */
75
- } else if (lexer->lookahead == '%') {
76
- advance(lexer);
77
- if (lexer->lookahead == '}') {
78
- /* found '%}' — stop before '%' */
79
- return has_content;
80
- }
81
- /* was '%' + non-'}'; commit on next iteration */
82
- } else {
83
- advance(lexer);
84
- }
85
- }
86
- }
87
-
88
- /*
89
- * Scan expression code: content between {{/{{- and }}/- }}.
90
- *
91
- * Stops (without consuming) before '}}' or '-}}'.
92
- */
93
- static bool scan_expr_code(TSLexer *lexer) {
94
- lexer->result_symbol = EXPR_CODE;
95
- for (bool has_content = false;; has_content = true) {
96
- lexer->mark_end(lexer);
97
- if (lexer->lookahead == '\0') return has_content;
98
-
99
- if (lexer->lookahead == '-') {
100
- advance(lexer);
101
- if (lexer->lookahead == '}') {
102
- advance(lexer);
103
- if (lexer->lookahead == '}') {
104
- /* found '-}}' — stop before '-' */
105
- return has_content;
106
- }
107
- /* was '-}' + something else; commit on next iteration */
108
- }
109
- /* was '-' + non-'}'; commit on next iteration */
110
- } else if (lexer->lookahead == '}') {
111
- advance(lexer);
112
- if (lexer->lookahead == '}') {
113
- /* found '}}' — stop before first '}' */
114
- return has_content;
115
- }
116
- /* was '}' + non-'}'; commit on next iteration */
117
- } else {
118
- advance(lexer);
119
- }
120
- }
121
- }
122
-
123
- /*
124
- * Scan comment body: content between {#/{#- and #}/-#}.
125
- *
126
- * Stops (without consuming) before '#}' or '-#}'.
127
- */
128
- static bool scan_comment_body(TSLexer *lexer) {
129
- lexer->result_symbol = COMMENT_BODY;
130
- for (bool has_content = false;; has_content = true) {
131
- lexer->mark_end(lexer);
132
- if (lexer->lookahead == '\0') return has_content;
133
-
134
- if (lexer->lookahead == '-') {
135
- advance(lexer);
136
- if (lexer->lookahead == '#') {
137
- advance(lexer);
138
- if (lexer->lookahead == '}') {
139
- /* found '-#}' — stop before '-' */
140
- return has_content;
141
- }
142
- /* was '-#' + non-'}'; commit on next iteration */
143
- }
144
- /* was '-' + non-'#'; commit on next iteration */
145
- } else if (lexer->lookahead == '#') {
146
- advance(lexer);
147
- if (lexer->lookahead == '}') {
148
- /* found '#}' — stop before '#' */
149
- return has_content;
150
- }
151
- /* was '#' + non-'}'; commit on next iteration */
152
- } else {
153
- advance(lexer);
154
- }
155
- }
156
- }
157
-
158
- bool tree_sitter_ucode_tmpl_external_scanner_scan(
159
- void *payload, TSLexer *lexer, const bool *valid_symbols
160
- ) {
161
- (void)payload;
162
-
163
- if (valid_symbols[RAW_TEXT]) return scan_raw_text(lexer);
164
- if (valid_symbols[STMT_CODE]) return scan_stmt_code(lexer);
165
- if (valid_symbols[EXPR_CODE]) return scan_expr_code(lexer);
166
- if (valid_symbols[COMMENT_BODY]) return scan_comment_body(lexer);
167
-
168
- return false;
169
- }
Binary file
File without changes
File without changes
File without changes