Skip to content

Commit a2c5c01

Browse files
committed
fix(option): correctly parse unmatched option
Fixes #8
1 parent eb01ab5 commit a2c5c01

File tree

4 files changed

+17
-70
lines changed

4 files changed

+17
-70
lines changed

corpus/code_block.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ To test for a non-empty string, use empty(): >
8383
(word)
8484
(word)
8585
(word)
86-
(word)
8786
(code_block))
8887
(line
8988
(word)

corpus/option.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,19 @@ world 'hello' world
2525
(option
2626
(word))
2727
(word)))
28+
29+
================================================================================
30+
Near-option
31+
================================================================================
32+
33+
Let's see if that works.
34+
35+
--------------------------------------------------------------------------------
36+
37+
(help_file
38+
(line
39+
(word)
40+
(word)
41+
(word)
42+
(word)
43+
(word)))

src/parser.c

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -288,74 +288,6 @@ static const uint16_t ts_non_terminal_alias_map[] = {
288288
0,
289289
};
290290

291-
static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
292-
[0] = 0,
293-
[1] = 1,
294-
[2] = 2,
295-
[3] = 3,
296-
[4] = 4,
297-
[5] = 5,
298-
[6] = 4,
299-
[7] = 7,
300-
[8] = 8,
301-
[9] = 9,
302-
[10] = 10,
303-
[11] = 11,
304-
[12] = 12,
305-
[13] = 13,
306-
[14] = 14,
307-
[15] = 15,
308-
[16] = 16,
309-
[17] = 17,
310-
[18] = 18,
311-
[19] = 19,
312-
[20] = 20,
313-
[21] = 20,
314-
[22] = 20,
315-
[23] = 9,
316-
[24] = 10,
317-
[25] = 13,
318-
[26] = 18,
319-
[27] = 17,
320-
[28] = 28,
321-
[29] = 10,
322-
[30] = 30,
323-
[31] = 31,
324-
[32] = 32,
325-
[33] = 33,
326-
[34] = 31,
327-
[35] = 35,
328-
[36] = 13,
329-
[37] = 18,
330-
[38] = 9,
331-
[39] = 17,
332-
[40] = 40,
333-
[41] = 41,
334-
[42] = 42,
335-
[43] = 43,
336-
[44] = 44,
337-
[45] = 30,
338-
[46] = 35,
339-
[47] = 47,
340-
[48] = 33,
341-
[49] = 32,
342-
[50] = 30,
343-
[51] = 35,
344-
[52] = 31,
345-
[53] = 33,
346-
[54] = 32,
347-
[55] = 55,
348-
[56] = 55,
349-
[57] = 44,
350-
[58] = 43,
351-
[59] = 42,
352-
[60] = 60,
353-
[61] = 55,
354-
[62] = 44,
355-
[63] = 43,
356-
[64] = 42,
357-
};
358-
359291
static bool ts_lex(TSLexer *lexer, TSStateId state) {
360292
START_LEXER();
361293
eof = lexer->eof(lexer);

src/scanner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool tree_sitter_help_external_scanner_scan(void *payload, TSLexer *lexer,
6666
bool all_uppercase = true;
6767

6868
// Now consume a word, without the ending ~ if any
69-
while (iswalpha(lexer->lookahead) && lexer->lookahead != '\0' &&
69+
while (!iswspace(lexer->lookahead) && lexer->lookahead != '\0' &&
7070
lexer->lookahead != '~') {
7171
if (all_uppercase && iswlower(lexer->lookahead)) {
7272
all_uppercase = false;

0 commit comments

Comments
 (0)