Skip to content

Commit 7147b26

Browse files
authored
Update ccomment grammar (#988)
1 parent 675bc59 commit 7147b26

File tree

6 files changed

+43
-26
lines changed

6 files changed

+43
-26
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tree-sitter-javascript = "=0.20.0"
3434
tree-sitter-python = "=0.20.2"
3535
tree-sitter-rust = "=0.20.3"
3636
tree-sitter-preproc = { path = "./tree-sitter-preproc", version = "=0.20.1" }
37-
tree-sitter-ccomment = { path = "./tree-sitter-ccomment", version = "=0.20.0" }
37+
tree-sitter-ccomment = { path = "./tree-sitter-ccomment", version = "=0.20.1" }
3838
tree-sitter-mozcpp = { path = "./tree-sitter-mozcpp", version = "=0.20.2" }
3939
tree-sitter-mozjs = { path = "./tree-sitter-mozjs", version = "=0.20.1" }
4040

enums/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tree-sitter-javascript = "=0.20.0"
1515
tree-sitter-python = "=0.20.2"
1616
tree-sitter-rust = "=0.20.3"
1717
tree-sitter-preproc = { path = "../tree-sitter-preproc", version = "=0.20.1" }
18-
tree-sitter-ccomment = { path = "../tree-sitter-ccomment", version = "=0.20.0" }
18+
tree-sitter-ccomment = { path = "../tree-sitter-ccomment", version = "=0.20.1" }
1919
tree-sitter-mozcpp = { path = "../tree-sitter-mozcpp", version = "=0.20.2" }
2020
tree-sitter-mozjs = { path = "../tree-sitter-mozjs", version = "=0.20.1" }
2121

tree-sitter-ccomment/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tree-sitter-ccomment"
33
description = "Ccomment grammar for the tree-sitter parsing library"
4-
version = "0.20.0"
4+
version = "0.20.1"
55
authors = ["Calixte Denizet <cdenizet@mozilla.com>"]
66
license = "MIT"
77
readme = "bindings/rust/README.md"
@@ -21,7 +21,7 @@ include = [
2121
path = "bindings/rust/lib.rs"
2222

2323
[dependencies]
24-
tree-sitter = "0.20.0"
24+
tree-sitter = "0.20.9"
2525

2626
[build-dependencies]
2727
cc = "^1.0"

tree-sitter-ccomment/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tree-sitter-ccomment",
3-
"version": "0.19.0",
3+
"version": "0.20.0",
44
"description": "Ccomment grammar for node-tree-sitter",
55
"main": "bindings/node",
66
"keywords": [
@@ -13,7 +13,7 @@
1313
"nan": "^2.14.2"
1414
},
1515
"devDependencies": {
16-
"tree-sitter-cli": "^0.19.3"
16+
"tree-sitter-cli": "^0.20.7"
1717
},
1818
"scripts": {
1919
"build": "tree-sitter generate && node-gyp build",

tree-sitter-ccomment/src/parser.c

Lines changed: 34 additions & 18 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 13
8+
#define LANGUAGE_VERSION 14
99
#define STATE_COUNT 12
1010
#define LARGE_STATE_COUNT 4
1111
#define SYMBOL_COUNT 16
@@ -34,7 +34,7 @@ enum {
3434
aux_sym_define_repeat1 = 15,
3535
};
3636

37-
static const char *ts_symbol_names[] = {
37+
static const char * const ts_symbol_names[] = {
3838
[ts_builtin_sym_end] = "end",
3939
[sym_nothing] = "nothing",
4040
[sym_preproc_continuation_line] = "preproc_continuation_line",
@@ -53,7 +53,7 @@ static const char *ts_symbol_names[] = {
5353
[aux_sym_define_repeat1] = "define_repeat1",
5454
};
5555

56-
static TSSymbol ts_symbol_map[] = {
56+
static const TSSymbol ts_symbol_map[] = {
5757
[ts_builtin_sym_end] = ts_builtin_sym_end,
5858
[sym_nothing] = sym_nothing,
5959
[sym_preproc_continuation_line] = sym_preproc_continuation_line,
@@ -139,14 +139,29 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
139139
},
140140
};
141141

142-
static TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
142+
static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
143143
[0] = {0},
144144
};
145145

146-
static uint16_t ts_non_terminal_alias_map[] = {
146+
static const uint16_t ts_non_terminal_alias_map[] = {
147147
0,
148148
};
149149

150+
static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
151+
[0] = 0,
152+
[1] = 1,
153+
[2] = 2,
154+
[3] = 3,
155+
[4] = 4,
156+
[5] = 5,
157+
[6] = 6,
158+
[7] = 7,
159+
[8] = 8,
160+
[9] = 9,
161+
[10] = 10,
162+
[11] = 11,
163+
};
164+
150165
static bool ts_lex(TSLexer *lexer, TSStateId state) {
151166
START_LEXER();
152167
eof = lexer->eof(lexer);
@@ -326,7 +341,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
326341
}
327342
}
328343

329-
static TSLexMode ts_lex_modes[STATE_COUNT] = {
344+
static const TSLexMode ts_lex_modes[STATE_COUNT] = {
330345
[0] = {.lex_state = 0, .external_lex_state = 1},
331346
[1] = {.lex_state = 0, .external_lex_state = 1},
332347
[2] = {.lex_state = 0, .external_lex_state = 1},
@@ -345,17 +360,17 @@ enum {
345360
ts_external_token_raw_string_literal = 0,
346361
};
347362

348-
static TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
363+
static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
349364
[ts_external_token_raw_string_literal] = sym_raw_string_literal,
350365
};
351366

352-
static bool ts_external_scanner_states[2][EXTERNAL_TOKEN_COUNT] = {
367+
static const bool ts_external_scanner_states[2][EXTERNAL_TOKEN_COUNT] = {
353368
[1] = {
354369
[ts_external_token_raw_string_literal] = true,
355370
},
356371
};
357372

358-
static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
373+
static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
359374
[0] = {
360375
[ts_builtin_sym_end] = ACTIONS(1),
361376
[sym_nothing] = ACTIONS(1),
@@ -410,7 +425,7 @@ static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
410425
},
411426
};
412427

413-
static uint16_t ts_small_parse_table[] = {
428+
static const uint16_t ts_small_parse_table[] = {
414429
[0] = 2,
415430
ACTIONS(38), 2,
416431
sym_raw_string_literal,
@@ -477,7 +492,7 @@ static uint16_t ts_small_parse_table[] = {
477492
ts_builtin_sym_end,
478493
};
479494

480-
static uint32_t ts_small_parse_table_map[] = {
495+
static const uint32_t ts_small_parse_table_map[] = {
481496
[SMALL_STATE(4)] = 0,
482497
[SMALL_STATE(5)] = 12,
483498
[SMALL_STATE(6)] = 24,
@@ -488,7 +503,7 @@ static uint32_t ts_small_parse_table_map[] = {
488503
[SMALL_STATE(11)] = 78,
489504
};
490505

491-
static TSParseActionEntry ts_parse_actions[] = {
506+
static const TSParseActionEntry ts_parse_actions[] = {
492507
[0] = {.entry = {.count = 0, .reusable = false}},
493508
[1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),
494509
[3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_translation_unit, 0),
@@ -537,7 +552,7 @@ void tree_sitter_ccomment_external_scanner_deserialize(void *, const char *, uns
537552
#endif
538553

539554
extern const TSLanguage *tree_sitter_ccomment(void) {
540-
static TSLanguage language = {
555+
static const TSLanguage language = {
541556
.version = LANGUAGE_VERSION,
542557
.symbol_count = SYMBOL_COUNT,
543558
.alias_count = ALIAS_COUNT,
@@ -548,26 +563,27 @@ extern const TSLanguage *tree_sitter_ccomment(void) {
548563
.production_id_count = PRODUCTION_ID_COUNT,
549564
.field_count = FIELD_COUNT,
550565
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
551-
.parse_table = (const uint16_t *)ts_parse_table,
552-
.small_parse_table = (const uint16_t *)ts_small_parse_table,
553-
.small_parse_table_map = (const uint32_t *)ts_small_parse_table_map,
566+
.parse_table = &ts_parse_table[0][0],
567+
.small_parse_table = ts_small_parse_table,
568+
.small_parse_table_map = ts_small_parse_table_map,
554569
.parse_actions = ts_parse_actions,
555570
.symbol_names = ts_symbol_names,
556571
.symbol_metadata = ts_symbol_metadata,
557572
.public_symbol_map = ts_symbol_map,
558573
.alias_map = ts_non_terminal_alias_map,
559-
.alias_sequences = (const TSSymbol *)ts_alias_sequences,
574+
.alias_sequences = &ts_alias_sequences[0][0],
560575
.lex_modes = ts_lex_modes,
561576
.lex_fn = ts_lex,
562577
.external_scanner = {
563-
(const bool *)ts_external_scanner_states,
578+
&ts_external_scanner_states[0][0],
564579
ts_external_scanner_symbol_map,
565580
tree_sitter_ccomment_external_scanner_create,
566581
tree_sitter_ccomment_external_scanner_destroy,
567582
tree_sitter_ccomment_external_scanner_scan,
568583
tree_sitter_ccomment_external_scanner_serialize,
569584
tree_sitter_ccomment_external_scanner_deserialize,
570585
},
586+
.primary_state_ids = ts_primary_state_ids,
571587
};
572588
return &language;
573589
}

tree-sitter-ccomment/src/tree_sitter/parser.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ struct TSLanguage {
102102
const uint16_t *small_parse_table;
103103
const uint32_t *small_parse_table_map;
104104
const TSParseActionEntry *parse_actions;
105-
const char **symbol_names;
106-
const char **field_names;
105+
const char * const *symbol_names;
106+
const char * const *field_names;
107107
const TSFieldMapSlice *field_map_slices;
108108
const TSFieldMapEntry *field_map_entries;
109109
const TSSymbolMetadata *symbol_metadata;
@@ -123,6 +123,7 @@ struct TSLanguage {
123123
unsigned (*serialize)(void *, char *);
124124
void (*deserialize)(void *, const char *, unsigned);
125125
} external_scanner;
126+
const TSStateId *primary_state_ids;
126127
};
127128

128129
/*

0 commit comments

Comments
 (0)