tree-sitter-ucode 0.3.0 → 0.5.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 (53) hide show
  1. package/README.md +32 -81
  2. package/grammar.js +221 -35
  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 +5814 -0
  12. package/markup/src/node-types.json +3224 -0
  13. package/markup/src/parser.c +134512 -0
  14. package/markup/src/scanner.c +22 -0
  15. package/package.json +9 -5
  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/locals.scm +8 -0
  21. package/queries/tags.scm +15 -2
  22. package/scripts/generate-markup-grammar.js +93 -0
  23. package/src/grammar.json +1104 -233
  24. package/src/node-types.json +736 -69
  25. package/src/parser.c +106697 -25362
  26. package/src/scanner.c +16 -193
  27. package/src/scanner_impl.h +494 -0
  28. package/tree-sitter-ucode.wasm +0 -0
  29. package/tree-sitter-ucode_markup.wasm +0 -0
  30. package/tree-sitter.json +46 -22
  31. package/ucdocs/grammar.js +284 -0
  32. package/ucdocs/queries/highlights.scm +25 -0
  33. package/ucdocs/queries/tags.scm +22 -0
  34. package/ucdocs/src/grammar.json +1437 -0
  35. package/ucdocs/src/node-types.json +1347 -0
  36. package/ucdocs/src/parser.c +6387 -0
  37. package/ucdocs/src/tree_sitter/alloc.h +54 -0
  38. package/ucdocs/src/tree_sitter/array.h +330 -0
  39. package/ucdocs/src/tree_sitter/parser.h +286 -0
  40. package/tmpl/grammar.js +0 -68
  41. package/tmpl/queries/folds.scm +0 -4
  42. package/tmpl/queries/highlights.scm +0 -23
  43. package/tmpl/queries/indents.scm +0 -5
  44. package/tmpl/queries/injections.scm +0 -8
  45. package/tmpl/queries/locals.scm +0 -3
  46. package/tmpl/src/grammar.json +0 -251
  47. package/tmpl/src/node-types.json +0 -238
  48. package/tmpl/src/parser.c +0 -724
  49. package/tmpl/src/scanner.c +0 -174
  50. package/tree-sitter-ucode_tmpl.wasm +0 -0
  51. /package/{tmpl → markup}/src/tree_sitter/alloc.h +0 -0
  52. /package/{tmpl → markup}/src/tree_sitter/array.h +0 -0
  53. /package/{tmpl → markup}/src/tree_sitter/parser.h +0 -0
@@ -1,174 +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
- EOF_CLOSE,
10
- };
11
-
12
- void *tree_sitter_ucode_tmpl_external_scanner_create(void) { return NULL; }
13
- void tree_sitter_ucode_tmpl_external_scanner_destroy(void *p) { (void)p; }
14
- unsigned tree_sitter_ucode_tmpl_external_scanner_serialize(void *p, char *buf) {
15
- (void)p; (void)buf; return 0;
16
- }
17
- void tree_sitter_ucode_tmpl_external_scanner_deserialize(void *p, const char *buf, unsigned n) {
18
- (void)p; (void)buf; (void)n;
19
- }
20
-
21
- static inline void advance(TSLexer *lexer) {
22
- lexer->advance(lexer, false);
23
- }
24
-
25
- /*
26
- * Scan raw text: everything outside a tag delimiter.
27
- *
28
- * Stops (without consuming) when it sees '{' followed by '%', '{', or '#'.
29
- * Characters advanced past without a subsequent mark_end call are treated as
30
- * lookahead and reset by tree-sitter after the token is returned.
31
- */
32
- static bool scan_raw_text(TSLexer *lexer) {
33
- lexer->result_symbol = RAW_TEXT;
34
- for (bool has_content = false;; has_content = true) {
35
- lexer->mark_end(lexer);
36
- if (lexer->lookahead == '\0') return has_content;
37
-
38
- if (lexer->lookahead == '{') {
39
- advance(lexer); /* peek at the char after '{' */
40
- if (lexer->lookahead == '%' ||
41
- lexer->lookahead == '{' ||
42
- lexer->lookahead == '#') {
43
- /* '{' starts a tag — stop before it */
44
- return has_content;
45
- }
46
- /* '{' is not a tag opener; it will be committed on the next
47
- iteration when mark_end is called at the top of the loop */
48
- } else {
49
- advance(lexer);
50
- }
51
- }
52
- }
53
-
54
- /*
55
- * Scan statement code: content between {%/{%-/{%+ and %}/-%}.
56
- *
57
- * Stops (without consuming) before '%}' or '-%}'.
58
- */
59
- static bool scan_stmt_code(TSLexer *lexer) {
60
- lexer->result_symbol = STMT_CODE;
61
- for (bool has_content = false;; has_content = true) {
62
- lexer->mark_end(lexer);
63
- if (lexer->lookahead == '\0') return has_content;
64
-
65
- if (lexer->lookahead == '-') {
66
- advance(lexer);
67
- if (lexer->lookahead == '%') {
68
- advance(lexer);
69
- if (lexer->lookahead == '}') {
70
- /* found '-%}' — stop before '-' */
71
- return has_content;
72
- }
73
- /* was '-%' + something else; commit on next iteration */
74
- }
75
- /* was '-' + non-'%'; commit on next iteration */
76
- } else if (lexer->lookahead == '%') {
77
- advance(lexer);
78
- if (lexer->lookahead == '}') {
79
- /* found '%}' — stop before '%' */
80
- return has_content;
81
- }
82
- /* was '%' + non-'}'; commit on next iteration */
83
- } else {
84
- advance(lexer);
85
- }
86
- }
87
- }
88
-
89
- /*
90
- * Scan expression code: content between {{/{{- and }}/- }}.
91
- *
92
- * Stops (without consuming) before '}}' or '-}}'.
93
- */
94
- static bool scan_expr_code(TSLexer *lexer) {
95
- lexer->result_symbol = EXPR_CODE;
96
- for (bool has_content = false;; has_content = true) {
97
- lexer->mark_end(lexer);
98
- if (lexer->lookahead == '\0') return has_content;
99
-
100
- if (lexer->lookahead == '-') {
101
- advance(lexer);
102
- if (lexer->lookahead == '}') {
103
- advance(lexer);
104
- if (lexer->lookahead == '}') {
105
- /* found '-}}' — stop before '-' */
106
- return has_content;
107
- }
108
- /* was '-}' + something else; commit on next iteration */
109
- }
110
- /* was '-' + non-'}'; commit on next iteration */
111
- } else if (lexer->lookahead == '}') {
112
- advance(lexer);
113
- if (lexer->lookahead == '}') {
114
- /* found '}}' — stop before first '}' */
115
- return has_content;
116
- }
117
- /* was '}' + non-'}'; commit on next iteration */
118
- } else {
119
- advance(lexer);
120
- }
121
- }
122
- }
123
-
124
- /*
125
- * Scan comment body: content between {#/{#- and #}/-#}.
126
- *
127
- * Stops (without consuming) before '#}' or '-#}'.
128
- */
129
- static bool scan_comment_body(TSLexer *lexer) {
130
- lexer->result_symbol = COMMENT_BODY;
131
- for (bool has_content = false;; has_content = true) {
132
- lexer->mark_end(lexer);
133
- if (lexer->lookahead == '\0') return has_content;
134
-
135
- if (lexer->lookahead == '-') {
136
- advance(lexer);
137
- if (lexer->lookahead == '#') {
138
- advance(lexer);
139
- if (lexer->lookahead == '}') {
140
- /* found '-#}' — stop before '-' */
141
- return has_content;
142
- }
143
- /* was '-#' + non-'}'; commit on next iteration */
144
- }
145
- /* was '-' + non-'#'; commit on next iteration */
146
- } else if (lexer->lookahead == '#') {
147
- advance(lexer);
148
- if (lexer->lookahead == '}') {
149
- /* found '#}' — stop before '#' */
150
- return has_content;
151
- }
152
- /* was '#' + non-'}'; commit on next iteration */
153
- } else {
154
- advance(lexer);
155
- }
156
- }
157
- }
158
-
159
- bool tree_sitter_ucode_tmpl_external_scanner_scan(
160
- void *payload, TSLexer *lexer, const bool *valid_symbols
161
- ) {
162
- (void)payload;
163
-
164
- if (valid_symbols[EOF_CLOSE] && lexer->lookahead == '\0') {
165
- lexer->result_symbol = EOF_CLOSE;
166
- return true;
167
- }
168
- if (valid_symbols[RAW_TEXT]) return scan_raw_text(lexer);
169
- if (valid_symbols[STMT_CODE]) return scan_stmt_code(lexer);
170
- if (valid_symbols[EXPR_CODE]) return scan_expr_code(lexer);
171
- if (valid_symbols[COMMENT_BODY]) return scan_comment_body(lexer);
172
-
173
- return false;
174
- }
Binary file
File without changes
File without changes
File without changes