Skip to content

Commit

Permalink
Fix warnings when generating, escape more chars when debug printing
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodywasishere committed Dec 8, 2024
1 parent 732abb0 commit f8235b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
6 changes: 3 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ module.exports = grammar({
},

string_escape_sequence: $ => {
const octal_escape = seq(/[0-7]{1,3}/)
const octal_escape = /[0-7]{1,3}/
const hex_escape = seq('x', /[0-9a-fA-F]{2}/)

const long_unicode_character = /[0-9a-fA-F]{1,6}/
Expand Down Expand Up @@ -730,13 +730,13 @@ module.exports = grammar({

regex_escape_sequence: $ => {
// These are PCRE escape sequences
const octal_escape = seq(/[0-7]{1,3}/)
const octal_escape = /[0-7]{1,3}/
const long_octal_escape = seq('o{', repeat1(/[0-7]/), '}')

const hex_escape = seq('x', /[0-9a-fA-F]{1,2}/)
const long_hex_escape = seq('x{', repeat1(/[0-9a-fA-F]/), '}')

const ctrl_escape = seq(/c[\x01-\x7f]/) // eslint-disable-line no-control-regex
const ctrl_escape = /c[\x01-\x7f]/ // eslint-disable-line no-control-regex

// TODO: handle rest of PCRE escape syntax:
// https://www.pcre.org/original/doc/html/pcresyntax.html
Expand Down
27 changes: 6 additions & 21 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,12 @@ bool tree_sitter_crystal_external_scanner_scan(void *payload, TSLexer *lexer, co
DEBUG("\n ==> starting external scan\n");
if (lexer->lookahead == '\n') {
DEBUG(" ==> char is '\\n'\n");
} else if (lexer->lookahead == '\0') {
DEBUG(" ==> char is '\\0'\n");
} else if (lexer->lookahead == '\r') {
DEBUG(" ==> char is '\\r'\n");
} else if (lexer->lookahead == '\t') {
DEBUG(" ==> char is '\\t'\n");
} else {
DEBUG(" ==> char is '%c'\n", lexer->lookahead);
}
Expand Down

0 comments on commit f8235b0

Please sign in to comment.