Skip to content

Commit 22801a4

Browse files
committed
Bump tree-sitter-cli to 0.19
1 parent 32cd5a0 commit 22801a4

File tree

8 files changed

+115
-121
lines changed

8 files changed

+115
-121
lines changed

binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"sources": [
1010
"src/parser.c",
11-
"src/binding.cc",
11+
"bindings/node/binding.cc",
1212
"src/scanner.cc"
1313
],
1414
"cflags_c": [
File renamed without changes.

bindings/node/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
try {
2+
module.exports = require("../../build/Release/tree_sitter_ruby_binding");
3+
} catch (error1) {
4+
if (error1.code !== 'MODULE_NOT_FOUND') {
5+
throw error1;
6+
}
7+
try {
8+
module.exports = require("../../build/Debug/tree_sitter_ruby_binding");
9+
} catch (error2) {
10+
if (error2.code !== 'MODULE_NOT_FOUND') {
11+
throw error2;
12+
}
13+
throw error1
14+
}
15+
}
16+
17+
try {
18+
module.exports.nodeTypeInfo = require("../../src/node-types.json");
19+
} catch (_) {}

index.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
"name": "tree-sitter-ruby",
33
"version": "0.17.0",
44
"description": "Ruby grammar for tree-sitter",
5-
"main": "index.js",
5+
"main": "bindings/node",
66
"keywords": [
77
"parser",
88
"lexer"
99
],
1010
"author": "Rob Rix",
1111
"license": "MIT",
1212
"dependencies": {
13-
"nan": "^2.12.1",
13+
"nan": "^2.14.1",
1414
"prebuild-install": "^5.0.0"
1515
},
1616
"devDependencies": {
1717
"prebuild": "^10.0.1",
18-
"tree-sitter-cli": "^0.18.2"
18+
"tree-sitter-cli": "^0.19.1"
1919
},
2020
"scripts": {
2121
"install": "prebuild-install || node-gyp rebuild",

src/grammar.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6012,6 +6012,7 @@
60126012
}
60136013
],
60146014
"conflicts": [],
6015+
"precedences": [],
60156016
"externals": [
60166017
{
60176018
"type": "SYMBOL",

src/parser.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
66
#endif
77

8-
#define LANGUAGE_VERSION 12
8+
#define LANGUAGE_VERSION 13
99
#define STATE_COUNT 3312
1010
#define LARGE_STATE_COUNT 1237
1111
#define SYMBOL_COUNT 275
@@ -14,6 +14,7 @@
1414
#define EXTERNAL_TOKEN_COUNT 25
1515
#define FIELD_COUNT 26
1616
#define MAX_ALIAS_SEQUENCE_LENGTH 8
17+
#define PRODUCTION_ID_COUNT 66
1718

1819
enum {
1920
sym_identifier = 1,
@@ -2037,7 +2038,7 @@ static const char *ts_field_names[] = {
20372038
[field_variable] = "variable",
20382039
};
20392040

2040-
static const TSFieldMapSlice ts_field_map_slices[66] = {
2041+
static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = {
20412042
[1] = {.index = 0, .length = 2},
20422043
[6] = {.index = 2, .length = 2},
20432044
[7] = {.index = 4, .length = 2},
@@ -2254,7 +2255,7 @@ static const TSFieldMapEntry ts_field_map_entries[] = {
22542255
{field_parameters, 5, .inherited = true},
22552256
};
22562257

2257-
static TSSymbol ts_alias_sequences[66][MAX_ALIAS_SEQUENCE_LENGTH] = {
2258+
static TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
22582259
[0] = {0},
22592260
[1] = {
22602261
[0] = sym_call,
@@ -238232,13 +238233,24 @@ extern const TSLanguage *tree_sitter_ruby(void) {
238232238233
.alias_count = ALIAS_COUNT,
238233238234
.token_count = TOKEN_COUNT,
238234238235
.external_token_count = EXTERNAL_TOKEN_COUNT,
238235-
.symbol_names = ts_symbol_names,
238236-
.symbol_metadata = ts_symbol_metadata,
238236+
.state_count = STATE_COUNT,
238237+
.large_state_count = LARGE_STATE_COUNT,
238238+
.production_id_count = PRODUCTION_ID_COUNT,
238239+
.field_count = FIELD_COUNT,
238240+
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
238237238241
.parse_table = (const uint16_t *)ts_parse_table,
238242+
.small_parse_table = (const uint16_t *)ts_small_parse_table,
238243+
.small_parse_table_map = (const uint32_t *)ts_small_parse_table_map,
238238238244
.parse_actions = ts_parse_actions,
238239-
.lex_modes = ts_lex_modes,
238245+
.symbol_names = ts_symbol_names,
238246+
.field_names = ts_field_names,
238247+
.field_map_slices = (const TSFieldMapSlice *)ts_field_map_slices,
238248+
.field_map_entries = (const TSFieldMapEntry *)ts_field_map_entries,
238249+
.symbol_metadata = ts_symbol_metadata,
238250+
.public_symbol_map = ts_symbol_map,
238251+
.alias_map = ts_non_terminal_alias_map,
238240238252
.alias_sequences = (const TSSymbol *)ts_alias_sequences,
238241-
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
238253+
.lex_modes = ts_lex_modes,
238242238254
.lex_fn = ts_lex,
238243238255
.keyword_lex_fn = ts_lex_keywords,
238244238256
.keyword_capture_token = sym_identifier,
@@ -238251,16 +238263,6 @@ extern const TSLanguage *tree_sitter_ruby(void) {
238251238263
tree_sitter_ruby_external_scanner_serialize,
238252238264
tree_sitter_ruby_external_scanner_deserialize,
238253238265
},
238254-
.field_count = FIELD_COUNT,
238255-
.field_map_slices = (const TSFieldMapSlice *)ts_field_map_slices,
238256-
.field_map_entries = (const TSFieldMapEntry *)ts_field_map_entries,
238257-
.field_names = ts_field_names,
238258-
.large_state_count = LARGE_STATE_COUNT,
238259-
.small_parse_table = (const uint16_t *)ts_small_parse_table,
238260-
.small_parse_table_map = (const uint32_t *)ts_small_parse_table_map,
238261-
.public_symbol_map = ts_symbol_map,
238262-
.alias_map = ts_non_terminal_alias_map,
238263-
.state_count = STATE_COUNT,
238264238266
};
238265238267
return &language;
238266238268
}

src/tree_sitter/parser.h

Lines changed: 72 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ extern "C" {
1313
#define ts_builtin_sym_end 0
1414
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
1515

16+
typedef uint16_t TSStateId;
17+
1618
#ifndef TREE_SITTER_API_H_
1719
typedef uint16_t TSSymbol;
1820
typedef uint16_t TSFieldId;
@@ -30,12 +32,10 @@ typedef struct {
3032
uint16_t length;
3133
} TSFieldMapSlice;
3234

33-
typedef uint16_t TSStateId;
34-
3535
typedef struct {
36-
bool visible : 1;
37-
bool named : 1;
38-
bool supertype: 1;
36+
bool visible;
37+
bool named;
38+
bool supertype;
3939
} TSSymbolMetadata;
4040

4141
typedef struct TSLexer TSLexer;
@@ -57,21 +57,21 @@ typedef enum {
5757
TSParseActionTypeRecover,
5858
} TSParseActionType;
5959

60-
typedef struct {
61-
union {
62-
struct {
63-
TSStateId state;
64-
bool extra : 1;
65-
bool repetition : 1;
66-
} shift;
67-
struct {
68-
TSSymbol symbol;
69-
int16_t dynamic_precedence;
70-
uint8_t child_count;
71-
uint8_t production_id;
72-
} reduce;
73-
} params;
74-
TSParseActionType type : 4;
60+
typedef union {
61+
struct {
62+
uint8_t type;
63+
TSStateId state;
64+
bool extra;
65+
bool repetition;
66+
} shift;
67+
struct {
68+
uint8_t type;
69+
uint8_t child_count;
70+
TSSymbol symbol;
71+
int16_t dynamic_precedence;
72+
uint16_t production_id;
73+
} reduce;
74+
uint8_t type;
7575
} TSParseAction;
7676

7777
typedef struct {
@@ -83,7 +83,7 @@ typedef union {
8383
TSParseAction action;
8484
struct {
8585
uint8_t count;
86-
bool reusable : 1;
86+
bool reusable;
8787
} entry;
8888
} TSParseActionEntry;
8989

@@ -93,13 +93,24 @@ struct TSLanguage {
9393
uint32_t alias_count;
9494
uint32_t token_count;
9595
uint32_t external_token_count;
96-
const char **symbol_names;
97-
const TSSymbolMetadata *symbol_metadata;
96+
uint32_t state_count;
97+
uint32_t large_state_count;
98+
uint32_t production_id_count;
99+
uint32_t field_count;
100+
uint16_t max_alias_sequence_length;
98101
const uint16_t *parse_table;
102+
const uint16_t *small_parse_table;
103+
const uint32_t *small_parse_table_map;
99104
const TSParseActionEntry *parse_actions;
100-
const TSLexMode *lex_modes;
105+
const char **symbol_names;
106+
const char **field_names;
107+
const TSFieldMapSlice *field_map_slices;
108+
const TSFieldMapEntry *field_map_entries;
109+
const TSSymbolMetadata *symbol_metadata;
110+
const TSSymbol *public_symbol_map;
111+
const uint16_t *alias_map;
101112
const TSSymbol *alias_sequences;
102-
uint16_t max_alias_sequence_length;
113+
const TSLexMode *lex_modes;
103114
bool (*lex_fn)(TSLexer *, TSStateId);
104115
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
105116
TSSymbol keyword_capture_token;
@@ -112,16 +123,6 @@ struct TSLanguage {
112123
unsigned (*serialize)(void *, char *);
113124
void (*deserialize)(void *, const char *, unsigned);
114125
} external_scanner;
115-
uint32_t field_count;
116-
const TSFieldMapSlice *field_map_slices;
117-
const TSFieldMapEntry *field_map_entries;
118-
const char **field_names;
119-
uint32_t large_state_count;
120-
const uint16_t *small_parse_table;
121-
const uint32_t *small_parse_table_map;
122-
const TSSymbol *public_symbol_map;
123-
const uint16_t *alias_map;
124-
uint32_t state_count;
125126
};
126127

127128
/*
@@ -170,66 +171,50 @@ struct TSLanguage {
170171

171172
#define ACTIONS(id) id
172173

173-
#define SHIFT(state_value) \
174-
{ \
175-
{ \
176-
.params = { \
177-
.shift = { \
178-
.state = state_value \
179-
} \
180-
}, \
181-
.type = TSParseActionTypeShift \
182-
} \
183-
}
174+
#define SHIFT(state_value) \
175+
{{ \
176+
.shift = { \
177+
.type = TSParseActionTypeShift, \
178+
.state = state_value \
179+
} \
180+
}}
184181

185182
#define SHIFT_REPEAT(state_value) \
186-
{ \
187-
{ \
188-
.params = { \
189-
.shift = { \
190-
.state = state_value, \
191-
.repetition = true \
192-
} \
193-
}, \
194-
.type = TSParseActionTypeShift \
183+
{{ \
184+
.shift = { \
185+
.type = TSParseActionTypeShift, \
186+
.state = state_value, \
187+
.repetition = true \
195188
} \
196-
}
197-
198-
#define RECOVER() \
199-
{ \
200-
{ .type = TSParseActionTypeRecover } \
201-
}
189+
}}
202190

203191
#define SHIFT_EXTRA() \
204-
{ \
205-
{ \
206-
.params = { \
207-
.shift = { \
208-
.extra = true \
209-
} \
210-
}, \
211-
.type = TSParseActionTypeShift \
192+
{{ \
193+
.shift = { \
194+
.type = TSParseActionTypeShift, \
195+
.extra = true \
212196
} \
213-
}
197+
}}
214198

215199
#define REDUCE(symbol_val, child_count_val, ...) \
216-
{ \
217-
{ \
218-
.params = { \
219-
.reduce = { \
220-
.symbol = symbol_val, \
221-
.child_count = child_count_val, \
222-
__VA_ARGS__ \
223-
}, \
224-
}, \
225-
.type = TSParseActionTypeReduce \
226-
} \
227-
}
228-
229-
#define ACCEPT_INPUT() \
230-
{ \
231-
{ .type = TSParseActionTypeAccept } \
232-
}
200+
{{ \
201+
.reduce = { \
202+
.type = TSParseActionTypeReduce, \
203+
.symbol = symbol_val, \
204+
.child_count = child_count_val, \
205+
__VA_ARGS__ \
206+
}, \
207+
}}
208+
209+
#define RECOVER() \
210+
{{ \
211+
.type = TSParseActionTypeRecover \
212+
}}
213+
214+
#define ACCEPT_INPUT() \
215+
{{ \
216+
.type = TSParseActionTypeAccept \
217+
}}
233218

234219
#ifdef __cplusplus
235220
}

0 commit comments

Comments
 (0)