Support ANSII-C quoting in strings prefixed with $
See https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html for details
This commit is contained in:
parent
3b15f16973
commit
1c48cd1676
|
@ -299,6 +299,16 @@ echo "s$"
|
||||||
(command (command_name (word)) (string))
|
(command (command_name (word)) (string))
|
||||||
(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
|
Arrays and array expansions
|
||||||
=========================================
|
=========================================
|
||||||
|
|
|
@ -396,6 +396,7 @@ module.exports = grammar({
|
||||||
$.word,
|
$.word,
|
||||||
$.string,
|
$.string,
|
||||||
$.raw_string,
|
$.raw_string,
|
||||||
|
$.ansii_c_string,
|
||||||
$.expansion,
|
$.expansion,
|
||||||
$.simple_expansion,
|
$.simple_expansion,
|
||||||
$.string_expansion,
|
$.string_expansion,
|
||||||
|
@ -445,6 +446,8 @@ module.exports = grammar({
|
||||||
|
|
||||||
raw_string: $ => /'[^']*'/,
|
raw_string: $ => /'[^']*'/,
|
||||||
|
|
||||||
|
ansii_c_string: $ => /\$'([^']|\\')*'/,
|
||||||
|
|
||||||
simple_expansion: $ => seq(
|
simple_expansion: $ => seq(
|
||||||
'$',
|
'$',
|
||||||
choice(
|
choice(
|
||||||
|
|
|
@ -1626,6 +1626,10 @@
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "raw_string"
|
"name": "raw_string"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "ansii_c_string"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "expansion"
|
"name": "expansion"
|
||||||
|
@ -1866,6 +1870,10 @@
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "'[^']*'"
|
"value": "'[^']*'"
|
||||||
},
|
},
|
||||||
|
"ansii_c_string": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "\\$'([^']|\\\\')*'"
|
||||||
|
},
|
||||||
"simple_expansion": {
|
"simple_expansion": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -122,20 +122,24 @@ struct TSLanguage {
|
||||||
|
|
||||||
#define START_LEXER() \
|
#define START_LEXER() \
|
||||||
bool result = false; \
|
bool result = false; \
|
||||||
|
bool skip = false; \
|
||||||
int32_t lookahead; \
|
int32_t lookahead; \
|
||||||
|
goto start; \
|
||||||
next_state: \
|
next_state: \
|
||||||
|
lexer->advance(lexer, skip); \
|
||||||
|
start: \
|
||||||
|
skip = false; \
|
||||||
lookahead = lexer->lookahead;
|
lookahead = lexer->lookahead;
|
||||||
|
|
||||||
#define ADVANCE(state_value) \
|
#define ADVANCE(state_value) \
|
||||||
{ \
|
{ \
|
||||||
lexer->advance(lexer, false); \
|
|
||||||
state = state_value; \
|
state = state_value; \
|
||||||
goto next_state; \
|
goto next_state; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SKIP(state_value) \
|
#define SKIP(state_value) \
|
||||||
{ \
|
{ \
|
||||||
lexer->advance(lexer, true); \
|
skip = true; \
|
||||||
state = state_value; \
|
state = state_value; \
|
||||||
goto next_state; \
|
goto next_state; \
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue