Merge pull request #54 from tree-sitter/ns/ansii-c-quoting

Support ANSII-C quoting in strings prefixed with $
This commit is contained in:
Nathan Sobo 2019-07-26 14:05:17 -06:00 committed by GitHub
commit c710c0d75b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 68696 additions and 68659 deletions

View File

@ -299,6 +299,16 @@ echo "s$"
(command (command_name (word)) (string))
(command (command_name (word)) (string)))
========================================
Strings with ANSI-C quoting
========================================
echo $'Here\'s johnny!\r\n'
---
(program (command (command_name (word)) (ansii_c_string)))
=========================================
Arrays and array expansions
=========================================

View File

@ -396,6 +396,7 @@ module.exports = grammar({
$.word,
$.string,
$.raw_string,
$.ansii_c_string,
$.expansion,
$.simple_expansion,
$.string_expansion,
@ -445,6 +446,8 @@ module.exports = grammar({
raw_string: $ => /'[^']*'/,
ansii_c_string: $ => /\$'([^']|\\')*'/,
simple_expansion: $ => seq(
'$',
choice(

8
src/grammar.json vendored
View File

@ -1626,6 +1626,10 @@
"type": "SYMBOL",
"name": "raw_string"
},
{
"type": "SYMBOL",
"name": "ansii_c_string"
},
{
"type": "SYMBOL",
"name": "expansion"
@ -1866,6 +1870,10 @@
"type": "PATTERN",
"value": "'[^']*'"
},
"ansii_c_string": {
"type": "PATTERN",
"value": "\\$'([^']|\\\\')*'"
},
"simple_expansion": {
"type": "SEQ",
"members": [

2048
src/node-types.json vendored

File diff suppressed because it is too large Load Diff

135492
src/parser.c vendored

File diff suppressed because it is too large Load Diff

View File

@ -122,20 +122,24 @@ struct TSLanguage {
#define START_LEXER() \
bool result = false; \
bool skip = false; \
int32_t lookahead; \
goto start; \
next_state: \
lexer->advance(lexer, skip); \
start: \
skip = false; \
lookahead = lexer->lookahead;
#define ADVANCE(state_value) \
{ \
lexer->advance(lexer, false); \
state = state_value; \
goto next_state; \
}
#define SKIP(state_value) \
{ \
lexer->advance(lexer, true); \
skip = true; \
state = state_value; \
goto next_state; \
}