Skip to content

Commit 28d3b2e

Browse files
committed
Fixed copy/paste related typo
1 parent ef018fe commit 28d3b2e

File tree

3 files changed

+92
-67
lines changed

3 files changed

+92
-67
lines changed

.github/ISSUE_TEMPLATE/bug-report---parsing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A clear and concise description of what the bug is.
1515
Given this Objdump file
1616

1717
<!-- Insert a Objdump file here or link to a GitHub gist example -->
18-
`tree-sitter parse /the/file.usda`
18+
`tree-sitter parse /the/file.objdump`
1919

2020
### Expected Parse
2121
<!-- Insert the text output that you expected here -->

src/parser.c

Lines changed: 85 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "tree_sitter/parser.h"
1+
#include <tree_sitter/parser.h>
22

33
#if defined(__GNUC__) || defined(__clang__)
44
#pragma GCC diagnostic push
@@ -16,7 +16,7 @@
1616
#define MAX_ALIAS_SEQUENCE_LENGTH 5
1717
#define PRODUCTION_ID_COUNT 2
1818

19-
enum ts_symbol_identifiers {
19+
enum {
2020
anon_sym_COLON = 1,
2121
anon_sym_file = 2,
2222
anon_sym_format = 3,
@@ -33,7 +33,7 @@ enum ts_symbol_identifiers {
3333
anon_sym_GT = 14,
3434
sym_hexadecimal = 15,
3535
sym_byte = 16,
36-
anon_sym_SPACE = 17,
36+
anon_sym_ = 17,
3737
sym_address = 18,
3838
anon_sym_File = 19,
3939
anon_sym_Offset_COLON = 20,
@@ -87,7 +87,7 @@ static const char * const ts_symbol_names[] = {
8787
[anon_sym_GT] = ">",
8888
[sym_hexadecimal] = "hexadecimal",
8989
[sym_byte] = "byte",
90-
[anon_sym_SPACE] = " ",
90+
[anon_sym_] = " ",
9191
[sym_address] = "address",
9292
[anon_sym_File] = "File",
9393
[anon_sym_Offset_COLON] = "Offset:",
@@ -141,7 +141,7 @@ static const TSSymbol ts_symbol_map[] = {
141141
[anon_sym_GT] = anon_sym_GT,
142142
[sym_hexadecimal] = sym_hexadecimal,
143143
[sym_byte] = sym_byte,
144-
[anon_sym_SPACE] = anon_sym_SPACE,
144+
[anon_sym_] = anon_sym_,
145145
[sym_address] = sym_address,
146146
[anon_sym_File] = anon_sym_File,
147147
[anon_sym_Offset_COLON] = anon_sym_Offset_COLON,
@@ -246,7 +246,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
246246
.visible = true,
247247
.named = true,
248248
},
249-
[anon_sym_SPACE] = {
249+
[anon_sym_] = {
250250
.visible = true,
251251
.named = false,
252252
},
@@ -463,6 +463,7 @@ static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
463463

464464
static bool ts_lex(TSLexer *lexer, TSStateId state) {
465465
START_LEXER();
466+
eof = lexer->eof(lexer);
466467
switch (state) {
467468
case 0:
468469
if (eof) ADVANCE(66);
@@ -478,24 +479,28 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
478479
if (lookahead == 'O') ADVANCE(25);
479480
if (lookahead == 'd') ADVANCE(96);
480481
if (lookahead == 'f') ADVANCE(97);
481-
if (('\t' <= lookahead && lookahead <= '\r') ||
482-
lookahead == ' ') SKIP(0);
482+
if (lookahead == '\t' ||
483+
lookahead == '\n' ||
484+
lookahead == '\r' ||
485+
lookahead == ' ') SKIP(0)
483486
if (('A' <= lookahead && lookahead <= 'E') ||
484487
('a' <= lookahead && lookahead <= 'e')) ADVANCE(101);
485488
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(100);
486489
END_STATE();
487490
case 1:
488-
if (lookahead == '\n') SKIP(1);
491+
if (lookahead == '\n') SKIP(1)
489492
if (lookahead == '(') ADVANCE(80);
490-
if (('\t' <= lookahead && lookahead <= '\r') ||
493+
if (lookahead == '\t' ||
494+
lookahead == '\r' ||
491495
lookahead == ' ') ADVANCE(77);
492496
if (lookahead != 0 &&
493497
lookahead != '#' &&
494498
lookahead != '<') ADVANCE(82);
495499
END_STATE();
496500
case 2:
497-
if (lookahead == '\n') SKIP(2);
498-
if (('\t' <= lookahead && lookahead <= '\r') ||
501+
if (lookahead == '\n') SKIP(2)
502+
if (lookahead == '\t' ||
503+
lookahead == '\r' ||
499504
lookahead == ' ') ADVANCE(120);
500505
if (lookahead != 0) ADVANCE(121);
501506
END_STATE();
@@ -513,8 +518,10 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
513518
END_STATE();
514519
case 7:
515520
if (lookahead == '0') ADVANCE(98);
516-
if (('\t' <= lookahead && lookahead <= '\r') ||
517-
lookahead == ' ') SKIP(7);
521+
if (lookahead == '\t' ||
522+
lookahead == '\n' ||
523+
lookahead == '\r' ||
524+
lookahead == ' ') SKIP(7)
518525
if (('1' <= lookahead && lookahead <= '9') ||
519526
('A' <= lookahead && lookahead <= 'F') ||
520527
('a' <= lookahead && lookahead <= 'f')) ADVANCE(101);
@@ -526,8 +533,10 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
526533
if (lookahead == '+' ||
527534
lookahead == '-' ||
528535
lookahead == '/') ADVANCE(118);
529-
if (('\t' <= lookahead && lookahead <= '\r') ||
530-
lookahead == ' ') SKIP(8);
536+
if (lookahead == '\t' ||
537+
lookahead == '\n' ||
538+
lookahead == '\r' ||
539+
lookahead == ' ') SKIP(8)
531540
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(102);
532541
if (('A' <= lookahead && lookahead <= 'F') ||
533542
('a' <= lookahead && lookahead <= 'f')) ADVANCE(99);
@@ -548,8 +557,10 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
548557
if (lookahead == 'F') ADVANCE(29);
549558
if (lookahead == 'd') ADVANCE(31);
550559
if (lookahead == 'f') ADVANCE(43);
551-
if (('\t' <= lookahead && lookahead <= '\r') ||
552-
lookahead == ' ') SKIP(11);
560+
if (lookahead == '\t' ||
561+
lookahead == '\n' ||
562+
lookahead == '\r' ||
563+
lookahead == ' ') SKIP(11)
553564
if (('0' <= lookahead && lookahead <= '9') ||
554565
('A' <= lookahead && lookahead <= 'E') ||
555566
('a' <= lookahead && lookahead <= 'e')) ADVANCE(63);
@@ -604,8 +615,10 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
604615
END_STATE();
605616
case 28:
606617
if (lookahead == 'f') ADVANCE(34);
607-
if (('\t' <= lookahead && lookahead <= '\r') ||
608-
lookahead == ' ') SKIP(28);
618+
if (lookahead == '\t' ||
619+
lookahead == '\n' ||
620+
lookahead == '\r' ||
621+
lookahead == ' ') SKIP(28)
609622
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(106);
610623
END_STATE();
611624
case 29:
@@ -714,7 +727,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
714727
if (lookahead == 'y') ADVANCE(4);
715728
END_STATE();
716729
case 61:
717-
if (('\t' <= lookahead && lookahead <= '\r') ||
730+
if (lookahead == '\t' ||
731+
lookahead == '\n' ||
732+
lookahead == '\r' ||
718733
lookahead == ' ') ADVANCE(122);
719734
if (lookahead != 0 &&
720735
lookahead != ':') ADVANCE(123);
@@ -744,8 +759,10 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
744759
if (lookahead == '+' ||
745760
lookahead == '-' ||
746761
lookahead == '/') ADVANCE(118);
747-
if (('\t' <= lookahead && lookahead <= '\r') ||
748-
lookahead == ' ') SKIP(65);
762+
if (lookahead == '\t' ||
763+
lookahead == '\n' ||
764+
lookahead == '\r' ||
765+
lookahead == ' ') SKIP(65)
749766
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(102);
750767
if (('A' <= lookahead && lookahead <= 'F') ||
751768
('a' <= lookahead && lookahead <= 'f')) ADVANCE(99);
@@ -788,18 +805,22 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
788805
case 75:
789806
ACCEPT_TOKEN(aux_sym_memory_offset_token1);
790807
if (lookahead == ' ') ADVANCE(92);
791-
if (('\t' <= lookahead && lookahead <= '\r')) ADVANCE(75);
808+
if (lookahead == '\t' ||
809+
lookahead == '\n' ||
810+
lookahead == '\r') ADVANCE(75);
792811
END_STATE();
793812
case 76:
794813
ACCEPT_TOKEN(aux_sym_memory_offset_token1);
795-
if (('\t' <= lookahead && lookahead <= '\r') ||
814+
if (lookahead == '\t' ||
815+
lookahead == '\n' ||
816+
lookahead == '\r' ||
796817
lookahead == ' ') ADVANCE(76);
797818
END_STATE();
798819
case 77:
799820
ACCEPT_TOKEN(sym_instruction);
800821
if (lookahead == '(') ADVANCE(80);
801822
if (lookahead == '\t' ||
802-
(11 <= lookahead && lookahead <= '\r') ||
823+
lookahead == '\r' ||
803824
lookahead == ' ') ADVANCE(77);
804825
if (lookahead != 0 &&
805826
lookahead != '\n' &&
@@ -882,9 +903,11 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
882903
ACCEPT_TOKEN(sym_byte);
883904
END_STATE();
884905
case 92:
885-
ACCEPT_TOKEN(anon_sym_SPACE);
906+
ACCEPT_TOKEN(anon_sym_);
886907
if (lookahead == ' ') ADVANCE(92);
887-
if (('\t' <= lookahead && lookahead <= '\r')) ADVANCE(75);
908+
if (lookahead == '\t' ||
909+
lookahead == '\n' ||
910+
lookahead == '\r') ADVANCE(75);
888911
END_STATE();
889912
case 93:
890913
ACCEPT_TOKEN(sym_address);
@@ -1152,7 +1175,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
11521175
case 120:
11531176
ACCEPT_TOKEN(sym_identifier);
11541177
if (lookahead == '\t' ||
1155-
(11 <= lookahead && lookahead <= '\r') ||
1178+
lookahead == '\r' ||
11561179
lookahead == ' ') ADVANCE(120);
11571180
if (lookahead != 0 &&
11581181
lookahead != '\n') ADVANCE(121);
@@ -1164,7 +1187,9 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
11641187
END_STATE();
11651188
case 122:
11661189
ACCEPT_TOKEN(sym__section_name);
1167-
if (('\t' <= lookahead && lookahead <= '\r') ||
1190+
if (lookahead == '\t' ||
1191+
lookahead == '\n' ||
1192+
lookahead == '\r' ||
11681193
lookahead == ' ') ADVANCE(122);
11691194
if (lookahead != 0 &&
11701195
lookahead != ':') ADVANCE(123);
@@ -1245,6 +1270,32 @@ static const TSLexMode ts_lex_modes[STATE_COUNT] = {
12451270
[62] = {.lex_state = 61},
12461271
};
12471272

1273+
enum {
1274+
ts_external_token_code_identifier = 0,
1275+
ts_external_token__whitespace_no_newline = 1,
1276+
ts_external_token__error_sentinel = 2,
1277+
};
1278+
1279+
static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
1280+
[ts_external_token_code_identifier] = sym_code_identifier,
1281+
[ts_external_token__whitespace_no_newline] = sym__whitespace_no_newline,
1282+
[ts_external_token__error_sentinel] = sym__error_sentinel,
1283+
};
1284+
1285+
static const bool ts_external_scanner_states[4][EXTERNAL_TOKEN_COUNT] = {
1286+
[1] = {
1287+
[ts_external_token_code_identifier] = true,
1288+
[ts_external_token__whitespace_no_newline] = true,
1289+
[ts_external_token__error_sentinel] = true,
1290+
},
1291+
[2] = {
1292+
[ts_external_token__whitespace_no_newline] = true,
1293+
},
1294+
[3] = {
1295+
[ts_external_token_code_identifier] = true,
1296+
},
1297+
};
1298+
12481299
static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
12491300
[0] = {
12501301
[ts_builtin_sym_end] = ACTIONS(1),
@@ -1588,7 +1639,7 @@ static const uint16_t ts_small_parse_table[] = {
15881639
ACTIONS(150), 1,
15891640
aux_sym_memory_offset_token1,
15901641
ACTIONS(152), 1,
1591-
anon_sym_SPACE,
1642+
anon_sym_,
15921643
ACTIONS(155), 1,
15931644
sym__whitespace_no_newline,
15941645
STATE(29), 1,
@@ -1597,14 +1648,14 @@ static const uint16_t ts_small_parse_table[] = {
15971648
ACTIONS(157), 1,
15981649
aux_sym_memory_offset_token1,
15991650
ACTIONS(159), 1,
1600-
anon_sym_SPACE,
1651+
anon_sym_,
16011652
ACTIONS(161), 1,
16021653
sym__whitespace_no_newline,
16031654
STATE(31), 1,
16041655
aux_sym_machine_code_bytes_repeat1,
16051656
[410] = 4,
16061657
ACTIONS(159), 1,
1607-
anon_sym_SPACE,
1658+
anon_sym_,
16081659
ACTIONS(163), 1,
16091660
aux_sym_memory_offset_token1,
16101661
ACTIONS(165), 1,
@@ -1631,7 +1682,7 @@ static const uint16_t ts_small_parse_table[] = {
16311682
sym__whitespace_no_newline,
16321683
ACTIONS(150), 2,
16331684
aux_sym_memory_offset_token1,
1634-
anon_sym_SPACE,
1685+
anon_sym_,
16351686
[452] = 2,
16361687
ACTIONS(173), 1,
16371688
anon_sym_PLUS,
@@ -1906,32 +1957,6 @@ static const TSParseActionEntry ts_parse_actions[] = {
19061957
[229] = {.entry = {.count = 1, .reusable = true}}, SHIFT(54),
19071958
};
19081959

1909-
enum ts_external_scanner_symbol_identifiers {
1910-
ts_external_token_code_identifier = 0,
1911-
ts_external_token__whitespace_no_newline = 1,
1912-
ts_external_token__error_sentinel = 2,
1913-
};
1914-
1915-
static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
1916-
[ts_external_token_code_identifier] = sym_code_identifier,
1917-
[ts_external_token__whitespace_no_newline] = sym__whitespace_no_newline,
1918-
[ts_external_token__error_sentinel] = sym__error_sentinel,
1919-
};
1920-
1921-
static const bool ts_external_scanner_states[4][EXTERNAL_TOKEN_COUNT] = {
1922-
[1] = {
1923-
[ts_external_token_code_identifier] = true,
1924-
[ts_external_token__whitespace_no_newline] = true,
1925-
[ts_external_token__error_sentinel] = true,
1926-
},
1927-
[2] = {
1928-
[ts_external_token__whitespace_no_newline] = true,
1929-
},
1930-
[3] = {
1931-
[ts_external_token_code_identifier] = true,
1932-
},
1933-
};
1934-
19351960
#ifdef __cplusplus
19361961
extern "C" {
19371962
#endif

src/tree_sitter/parser.h

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

16-
#ifndef TREE_SITTER_API_H_
1716
typedef uint16_t TSStateId;
17+
18+
#ifndef TREE_SITTER_API_H_
1819
typedef uint16_t TSSymbol;
1920
typedef uint16_t TSFieldId;
2021
typedef struct TSLanguage TSLanguage;
@@ -139,8 +140,7 @@ struct TSLanguage {
139140
lexer->advance(lexer, skip); \
140141
start: \
141142
skip = false; \
142-
lookahead = lexer->lookahead; \
143-
eof = lexer->eof(lexer);
143+
lookahead = lexer->lookahead;
144144

145145
#define ADVANCE(state_value) \
146146
{ \
@@ -166,7 +166,7 @@ struct TSLanguage {
166166
* Parse Table Macros
167167
*/
168168

169-
#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)
169+
#define SMALL_STATE(id) id - LARGE_STATE_COUNT
170170

171171
#define STATE(id) id
172172

@@ -176,15 +176,15 @@ struct TSLanguage {
176176
{{ \
177177
.shift = { \
178178
.type = TSParseActionTypeShift, \
179-
.state = (state_value) \
179+
.state = state_value \
180180
} \
181181
}}
182182

183183
#define SHIFT_REPEAT(state_value) \
184184
{{ \
185185
.shift = { \
186186
.type = TSParseActionTypeShift, \
187-
.state = (state_value), \
187+
.state = state_value, \
188188
.repetition = true \
189189
} \
190190
}}

0 commit comments

Comments
 (0)