@yalehwang/archguard 0.1.7 → 0.1.9
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.
- package/README.md +33 -23
- package/dist/cli/analyze/normalize-to-diagrams.d.ts.map +1 -1
- package/dist/cli/analyze/normalize-to-diagrams.js +61 -4
- package/dist/cli/analyze/normalize-to-diagrams.js.map +1 -1
- package/dist/cli/analyze/run-analysis.d.ts.map +1 -1
- package/dist/cli/analyze/run-analysis.js +12 -4
- package/dist/cli/analyze/run-analysis.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts.map +1 -1
- package/dist/cli/commands/mcp.js +2 -6
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/index.js +0 -0
- package/dist/cli/mcp/analyze-tool.d.ts +1 -5
- package/dist/cli/mcp/analyze-tool.d.ts.map +1 -1
- package/dist/cli/mcp/analyze-tool.js +48 -52
- package/dist/cli/mcp/analyze-tool.js.map +1 -1
- package/dist/cli/mcp/mcp-server.d.ts +4 -4
- package/dist/cli/mcp/mcp-server.d.ts.map +1 -1
- package/dist/cli/mcp/mcp-server.js +108 -57
- package/dist/cli/mcp/mcp-server.js.map +1 -1
- package/dist/cli/processors/arch-json-provider.d.ts +4 -1
- package/dist/cli/processors/arch-json-provider.d.ts.map +1 -1
- package/dist/cli/processors/arch-json-provider.js +87 -23
- package/dist/cli/processors/arch-json-provider.js.map +1 -1
- package/dist/cli/processors/diagram-output-router.d.ts.map +1 -1
- package/dist/cli/processors/diagram-output-router.js +1 -0
- package/dist/cli/processors/diagram-output-router.js.map +1 -1
- package/dist/cli/processors/diagram-processor.d.ts.map +1 -1
- package/dist/cli/processors/diagram-processor.js +10 -5
- package/dist/cli/processors/diagram-processor.js.map +1 -1
- package/dist/cli/query/engine-loader.js +2 -2
- package/dist/cli/query/engine-loader.js.map +1 -1
- package/dist/cli/query/query-artifacts.d.ts +5 -1
- package/dist/cli/query/query-artifacts.d.ts.map +1 -1
- package/dist/cli/query/query-artifacts.js +22 -3
- package/dist/cli/query/query-artifacts.js.map +1 -1
- package/dist/cli/query/query-manifest.d.ts +2 -0
- package/dist/cli/query/query-manifest.d.ts.map +1 -1
- package/dist/cli/utils/default-scope-planner.d.ts +22 -0
- package/dist/cli/utils/default-scope-planner.d.ts.map +1 -0
- package/dist/cli/utils/default-scope-planner.js +84 -0
- package/dist/cli/utils/default-scope-planner.js.map +1 -0
- package/dist/cli/utils/project-language-detector.d.ts +10 -0
- package/dist/cli/utils/project-language-detector.d.ts.map +1 -0
- package/dist/cli/utils/project-language-detector.js +179 -0
- package/dist/cli/utils/project-language-detector.js.map +1 -0
- package/dist/mermaid/render-worker-pool.d.ts.map +1 -1
- package/dist/mermaid/render-worker-pool.js +7 -1
- package/dist/mermaid/render-worker-pool.js.map +1 -1
- package/dist/plugins/golang/atlas/index.d.ts.map +1 -1
- package/dist/plugins/golang/atlas/index.js +3 -1
- package/dist/plugins/golang/atlas/index.js.map +1 -1
- package/dist/plugins/golang/atlas/types.d.ts +1 -0
- package/dist/plugins/golang/atlas/types.d.ts.map +1 -1
- package/dist/plugins/golang/index.d.ts.map +1 -1
- package/dist/plugins/golang/index.js +15 -6
- package/dist/plugins/golang/index.js.map +1 -1
- package/dist/plugins/golang/source-scope.d.ts +7 -0
- package/dist/plugins/golang/source-scope.d.ts.map +1 -0
- package/dist/plugins/golang/source-scope.js +83 -0
- package/dist/plugins/golang/source-scope.js.map +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.d.ts.map +1 -1
- package/node_modules/node-addon-api/LICENSE.md +9 -0
- package/node_modules/node-addon-api/README.md +95 -0
- package/node_modules/node-addon-api/common.gypi +21 -0
- package/node_modules/node-addon-api/except.gypi +25 -0
- package/node_modules/node-addon-api/index.js +14 -0
- package/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
- package/node_modules/node-addon-api/napi-inl.h +7033 -0
- package/node_modules/node-addon-api/napi.h +3309 -0
- package/node_modules/node-addon-api/node_addon_api.gyp +42 -0
- package/node_modules/node-addon-api/node_api.gyp +9 -0
- package/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/node_modules/node-addon-api/nothing.c +0 -0
- package/node_modules/node-addon-api/package-support.json +21 -0
- package/node_modules/node-addon-api/package.json +480 -0
- package/node_modules/node-addon-api/tools/README.md +73 -0
- package/node_modules/node-addon-api/tools/check-napi.js +99 -0
- package/node_modules/node-addon-api/tools/clang-format.js +71 -0
- package/node_modules/node-addon-api/tools/conversion.js +301 -0
- package/node_modules/node-gyp-build/LICENSE +21 -0
- package/node_modules/node-gyp-build/README.md +58 -0
- package/node_modules/node-gyp-build/SECURITY.md +5 -0
- package/node_modules/node-gyp-build/bin.js +84 -0
- package/node_modules/node-gyp-build/build-test.js +19 -0
- package/node_modules/node-gyp-build/index.js +6 -0
- package/node_modules/node-gyp-build/node-gyp-build.js +207 -0
- package/node_modules/node-gyp-build/optional.js +7 -0
- package/node_modules/node-gyp-build/package.json +43 -0
- package/node_modules/tree-sitter/LICENSE +21 -0
- package/node_modules/tree-sitter/README.md +128 -0
- package/node_modules/tree-sitter/binding.gyp +80 -0
- package/node_modules/tree-sitter/index.js +916 -0
- package/node_modules/tree-sitter/package.json +76 -0
- package/node_modules/tree-sitter/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/node_modules/tree-sitter/src/addon_data.h +47 -0
- package/node_modules/tree-sitter/src/binding.cc +35 -0
- package/node_modules/tree-sitter/src/conversions.cc +140 -0
- package/node_modules/tree-sitter/src/conversions.h +22 -0
- package/node_modules/tree-sitter/src/language.cc +106 -0
- package/node_modules/tree-sitter/src/language.h +17 -0
- package/node_modules/tree-sitter/src/logger.cc +70 -0
- package/node_modules/tree-sitter/src/logger.h +19 -0
- package/node_modules/tree-sitter/src/lookaheaditerator.cc +122 -0
- package/node_modules/tree-sitter/src/lookaheaditerator.h +33 -0
- package/node_modules/tree-sitter/src/node.cc +1088 -0
- package/node_modules/tree-sitter/src/node.h +30 -0
- package/node_modules/tree-sitter/src/parser.cc +306 -0
- package/node_modules/tree-sitter/src/parser.h +35 -0
- package/node_modules/tree-sitter/src/query.cc +397 -0
- package/node_modules/tree-sitter/src/query.h +40 -0
- package/node_modules/tree-sitter/src/tree.cc +316 -0
- package/node_modules/tree-sitter/src/tree.h +45 -0
- package/node_modules/tree-sitter/src/tree_cursor.cc +213 -0
- package/node_modules/tree-sitter/src/tree_cursor.h +52 -0
- package/node_modules/tree-sitter/tree-sitter.d.ts +1042 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/include/tree_sitter/api.h +1478 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.c +48 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.h +41 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/array.h +291 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/atomic.h +68 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/clock.h +146 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/error_costs.h +11 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.c +523 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.h +36 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/host.h +21 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.c +293 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.h +293 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/length.h +52 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.c +483 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.h +54 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lib.c +12 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/node.c +875 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.c +2293 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.h +286 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/point.h +48 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/portable/endian.h +239 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/query.c +4350 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reduce_action.h +34 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reusable_node.h +95 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.c +911 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.h +133 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.c +1034 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.h +399 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.c +170 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.h +31 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.c +717 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.h +48 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/ts_assert.h +11 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ICU_SHA +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/LICENSE +414 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/README.md +29 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ptypes.h +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/umachine.h +448 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/urename.h +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf.h +1 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf16.h +733 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf8.h +881 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode.h +75 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib-symbols.txt +24 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib.c +113 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/wasm-stdlib.h +1314 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.c +1935 -0
- package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.h +31 -0
- package/package.json +8 -2
- package/scripts/postinstall-tree-sitter.mjs +28 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
#ifndef TREE_SITTER_PARSER_H_
|
|
2
|
+
#define TREE_SITTER_PARSER_H_
|
|
3
|
+
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#include <stdbool.h>
|
|
9
|
+
#include <stdint.h>
|
|
10
|
+
#include <stdlib.h>
|
|
11
|
+
|
|
12
|
+
#define ts_builtin_sym_error ((TSSymbol)-1)
|
|
13
|
+
#define ts_builtin_sym_end 0
|
|
14
|
+
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
|
15
|
+
|
|
16
|
+
#ifndef TREE_SITTER_API_H_
|
|
17
|
+
typedef uint16_t TSStateId;
|
|
18
|
+
typedef uint16_t TSSymbol;
|
|
19
|
+
typedef uint16_t TSFieldId;
|
|
20
|
+
typedef struct TSLanguage TSLanguage;
|
|
21
|
+
typedef struct TSLanguageMetadata {
|
|
22
|
+
uint8_t major_version;
|
|
23
|
+
uint8_t minor_version;
|
|
24
|
+
uint8_t patch_version;
|
|
25
|
+
} TSLanguageMetadata;
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
typedef struct {
|
|
29
|
+
TSFieldId field_id;
|
|
30
|
+
uint8_t child_index;
|
|
31
|
+
bool inherited;
|
|
32
|
+
} TSFieldMapEntry;
|
|
33
|
+
|
|
34
|
+
// Used to index the field and supertype maps.
|
|
35
|
+
typedef struct {
|
|
36
|
+
uint16_t index;
|
|
37
|
+
uint16_t length;
|
|
38
|
+
} TSMapSlice;
|
|
39
|
+
|
|
40
|
+
typedef struct {
|
|
41
|
+
bool visible;
|
|
42
|
+
bool named;
|
|
43
|
+
bool supertype;
|
|
44
|
+
} TSSymbolMetadata;
|
|
45
|
+
|
|
46
|
+
typedef struct TSLexer TSLexer;
|
|
47
|
+
|
|
48
|
+
struct TSLexer {
|
|
49
|
+
int32_t lookahead;
|
|
50
|
+
TSSymbol result_symbol;
|
|
51
|
+
void (*advance)(TSLexer *, bool);
|
|
52
|
+
void (*mark_end)(TSLexer *);
|
|
53
|
+
uint32_t (*get_column)(TSLexer *);
|
|
54
|
+
bool (*is_at_included_range_start)(const TSLexer *);
|
|
55
|
+
bool (*eof)(const TSLexer *);
|
|
56
|
+
void (*log)(const TSLexer *, const char *, ...);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
typedef enum {
|
|
60
|
+
TSParseActionTypeShift,
|
|
61
|
+
TSParseActionTypeReduce,
|
|
62
|
+
TSParseActionTypeAccept,
|
|
63
|
+
TSParseActionTypeRecover,
|
|
64
|
+
} TSParseActionType;
|
|
65
|
+
|
|
66
|
+
typedef union {
|
|
67
|
+
struct {
|
|
68
|
+
uint8_t type;
|
|
69
|
+
TSStateId state;
|
|
70
|
+
bool extra;
|
|
71
|
+
bool repetition;
|
|
72
|
+
} shift;
|
|
73
|
+
struct {
|
|
74
|
+
uint8_t type;
|
|
75
|
+
uint8_t child_count;
|
|
76
|
+
TSSymbol symbol;
|
|
77
|
+
int16_t dynamic_precedence;
|
|
78
|
+
uint16_t production_id;
|
|
79
|
+
} reduce;
|
|
80
|
+
uint8_t type;
|
|
81
|
+
} TSParseAction;
|
|
82
|
+
|
|
83
|
+
typedef struct {
|
|
84
|
+
uint16_t lex_state;
|
|
85
|
+
uint16_t external_lex_state;
|
|
86
|
+
} TSLexMode;
|
|
87
|
+
|
|
88
|
+
typedef struct {
|
|
89
|
+
uint16_t lex_state;
|
|
90
|
+
uint16_t external_lex_state;
|
|
91
|
+
uint16_t reserved_word_set_id;
|
|
92
|
+
} TSLexerMode;
|
|
93
|
+
|
|
94
|
+
typedef union {
|
|
95
|
+
TSParseAction action;
|
|
96
|
+
struct {
|
|
97
|
+
uint8_t count;
|
|
98
|
+
bool reusable;
|
|
99
|
+
} entry;
|
|
100
|
+
} TSParseActionEntry;
|
|
101
|
+
|
|
102
|
+
typedef struct {
|
|
103
|
+
int32_t start;
|
|
104
|
+
int32_t end;
|
|
105
|
+
} TSCharacterRange;
|
|
106
|
+
|
|
107
|
+
struct TSLanguage {
|
|
108
|
+
uint32_t abi_version;
|
|
109
|
+
uint32_t symbol_count;
|
|
110
|
+
uint32_t alias_count;
|
|
111
|
+
uint32_t token_count;
|
|
112
|
+
uint32_t external_token_count;
|
|
113
|
+
uint32_t state_count;
|
|
114
|
+
uint32_t large_state_count;
|
|
115
|
+
uint32_t production_id_count;
|
|
116
|
+
uint32_t field_count;
|
|
117
|
+
uint16_t max_alias_sequence_length;
|
|
118
|
+
const uint16_t *parse_table;
|
|
119
|
+
const uint16_t *small_parse_table;
|
|
120
|
+
const uint32_t *small_parse_table_map;
|
|
121
|
+
const TSParseActionEntry *parse_actions;
|
|
122
|
+
const char * const *symbol_names;
|
|
123
|
+
const char * const *field_names;
|
|
124
|
+
const TSMapSlice *field_map_slices;
|
|
125
|
+
const TSFieldMapEntry *field_map_entries;
|
|
126
|
+
const TSSymbolMetadata *symbol_metadata;
|
|
127
|
+
const TSSymbol *public_symbol_map;
|
|
128
|
+
const uint16_t *alias_map;
|
|
129
|
+
const TSSymbol *alias_sequences;
|
|
130
|
+
const TSLexerMode *lex_modes;
|
|
131
|
+
bool (*lex_fn)(TSLexer *, TSStateId);
|
|
132
|
+
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
|
133
|
+
TSSymbol keyword_capture_token;
|
|
134
|
+
struct {
|
|
135
|
+
const bool *states;
|
|
136
|
+
const TSSymbol *symbol_map;
|
|
137
|
+
void *(*create)(void);
|
|
138
|
+
void (*destroy)(void *);
|
|
139
|
+
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
|
140
|
+
unsigned (*serialize)(void *, char *);
|
|
141
|
+
void (*deserialize)(void *, const char *, unsigned);
|
|
142
|
+
} external_scanner;
|
|
143
|
+
const TSStateId *primary_state_ids;
|
|
144
|
+
const char *name;
|
|
145
|
+
const TSSymbol *reserved_words;
|
|
146
|
+
uint16_t max_reserved_word_set_size;
|
|
147
|
+
uint32_t supertype_count;
|
|
148
|
+
const TSSymbol *supertype_symbols;
|
|
149
|
+
const TSMapSlice *supertype_map_slices;
|
|
150
|
+
const TSSymbol *supertype_map_entries;
|
|
151
|
+
TSLanguageMetadata metadata;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
|
155
|
+
uint32_t index = 0;
|
|
156
|
+
uint32_t size = len - index;
|
|
157
|
+
while (size > 1) {
|
|
158
|
+
uint32_t half_size = size / 2;
|
|
159
|
+
uint32_t mid_index = index + half_size;
|
|
160
|
+
const TSCharacterRange *range = &ranges[mid_index];
|
|
161
|
+
if (lookahead >= range->start && lookahead <= range->end) {
|
|
162
|
+
return true;
|
|
163
|
+
} else if (lookahead > range->end) {
|
|
164
|
+
index = mid_index;
|
|
165
|
+
}
|
|
166
|
+
size -= half_size;
|
|
167
|
+
}
|
|
168
|
+
const TSCharacterRange *range = &ranges[index];
|
|
169
|
+
return (lookahead >= range->start && lookahead <= range->end);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
* Lexer Macros
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
#ifdef _MSC_VER
|
|
177
|
+
#define UNUSED __pragma(warning(suppress : 4101))
|
|
178
|
+
#else
|
|
179
|
+
#define UNUSED __attribute__((unused))
|
|
180
|
+
#endif
|
|
181
|
+
|
|
182
|
+
#define START_LEXER() \
|
|
183
|
+
bool result = false; \
|
|
184
|
+
bool skip = false; \
|
|
185
|
+
UNUSED \
|
|
186
|
+
bool eof = false; \
|
|
187
|
+
int32_t lookahead; \
|
|
188
|
+
goto start; \
|
|
189
|
+
next_state: \
|
|
190
|
+
lexer->advance(lexer, skip); \
|
|
191
|
+
start: \
|
|
192
|
+
skip = false; \
|
|
193
|
+
lookahead = lexer->lookahead;
|
|
194
|
+
|
|
195
|
+
#define ADVANCE(state_value) \
|
|
196
|
+
{ \
|
|
197
|
+
state = state_value; \
|
|
198
|
+
goto next_state; \
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
#define ADVANCE_MAP(...) \
|
|
202
|
+
{ \
|
|
203
|
+
static const uint16_t map[] = { __VA_ARGS__ }; \
|
|
204
|
+
for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \
|
|
205
|
+
if (map[i] == lookahead) { \
|
|
206
|
+
state = map[i + 1]; \
|
|
207
|
+
goto next_state; \
|
|
208
|
+
} \
|
|
209
|
+
} \
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
#define SKIP(state_value) \
|
|
213
|
+
{ \
|
|
214
|
+
skip = true; \
|
|
215
|
+
state = state_value; \
|
|
216
|
+
goto next_state; \
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
#define ACCEPT_TOKEN(symbol_value) \
|
|
220
|
+
result = true; \
|
|
221
|
+
lexer->result_symbol = symbol_value; \
|
|
222
|
+
lexer->mark_end(lexer);
|
|
223
|
+
|
|
224
|
+
#define END_STATE() return result;
|
|
225
|
+
|
|
226
|
+
/*
|
|
227
|
+
* Parse Table Macros
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)
|
|
231
|
+
|
|
232
|
+
#define STATE(id) id
|
|
233
|
+
|
|
234
|
+
#define ACTIONS(id) id
|
|
235
|
+
|
|
236
|
+
#define SHIFT(state_value) \
|
|
237
|
+
{{ \
|
|
238
|
+
.shift = { \
|
|
239
|
+
.type = TSParseActionTypeShift, \
|
|
240
|
+
.state = (state_value) \
|
|
241
|
+
} \
|
|
242
|
+
}}
|
|
243
|
+
|
|
244
|
+
#define SHIFT_REPEAT(state_value) \
|
|
245
|
+
{{ \
|
|
246
|
+
.shift = { \
|
|
247
|
+
.type = TSParseActionTypeShift, \
|
|
248
|
+
.state = (state_value), \
|
|
249
|
+
.repetition = true \
|
|
250
|
+
} \
|
|
251
|
+
}}
|
|
252
|
+
|
|
253
|
+
#define SHIFT_EXTRA() \
|
|
254
|
+
{{ \
|
|
255
|
+
.shift = { \
|
|
256
|
+
.type = TSParseActionTypeShift, \
|
|
257
|
+
.extra = true \
|
|
258
|
+
} \
|
|
259
|
+
}}
|
|
260
|
+
|
|
261
|
+
#define REDUCE(symbol_name, children, precedence, prod_id) \
|
|
262
|
+
{{ \
|
|
263
|
+
.reduce = { \
|
|
264
|
+
.type = TSParseActionTypeReduce, \
|
|
265
|
+
.symbol = symbol_name, \
|
|
266
|
+
.child_count = children, \
|
|
267
|
+
.dynamic_precedence = precedence, \
|
|
268
|
+
.production_id = prod_id \
|
|
269
|
+
}, \
|
|
270
|
+
}}
|
|
271
|
+
|
|
272
|
+
#define RECOVER() \
|
|
273
|
+
{{ \
|
|
274
|
+
.type = TSParseActionTypeRecover \
|
|
275
|
+
}}
|
|
276
|
+
|
|
277
|
+
#define ACCEPT_INPUT() \
|
|
278
|
+
{{ \
|
|
279
|
+
.type = TSParseActionTypeAccept \
|
|
280
|
+
}}
|
|
281
|
+
|
|
282
|
+
#ifdef __cplusplus
|
|
283
|
+
}
|
|
284
|
+
#endif
|
|
285
|
+
|
|
286
|
+
#endif // TREE_SITTER_PARSER_H_
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#ifndef TREE_SITTER_POINT_H_
|
|
2
|
+
#define TREE_SITTER_POINT_H_
|
|
3
|
+
|
|
4
|
+
#include "tree_sitter/api.h"
|
|
5
|
+
|
|
6
|
+
#define POINT_ZERO ((TSPoint) {0, 0})
|
|
7
|
+
#define POINT_MAX ((TSPoint) {UINT32_MAX, UINT32_MAX})
|
|
8
|
+
|
|
9
|
+
static inline TSPoint point__new(unsigned row, unsigned column) {
|
|
10
|
+
TSPoint result = {row, column};
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static inline TSPoint point_add(TSPoint a, TSPoint b) {
|
|
15
|
+
if (b.row > 0)
|
|
16
|
+
return point__new(a.row + b.row, b.column);
|
|
17
|
+
else
|
|
18
|
+
return point__new(a.row, a.column + b.column);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static inline TSPoint point_sub(TSPoint a, TSPoint b) {
|
|
22
|
+
if (a.row > b.row)
|
|
23
|
+
return point__new(a.row - b.row, a.column);
|
|
24
|
+
else
|
|
25
|
+
return point__new(0, (a.column >= b.column) ? a.column - b.column : 0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static inline bool point_lte(TSPoint a, TSPoint b) {
|
|
29
|
+
return (a.row < b.row) || (a.row == b.row && a.column <= b.column);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static inline bool point_lt(TSPoint a, TSPoint b) {
|
|
33
|
+
return (a.row < b.row) || (a.row == b.row && a.column < b.column);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static inline bool point_gt(TSPoint a, TSPoint b) {
|
|
37
|
+
return (a.row > b.row) || (a.row == b.row && a.column > b.column);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static inline bool point_gte(TSPoint a, TSPoint b) {
|
|
41
|
+
return (a.row > b.row) || (a.row == b.row && a.column >= b.column);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static inline bool point_eq(TSPoint a, TSPoint b) {
|
|
45
|
+
return a.row == b.row && a.column == b.column;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#endif
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// "License": Public Domain
|
|
2
|
+
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
|
|
3
|
+
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
|
|
4
|
+
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
|
|
5
|
+
// an example on how to get the endian conversion functions on different platforms.
|
|
6
|
+
|
|
7
|
+
// updates from https://github.com/mikepb/endian.h/issues/4
|
|
8
|
+
|
|
9
|
+
#ifndef ENDIAN_H
|
|
10
|
+
#define ENDIAN_H
|
|
11
|
+
|
|
12
|
+
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
|
|
13
|
+
|
|
14
|
+
# define __WINDOWS__
|
|
15
|
+
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
#if defined(HAVE_ENDIAN_H) || \
|
|
19
|
+
defined(__linux__) || \
|
|
20
|
+
defined(__GNU__) || \
|
|
21
|
+
defined(__illumos__) || \
|
|
22
|
+
defined(__NetBSD__) || \
|
|
23
|
+
defined(__OpenBSD__) || \
|
|
24
|
+
defined(__CYGWIN__) || \
|
|
25
|
+
defined(__MSYS__) || \
|
|
26
|
+
defined(__EMSCRIPTEN__) || \
|
|
27
|
+
defined(__wasi__)
|
|
28
|
+
|
|
29
|
+
#if defined(__NetBSD__)
|
|
30
|
+
#define _NETBSD_SOURCE 1
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
# include <endian.h>
|
|
34
|
+
|
|
35
|
+
#elif defined(HAVE_SYS_ENDIAN_H) || \
|
|
36
|
+
defined(__FreeBSD__) || \
|
|
37
|
+
defined(__DragonFly__)
|
|
38
|
+
|
|
39
|
+
# include <sys/endian.h>
|
|
40
|
+
|
|
41
|
+
#elif defined(__APPLE__)
|
|
42
|
+
# define __BYTE_ORDER BYTE_ORDER
|
|
43
|
+
# define __BIG_ENDIAN BIG_ENDIAN
|
|
44
|
+
# define __LITTLE_ENDIAN LITTLE_ENDIAN
|
|
45
|
+
# define __PDP_ENDIAN PDP_ENDIAN
|
|
46
|
+
|
|
47
|
+
# if !defined(_POSIX_C_SOURCE)
|
|
48
|
+
# include <libkern/OSByteOrder.h>
|
|
49
|
+
|
|
50
|
+
# define htobe16(x) OSSwapHostToBigInt16(x)
|
|
51
|
+
# define htole16(x) OSSwapHostToLittleInt16(x)
|
|
52
|
+
# define be16toh(x) OSSwapBigToHostInt16(x)
|
|
53
|
+
# define le16toh(x) OSSwapLittleToHostInt16(x)
|
|
54
|
+
|
|
55
|
+
# define htobe32(x) OSSwapHostToBigInt32(x)
|
|
56
|
+
# define htole32(x) OSSwapHostToLittleInt32(x)
|
|
57
|
+
# define be32toh(x) OSSwapBigToHostInt32(x)
|
|
58
|
+
# define le32toh(x) OSSwapLittleToHostInt32(x)
|
|
59
|
+
|
|
60
|
+
# define htobe64(x) OSSwapHostToBigInt64(x)
|
|
61
|
+
# define htole64(x) OSSwapHostToLittleInt64(x)
|
|
62
|
+
# define be64toh(x) OSSwapBigToHostInt64(x)
|
|
63
|
+
# define le64toh(x) OSSwapLittleToHostInt64(x)
|
|
64
|
+
# else
|
|
65
|
+
# if BYTE_ORDER == LITTLE_ENDIAN
|
|
66
|
+
# define htobe16(x) __builtin_bswap16(x)
|
|
67
|
+
# define htole16(x) (x)
|
|
68
|
+
# define be16toh(x) __builtin_bswap16(x)
|
|
69
|
+
# define le16toh(x) (x)
|
|
70
|
+
|
|
71
|
+
# define htobe32(x) __builtin_bswap32(x)
|
|
72
|
+
# define htole32(x) (x)
|
|
73
|
+
# define be32toh(x) __builtin_bswap32(x)
|
|
74
|
+
# define le32toh(x) (x)
|
|
75
|
+
|
|
76
|
+
# define htobe64(x) __builtin_bswap64(x)
|
|
77
|
+
# define htole64(x) (x)
|
|
78
|
+
# define be64toh(x) __builtin_bswap64(x)
|
|
79
|
+
# define le64toh(x) (x)
|
|
80
|
+
# elif BYTE_ORDER == BIG_ENDIAN
|
|
81
|
+
# define htobe16(x) (x)
|
|
82
|
+
# define htole16(x) __builtin_bswap16(x)
|
|
83
|
+
# define be16toh(x) (x)
|
|
84
|
+
# define le16toh(x) __builtin_bswap16(x)
|
|
85
|
+
|
|
86
|
+
# define htobe32(x) (x)
|
|
87
|
+
# define htole32(x) __builtin_bswap32(x)
|
|
88
|
+
# define be32toh(x) (x)
|
|
89
|
+
# define le32toh(x) __builtin_bswap32(x)
|
|
90
|
+
|
|
91
|
+
# define htobe64(x) (x)
|
|
92
|
+
# define htole64(x) __builtin_bswap64(x)
|
|
93
|
+
# define be64toh(x) (x)
|
|
94
|
+
# define le64toh(x) __builtin_bswap64(x)
|
|
95
|
+
# else
|
|
96
|
+
# error byte order not supported
|
|
97
|
+
# endif
|
|
98
|
+
# endif
|
|
99
|
+
|
|
100
|
+
#elif defined(__WINDOWS__)
|
|
101
|
+
|
|
102
|
+
# if defined(_MSC_VER) && !defined(__clang__)
|
|
103
|
+
# include <stdlib.h>
|
|
104
|
+
# define B_SWAP_16(x) _byteswap_ushort(x)
|
|
105
|
+
# define B_SWAP_32(x) _byteswap_ulong(x)
|
|
106
|
+
# define B_SWAP_64(x) _byteswap_uint64(x)
|
|
107
|
+
# else
|
|
108
|
+
# define B_SWAP_16(x) __builtin_bswap16(x)
|
|
109
|
+
# define B_SWAP_32(x) __builtin_bswap32(x)
|
|
110
|
+
# define B_SWAP_64(x) __builtin_bswap64(x)
|
|
111
|
+
# endif
|
|
112
|
+
|
|
113
|
+
# if defined(__MINGW32__) || defined(HAVE_SYS_PARAM_H)
|
|
114
|
+
# include <sys/param.h>
|
|
115
|
+
# endif
|
|
116
|
+
|
|
117
|
+
# ifndef BIG_ENDIAN
|
|
118
|
+
# ifdef __BIG_ENDIAN
|
|
119
|
+
# define BIG_ENDIAN __BIG_ENDIAN
|
|
120
|
+
# elif defined(__ORDER_BIG_ENDIAN__)
|
|
121
|
+
# define BIG_ENDIAN __ORDER_BIG_ENDIAN__
|
|
122
|
+
# else
|
|
123
|
+
# define BIG_ENDIAN 4321
|
|
124
|
+
# endif
|
|
125
|
+
# endif
|
|
126
|
+
|
|
127
|
+
# ifndef LITTLE_ENDIAN
|
|
128
|
+
# ifdef __LITTLE_ENDIAN
|
|
129
|
+
# define LITTLE_ENDIAN __LITTLE_ENDIAN
|
|
130
|
+
# elif defined(__ORDER_LITTLE_ENDIAN__)
|
|
131
|
+
# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
|
|
132
|
+
# else
|
|
133
|
+
# define LITTLE_ENDIAN 1234
|
|
134
|
+
# endif
|
|
135
|
+
# endif
|
|
136
|
+
|
|
137
|
+
# ifndef BYTE_ORDER
|
|
138
|
+
# ifdef __BYTE_ORDER
|
|
139
|
+
# define BYTE_ORDER __BYTE_ORDER
|
|
140
|
+
# elif defined(__BYTE_ORDER__)
|
|
141
|
+
# define BYTE_ORDER __BYTE_ORDER__
|
|
142
|
+
# else
|
|
143
|
+
/* assume LE on Windows if nothing was defined */
|
|
144
|
+
# define BYTE_ORDER LITTLE_ENDIAN
|
|
145
|
+
# endif
|
|
146
|
+
# endif
|
|
147
|
+
|
|
148
|
+
# if BYTE_ORDER == LITTLE_ENDIAN
|
|
149
|
+
|
|
150
|
+
# define htobe16(x) B_SWAP_16(x)
|
|
151
|
+
# define htole16(x) (x)
|
|
152
|
+
# define be16toh(x) B_SWAP_16(x)
|
|
153
|
+
# define le16toh(x) (x)
|
|
154
|
+
|
|
155
|
+
# define htobe32(x) B_SWAP_32(x)
|
|
156
|
+
# define htole32(x) (x)
|
|
157
|
+
# define be32toh(x) B_SWAP_32(x)
|
|
158
|
+
# define le32toh(x) (x)
|
|
159
|
+
|
|
160
|
+
# define htobe64(x) B_SWAP_64(x)
|
|
161
|
+
# define htole64(x) (x)
|
|
162
|
+
# define be64toh(x) B_SWAP_64(x)
|
|
163
|
+
# define le64toh(x) (x)
|
|
164
|
+
|
|
165
|
+
# elif BYTE_ORDER == BIG_ENDIAN
|
|
166
|
+
|
|
167
|
+
# define htobe16(x) (x)
|
|
168
|
+
# define htole16(x) B_SWAP_16(x)
|
|
169
|
+
# define be16toh(x) (x)
|
|
170
|
+
# define le16toh(x) B_SWAP_16(x)
|
|
171
|
+
|
|
172
|
+
# define htobe32(x) (x)
|
|
173
|
+
# define htole32(x) B_SWAP_32(x)
|
|
174
|
+
# define be32toh(x) (x)
|
|
175
|
+
# define le32toh(x) B_SWAP_32(x)
|
|
176
|
+
|
|
177
|
+
# define htobe64(x) (x)
|
|
178
|
+
# define htole64(x) B_SWAP_64(x)
|
|
179
|
+
# define be64toh(x) (x)
|
|
180
|
+
# define le64toh(x) B_SWAP_64(x)
|
|
181
|
+
|
|
182
|
+
# else
|
|
183
|
+
|
|
184
|
+
# error byte order not supported
|
|
185
|
+
|
|
186
|
+
# endif
|
|
187
|
+
|
|
188
|
+
#elif defined(__QNXNTO__)
|
|
189
|
+
|
|
190
|
+
# include <gulliver.h>
|
|
191
|
+
|
|
192
|
+
# define __LITTLE_ENDIAN 1234
|
|
193
|
+
# define __BIG_ENDIAN 4321
|
|
194
|
+
# define __PDP_ENDIAN 3412
|
|
195
|
+
|
|
196
|
+
# if defined(__BIGENDIAN__)
|
|
197
|
+
|
|
198
|
+
# define __BYTE_ORDER __BIG_ENDIAN
|
|
199
|
+
|
|
200
|
+
# define htobe16(x) (x)
|
|
201
|
+
# define htobe32(x) (x)
|
|
202
|
+
# define htobe64(x) (x)
|
|
203
|
+
|
|
204
|
+
# define htole16(x) ENDIAN_SWAP16(x)
|
|
205
|
+
# define htole32(x) ENDIAN_SWAP32(x)
|
|
206
|
+
# define htole64(x) ENDIAN_SWAP64(x)
|
|
207
|
+
|
|
208
|
+
# elif defined(__LITTLEENDIAN__)
|
|
209
|
+
|
|
210
|
+
# define __BYTE_ORDER __LITTLE_ENDIAN
|
|
211
|
+
|
|
212
|
+
# define htole16(x) (x)
|
|
213
|
+
# define htole32(x) (x)
|
|
214
|
+
# define htole64(x) (x)
|
|
215
|
+
|
|
216
|
+
# define htobe16(x) ENDIAN_SWAP16(x)
|
|
217
|
+
# define htobe32(x) ENDIAN_SWAP32(x)
|
|
218
|
+
# define htobe64(x) ENDIAN_SWAP64(x)
|
|
219
|
+
|
|
220
|
+
# else
|
|
221
|
+
|
|
222
|
+
# error byte order not supported
|
|
223
|
+
|
|
224
|
+
# endif
|
|
225
|
+
|
|
226
|
+
# define be16toh(x) ENDIAN_BE16(x)
|
|
227
|
+
# define be32toh(x) ENDIAN_BE32(x)
|
|
228
|
+
# define be64toh(x) ENDIAN_BE64(x)
|
|
229
|
+
# define le16toh(x) ENDIAN_LE16(x)
|
|
230
|
+
# define le32toh(x) ENDIAN_LE32(x)
|
|
231
|
+
# define le64toh(x) ENDIAN_LE64(x)
|
|
232
|
+
|
|
233
|
+
#else
|
|
234
|
+
|
|
235
|
+
# error platform not supported
|
|
236
|
+
|
|
237
|
+
#endif
|
|
238
|
+
|
|
239
|
+
#endif
|