|
|
|
|
@ -59,9 +59,9 @@ static void free_stack(Stack *stack) {
|
|
|
|
|
free(stack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void push(Stack *stack, char c, bool triple) {
|
|
|
|
|
static void push(Stack *stack, char chr, bool triple) {
|
|
|
|
|
if (stack->len >= TREE_SITTER_SERIALIZATION_BUFFER_SIZE) exit(1);
|
|
|
|
|
stack->arr[stack->len++] = triple ? (c + 1) : c;
|
|
|
|
|
stack->arr[stack->len++] = (Delimiter)(triple ? (chr + 1) : chr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Delimiter pop(Stack *stack) {
|
|
|
|
|
@ -128,7 +128,6 @@ static bool scan_string_content(TSLexer *lexer, Stack *stack) {
|
|
|
|
|
// otherwise, if this is the start, determine if it is an
|
|
|
|
|
// interpolated identifier.
|
|
|
|
|
// otherwise, it's just string content, so continue
|
|
|
|
|
else {
|
|
|
|
|
advance(lexer);
|
|
|
|
|
if (iswalpha(lexer->lookahead) || lexer->lookahead == '{') {
|
|
|
|
|
// this must be a string interpolation, let's
|
|
|
|
|
@ -139,7 +138,7 @@ static bool scan_string_content(TSLexer *lexer, Stack *stack) {
|
|
|
|
|
mark_end(lexer);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
} else if (lexer->lookahead == '\\') {
|
|
|
|
|
if (lexer->lookahead == '\\') {
|
|
|
|
|
// if we see a \, then this might possibly escape a dollar sign
|
|
|
|
|
// in which case, we need to not defer to the interpolation
|
|
|
|
|
has_content = true;
|
|
|
|
|
@ -192,20 +191,18 @@ static bool scan_string_content(TSLexer *lexer, Stack *stack) {
|
|
|
|
|
}
|
|
|
|
|
pop(stack);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
if (has_content) {
|
|
|
|
|
mark_end(lexer);
|
|
|
|
|
lexer->result_symbol = STRING_CONTENT;
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
pop(stack);
|
|
|
|
|
advance(lexer);
|
|
|
|
|
mark_end(lexer);
|
|
|
|
|
lexer->result_symbol = STRING_END;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
advance(lexer);
|
|
|
|
|
has_content = true;
|
|
|
|
|
}
|
|
|
|
|
@ -262,13 +259,12 @@ static bool scan_whitespace_and_comments(TSLexer *lexer) {
|
|
|
|
|
|
|
|
|
|
if (lexer->lookahead == '/') {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool scan_for_word(TSLexer *lexer, char* word, unsigned len) {
|
|
|
|
|
static bool scan_for_word(TSLexer *lexer, const char* word, unsigned len) {
|
|
|
|
|
skip(lexer);
|
|
|
|
|
for (unsigned i = 0; i < len; i++) {
|
|
|
|
|
if (lexer->lookahead != word[i]) return false;
|
|
|
|
|
|