Skip to content

Commit

Permalink
Merge pull request #11 from nickel-lang/10-segmentation-fault-parsing…
Browse files Browse the repository at this point in the history
…-let

Resolve segmentation fault parsing "let %"
  • Loading branch information
ErinvanderVeen committed Jul 6, 2022
2 parents 9a502ea + 206c0f8 commit 9d83db4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions corpus/errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
================================================================================
issue 10
================================================================================

let %

--------------------------------------------------------------------------------

(ERROR)
12 changes: 11 additions & 1 deletion src/scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ struct Scanner {
}

bool scan(TSLexer *lexer, const bool *valid_symbols) {
// During error recovery we don't run the external scanner. This produces
// less accurate results, but avoids a large deal of complexity in this
// scanner.
if (valid_symbols[MULTSTR_START] && valid_symbols[MULTSTR_END] &&
valid_symbols[STR_START] && valid_symbols[STR_END] &&
valid_symbols[INTERPOLATION_START] &&
valid_symbols[INTERPOLATION_END] && valid_symbols[COMMENT]) {
return false;
}

// Skip over all whitespace
while (iswspace(lookahead(lexer))) {
skip(lexer);
Expand Down Expand Up @@ -268,7 +278,7 @@ void tree_sitter_nickel_external_scanner_deserialize(void *payload,
const char *buffer,
unsigned length) {
Scanner *scanner = static_cast<Scanner *>(payload);
uint8_t length_uint8 = (uint8_t) length;
uint8_t length_uint8 = (uint8_t)length;
scanner->deserialize(buffer, length_uint8);
}

Expand Down

0 comments on commit 9d83db4

Please sign in to comment.