@konomanoasa/tree-sitter-c 0.0.0-stage → 0.2.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.
package/src/tokens.h ADDED
@@ -0,0 +1,287 @@
1
+ /* Generated by npm run generate. */
2
+ #ifndef TREE_SITTER_C_TOKENS_H
3
+ #define TREE_SITTER_C_TOKENS_H
4
+ typedef enum {
5
+ TOK_IDENTIFIER,
6
+ TOK_PP_NUMBER,
7
+ TOK_BASE_PREFIX,
8
+ TOK_INTEGER_DIGITS,
9
+ TOK_SIGNIFICAND_DIGITS,
10
+ TOK_DECIMAL_POINT,
11
+ TOK_FRACTION_DIGITS,
12
+ TOK_EXPONENT_MARKER,
13
+ TOK_EXPONENT_SIGN,
14
+ TOK_EXPONENT_DIGITS,
15
+ TOK_INTEGER_SUFFIX,
16
+ TOK_FLOATING_SUFFIX,
17
+ TOK_NUMBER_SPLICE,
18
+ TOK_SIGNIFICAND_SPLICE,
19
+ TOK_LEADING_DECIMAL_POINT,
20
+ TOK_RAW_NUMBER_HEAD,
21
+ TOK_RAW_NUMBER_TAIL,
22
+ TOK_CALL_START,
23
+ TOK_CANDIDATE_START,
24
+ TOK_EXTERNAL_CANDIDATE_START,
25
+ TOK_CANDIDATE_COMMA,
26
+ TOK_CANDIDATE_CLOSE,
27
+ TOK_ENCODING_PREFIX,
28
+ TOK_CHARACTER_OPEN,
29
+ TOK_STRING_OPEN,
30
+ TOK_LITERAL_TEXT,
31
+ TOK_LITERAL_CLOSE,
32
+ TOK_ESCAPE_SEQUENCE,
33
+ TOK_LINE_SPLICE,
34
+ TOK_HEADER_NAME,
35
+ TOK_OTHER_PREPROCESSING_TOKEN,
36
+ TOK_COMMENT,
37
+ TOK_LAYOUT,
38
+ TOK_DIRECTIVE_END,
39
+ TOK_DIRECTIVE_HASH,
40
+ TOK_EXTRA_DIRECTIVE_HASH,
41
+ TOK_IF_HASH,
42
+ TOK_TRANSPARENT_START,
43
+ TOK_STRUCTURAL_START,
44
+ TOK_BRANCH_TRIVIA_END,
45
+ TOK_ELLIPSIS_TRIVIA_END,
46
+ TOK_BRANCH_HASH,
47
+ TOK_MACRO_OPEN,
48
+ TOK_ATOMIC_OPEN,
49
+ TOK_PRAGMA_CLOSE,
50
+ TOK_IDENTIFIER_LIST_OPEN,
51
+ TOK_LIB_ALIGNOF,
52
+ TOK_LIB_OFFSETOF,
53
+ TOK_LIB_VA_ARG,
54
+ TOK_PP_IF,
55
+ TOK_PP_IFDEF,
56
+ TOK_PP_IFNDEF,
57
+ TOK_PP_ELIF,
58
+ TOK_PP_ELSE,
59
+ TOK_PP_ENDIF,
60
+ TOK_PP_INCLUDE,
61
+ TOK_PP_DEFINE,
62
+ TOK_PP_UNDEF,
63
+ TOK_PP_LINE,
64
+ TOK_PP_ERROR,
65
+ TOK_PP_PRAGMA,
66
+ TOK_KW_AUTO,
67
+ TOK_KW_BREAK,
68
+ TOK_KW_CASE,
69
+ TOK_KW_CHAR,
70
+ TOK_KW_CONST,
71
+ TOK_KW_CONTINUE,
72
+ TOK_KW_DEFAULT,
73
+ TOK_KW_DO,
74
+ TOK_KW_DOUBLE,
75
+ TOK_KW_ELSE,
76
+ TOK_KW_ENUM,
77
+ TOK_KW_EXTERN,
78
+ TOK_KW_FLOAT,
79
+ TOK_KW_FOR,
80
+ TOK_KW_GOTO,
81
+ TOK_KW_IF,
82
+ TOK_KW_INLINE,
83
+ TOK_KW_INT,
84
+ TOK_KW_LONG,
85
+ TOK_KW_REGISTER,
86
+ TOK_KW_RESTRICT,
87
+ TOK_KW_RETURN,
88
+ TOK_KW_SHORT,
89
+ TOK_KW_SIGNED,
90
+ TOK_KW_SIZEOF,
91
+ TOK_KW_STATIC,
92
+ TOK_KW_STRUCT,
93
+ TOK_KW_SWITCH,
94
+ TOK_KW_TYPEDEF,
95
+ TOK_KW_UNION,
96
+ TOK_KW_UNSIGNED,
97
+ TOK_KW_VOID,
98
+ TOK_KW_VOLATILE,
99
+ TOK_KW_WHILE,
100
+ TOK_KW__ALIGNAS,
101
+ TOK_KW__ALIGNOF,
102
+ TOK_KW__ATOMIC,
103
+ TOK_KW__BOOL,
104
+ TOK_KW__COMPLEX,
105
+ TOK_KW__GENERIC,
106
+ TOK_KW__IMAGINARY,
107
+ TOK_KW__NORETURN,
108
+ TOK_KW__STATIC_ASSERT,
109
+ TOK_KW__THREAD_LOCAL,
110
+ TOK_KW__PRAGMA,
111
+ TOK_P_LBRACKET,
112
+ TOK_P_RBRACKET,
113
+ TOK_P_LPAREN,
114
+ TOK_P_RPAREN,
115
+ TOK_P_LBRACE,
116
+ TOK_P_RBRACE,
117
+ TOK_P_DOT,
118
+ TOK_P_ARROW,
119
+ TOK_P_INC,
120
+ TOK_P_DEC,
121
+ TOK_P_AMP,
122
+ TOK_P_STAR,
123
+ TOK_P_PLUS,
124
+ TOK_P_MINUS,
125
+ TOK_P_TILDE,
126
+ TOK_P_BANG,
127
+ TOK_P_SLASH,
128
+ TOK_P_PERCENT,
129
+ TOK_P_SHL,
130
+ TOK_P_SHR,
131
+ TOK_P_LT,
132
+ TOK_P_GT,
133
+ TOK_P_LE,
134
+ TOK_P_GE,
135
+ TOK_P_EQ,
136
+ TOK_P_NE,
137
+ TOK_P_CARET,
138
+ TOK_P_PIPE,
139
+ TOK_P_AND,
140
+ TOK_P_OR,
141
+ TOK_P_QUESTION,
142
+ TOK_P_COLON,
143
+ TOK_P_SEMI,
144
+ TOK_P_ELLIPSIS,
145
+ TOK_P_ASSIGN,
146
+ TOK_P_MUL_ASSIGN,
147
+ TOK_P_DIV_ASSIGN,
148
+ TOK_P_MOD_ASSIGN,
149
+ TOK_P_ADD_ASSIGN,
150
+ TOK_P_SUB_ASSIGN,
151
+ TOK_P_SHL_ASSIGN,
152
+ TOK_P_SHR_ASSIGN,
153
+ TOK_P_AND_ASSIGN,
154
+ TOK_P_XOR_ASSIGN,
155
+ TOK_P_OR_ASSIGN,
156
+ TOK_P_COMMA,
157
+ TOK_P_HASH,
158
+ TOK_P_PASTE,
159
+ TOKEN_COUNT
160
+ } Token;
161
+
162
+ typedef struct { const char *text; Token token; } Spelling;
163
+
164
+ static const Spelling source_words[] = {
165
+ { "auto", TOK_KW_AUTO },
166
+ { "break", TOK_KW_BREAK },
167
+ { "case", TOK_KW_CASE },
168
+ { "char", TOK_KW_CHAR },
169
+ { "const", TOK_KW_CONST },
170
+ { "continue", TOK_KW_CONTINUE },
171
+ { "default", TOK_KW_DEFAULT },
172
+ { "do", TOK_KW_DO },
173
+ { "double", TOK_KW_DOUBLE },
174
+ { "else", TOK_KW_ELSE },
175
+ { "enum", TOK_KW_ENUM },
176
+ { "extern", TOK_KW_EXTERN },
177
+ { "float", TOK_KW_FLOAT },
178
+ { "for", TOK_KW_FOR },
179
+ { "goto", TOK_KW_GOTO },
180
+ { "if", TOK_KW_IF },
181
+ { "inline", TOK_KW_INLINE },
182
+ { "int", TOK_KW_INT },
183
+ { "long", TOK_KW_LONG },
184
+ { "register", TOK_KW_REGISTER },
185
+ { "restrict", TOK_KW_RESTRICT },
186
+ { "return", TOK_KW_RETURN },
187
+ { "short", TOK_KW_SHORT },
188
+ { "signed", TOK_KW_SIGNED },
189
+ { "sizeof", TOK_KW_SIZEOF },
190
+ { "static", TOK_KW_STATIC },
191
+ { "struct", TOK_KW_STRUCT },
192
+ { "switch", TOK_KW_SWITCH },
193
+ { "typedef", TOK_KW_TYPEDEF },
194
+ { "union", TOK_KW_UNION },
195
+ { "unsigned", TOK_KW_UNSIGNED },
196
+ { "void", TOK_KW_VOID },
197
+ { "volatile", TOK_KW_VOLATILE },
198
+ { "while", TOK_KW_WHILE },
199
+ { "_Alignas", TOK_KW__ALIGNAS },
200
+ { "_Alignof", TOK_KW__ALIGNOF },
201
+ { "_Atomic", TOK_KW__ATOMIC },
202
+ { "_Bool", TOK_KW__BOOL },
203
+ { "_Complex", TOK_KW__COMPLEX },
204
+ { "_Generic", TOK_KW__GENERIC },
205
+ { "_Imaginary", TOK_KW__IMAGINARY },
206
+ { "_Noreturn", TOK_KW__NORETURN },
207
+ { "_Static_assert", TOK_KW__STATIC_ASSERT },
208
+ { "_Thread_local", TOK_KW__THREAD_LOCAL },
209
+ { "_Pragma", TOK_KW__PRAGMA },
210
+ { "alignof", TOK_LIB_ALIGNOF },
211
+ { "offsetof", TOK_LIB_OFFSETOF },
212
+ { "va_arg", TOK_LIB_VA_ARG },
213
+ };
214
+
215
+ static const Spelling directive_names[] = {
216
+ { "if", TOK_PP_IF },
217
+ { "ifdef", TOK_PP_IFDEF },
218
+ { "ifndef", TOK_PP_IFNDEF },
219
+ { "elif", TOK_PP_ELIF },
220
+ { "else", TOK_PP_ELSE },
221
+ { "endif", TOK_PP_ENDIF },
222
+ { "include", TOK_PP_INCLUDE },
223
+ { "define", TOK_PP_DEFINE },
224
+ { "undef", TOK_PP_UNDEF },
225
+ { "line", TOK_PP_LINE },
226
+ { "error", TOK_PP_ERROR },
227
+ { "pragma", TOK_PP_PRAGMA },
228
+ };
229
+
230
+ static const Spelling punctuators[] = {
231
+ { "[", TOK_P_LBRACKET },
232
+ { "]", TOK_P_RBRACKET },
233
+ { "(", TOK_P_LPAREN },
234
+ { ")", TOK_P_RPAREN },
235
+ { "{", TOK_P_LBRACE },
236
+ { "}", TOK_P_RBRACE },
237
+ { ".", TOK_P_DOT },
238
+ { "->", TOK_P_ARROW },
239
+ { "++", TOK_P_INC },
240
+ { "--", TOK_P_DEC },
241
+ { "&", TOK_P_AMP },
242
+ { "*", TOK_P_STAR },
243
+ { "+", TOK_P_PLUS },
244
+ { "-", TOK_P_MINUS },
245
+ { "~", TOK_P_TILDE },
246
+ { "!", TOK_P_BANG },
247
+ { "/", TOK_P_SLASH },
248
+ { "%", TOK_P_PERCENT },
249
+ { "<<", TOK_P_SHL },
250
+ { ">>", TOK_P_SHR },
251
+ { "<", TOK_P_LT },
252
+ { ">", TOK_P_GT },
253
+ { "<=", TOK_P_LE },
254
+ { ">=", TOK_P_GE },
255
+ { "==", TOK_P_EQ },
256
+ { "!=", TOK_P_NE },
257
+ { "^", TOK_P_CARET },
258
+ { "|", TOK_P_PIPE },
259
+ { "&&", TOK_P_AND },
260
+ { "||", TOK_P_OR },
261
+ { "?", TOK_P_QUESTION },
262
+ { ":", TOK_P_COLON },
263
+ { ";", TOK_P_SEMI },
264
+ { "...", TOK_P_ELLIPSIS },
265
+ { "=", TOK_P_ASSIGN },
266
+ { "*=", TOK_P_MUL_ASSIGN },
267
+ { "/=", TOK_P_DIV_ASSIGN },
268
+ { "%=", TOK_P_MOD_ASSIGN },
269
+ { "+=", TOK_P_ADD_ASSIGN },
270
+ { "-=", TOK_P_SUB_ASSIGN },
271
+ { "<<=", TOK_P_SHL_ASSIGN },
272
+ { ">>=", TOK_P_SHR_ASSIGN },
273
+ { "&=", TOK_P_AND_ASSIGN },
274
+ { "^=", TOK_P_XOR_ASSIGN },
275
+ { "|=", TOK_P_OR_ASSIGN },
276
+ { ",", TOK_P_COMMA },
277
+ { "#", TOK_P_HASH },
278
+ { "##", TOK_P_PASTE },
279
+ { "<:", TOK_P_LBRACKET },
280
+ { ":>", TOK_P_RBRACKET },
281
+ { "<%", TOK_P_LBRACE },
282
+ { "%>", TOK_P_RBRACE },
283
+ { "%:", TOK_P_HASH },
284
+ { "%:%:", TOK_P_PASTE },
285
+ };
286
+
287
+ #endif
@@ -0,0 +1,162 @@
1
+ {
2
+ "categories": [
3
+ "_identifier",
4
+ "pp_number",
5
+ "base_prefix",
6
+ "integer_digits",
7
+ "significand_digits",
8
+ "decimal_point",
9
+ "_fraction_digits",
10
+ "exponent_marker",
11
+ "exponent_sign",
12
+ "exponent_digits",
13
+ "integer_suffix",
14
+ "floating_suffix",
15
+ "_number_splice",
16
+ "_significand_splice",
17
+ "_leading_decimal_point",
18
+ "_raw_number_head",
19
+ "_raw_number_tail",
20
+ "_call_start",
21
+ "_candidate_start",
22
+ "_external_candidate_start",
23
+ "_candidate_comma",
24
+ "_candidate_close",
25
+ "encoding_prefix",
26
+ "_character_open",
27
+ "_string_open",
28
+ "_literal_text",
29
+ "_literal_close",
30
+ "escape_sequence",
31
+ "line_splice",
32
+ "header_name",
33
+ "other_preprocessing_token",
34
+ "comment",
35
+ "_layout",
36
+ "_directive_end",
37
+ "_directive_hash",
38
+ "_extra_directive_hash",
39
+ "_if_hash",
40
+ "_transparent_start",
41
+ "_structural_start",
42
+ "_branch_trivia_end",
43
+ "_ellipsis_trivia_end",
44
+ "_branch_hash",
45
+ "_macro_open",
46
+ "_atomic_open",
47
+ "_pragma_close",
48
+ "_identifier_list_open"
49
+ ],
50
+ "typeArgumentMacros": ["alignof", "offsetof", "va_arg"],
51
+ "directives": [
52
+ "if",
53
+ "ifdef",
54
+ "ifndef",
55
+ "elif",
56
+ "else",
57
+ "endif",
58
+ "include",
59
+ "define",
60
+ "undef",
61
+ "line",
62
+ "error",
63
+ "pragma"
64
+ ],
65
+ "keywords": [
66
+ "auto",
67
+ "break",
68
+ "case",
69
+ "char",
70
+ "const",
71
+ "continue",
72
+ "default",
73
+ "do",
74
+ "double",
75
+ "else",
76
+ "enum",
77
+ "extern",
78
+ "float",
79
+ "for",
80
+ "goto",
81
+ "if",
82
+ "inline",
83
+ "int",
84
+ "long",
85
+ "register",
86
+ "restrict",
87
+ "return",
88
+ "short",
89
+ "signed",
90
+ "sizeof",
91
+ "static",
92
+ "struct",
93
+ "switch",
94
+ "typedef",
95
+ "union",
96
+ "unsigned",
97
+ "void",
98
+ "volatile",
99
+ "while",
100
+ "_Alignas",
101
+ "_Alignof",
102
+ "_Atomic",
103
+ "_Bool",
104
+ "_Complex",
105
+ "_Generic",
106
+ "_Imaginary",
107
+ "_Noreturn",
108
+ "_Static_assert",
109
+ "_Thread_local",
110
+ "_Pragma"
111
+ ],
112
+ "punctuators": {
113
+ "lbracket": "[",
114
+ "rbracket": "]",
115
+ "lparen": "(",
116
+ "rparen": ")",
117
+ "lbrace": "{",
118
+ "rbrace": "}",
119
+ "dot": ".",
120
+ "arrow": "->",
121
+ "inc": "++",
122
+ "dec": "--",
123
+ "amp": "&",
124
+ "star": "*",
125
+ "plus": "+",
126
+ "minus": "-",
127
+ "tilde": "~",
128
+ "bang": "!",
129
+ "slash": "/",
130
+ "percent": "%",
131
+ "shl": "<<",
132
+ "shr": ">>",
133
+ "lt": "<",
134
+ "gt": ">",
135
+ "le": "<=",
136
+ "ge": ">=",
137
+ "eq": "==",
138
+ "ne": "!=",
139
+ "caret": "^",
140
+ "pipe": "|",
141
+ "and": "&&",
142
+ "or": "||",
143
+ "question": "?",
144
+ "colon": ":",
145
+ "semi": ";",
146
+ "ellipsis": "...",
147
+ "assign": "=",
148
+ "mul_assign": "*=",
149
+ "div_assign": "/=",
150
+ "mod_assign": "%=",
151
+ "add_assign": "+=",
152
+ "sub_assign": "-=",
153
+ "shl_assign": "<<=",
154
+ "shr_assign": ">>=",
155
+ "and_assign": "&=",
156
+ "xor_assign": "^=",
157
+ "or_assign": "|=",
158
+ "comma": ",",
159
+ "hash": "#",
160
+ "paste": "##"
161
+ }
162
+ }
@@ -0,0 +1,54 @@
1
+ #ifndef TREE_SITTER_ALLOC_H_
2
+ #define TREE_SITTER_ALLOC_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include <stdbool.h>
9
+ #include <stdio.h>
10
+ #include <stdlib.h>
11
+
12
+ // Allow clients to override allocation functions
13
+ #ifdef TREE_SITTER_REUSE_ALLOCATOR
14
+
15
+ extern void *(*ts_current_malloc)(size_t size);
16
+ extern void *(*ts_current_calloc)(size_t count, size_t size);
17
+ extern void *(*ts_current_realloc)(void *ptr, size_t size);
18
+ extern void (*ts_current_free)(void *ptr);
19
+
20
+ #ifndef ts_malloc
21
+ #define ts_malloc ts_current_malloc
22
+ #endif
23
+ #ifndef ts_calloc
24
+ #define ts_calloc ts_current_calloc
25
+ #endif
26
+ #ifndef ts_realloc
27
+ #define ts_realloc ts_current_realloc
28
+ #endif
29
+ #ifndef ts_free
30
+ #define ts_free ts_current_free
31
+ #endif
32
+
33
+ #else
34
+
35
+ #ifndef ts_malloc
36
+ #define ts_malloc malloc
37
+ #endif
38
+ #ifndef ts_calloc
39
+ #define ts_calloc calloc
40
+ #endif
41
+ #ifndef ts_realloc
42
+ #define ts_realloc realloc
43
+ #endif
44
+ #ifndef ts_free
45
+ #define ts_free free
46
+ #endif
47
+
48
+ #endif
49
+
50
+ #ifdef __cplusplus
51
+ }
52
+ #endif
53
+
54
+ #endif // TREE_SITTER_ALLOC_H_