Fix bug regarding dollar sign but not variable reference
This commit is contained in:
parent
87795ad552
commit
5020572408
|
@ -156,3 +156,21 @@ message("${var_${var}} #comment")
|
|||
)
|
||||
)
|
||||
)
|
||||
|
||||
===========================================================
|
||||
Lookalike variable inside quoted argument [quoted_argument]
|
||||
===========================================================
|
||||
|
||||
message("$var")
|
||||
|
||||
---
|
||||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(argument
|
||||
(quoted_argument
|
||||
(quoted_element)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -102,3 +102,18 @@ message(${var_${var_ref}})
|
|||
)
|
||||
)
|
||||
|
||||
===============================================================
|
||||
Lookalike variable inside unquoted argument [unquoted_argument]
|
||||
===============================================================
|
||||
|
||||
message($var)
|
||||
|
||||
---
|
||||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(argument
|
||||
(unquoted_argument)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -42,9 +42,11 @@ module.exports = grammar({
|
|||
_paren_argument: ($) => seq("(", repeat($._untrimmed_argument), ")"),
|
||||
|
||||
quoted_argument: ($) => seq('"', optional($.quoted_element), '"'),
|
||||
quoted_element: ($) => repeat1(choice($.variable_ref, $.gen_exp, /[^\\"]/, $.escape_sequence)),
|
||||
quoted_element: ($) => repeat1(choice($.variable_ref, $.gen_exp, $._quoted_text, $.escape_sequence)),
|
||||
_quoted_text: ($) => prec.left(repeat1(choice('$', /[^\\"]/))),
|
||||
|
||||
unquoted_argument: ($) => prec.right(repeat1(choice($.variable_ref, $.gen_exp, /[^\s()#\"\\]/, $.escape_sequence))),
|
||||
unquoted_argument: ($) => prec.right(repeat1(choice($.variable_ref, $.gen_exp, $._unquoted_text, $.escape_sequence))),
|
||||
_unquoted_text: ($) => prec.left(repeat1(choice('$', /[^()#"\\']/))),
|
||||
|
||||
if_command: ($) => command($.if, repeat($._untrimmed_argument)),
|
||||
elseif_command: ($) => command($.elseif, repeat($._untrimmed_argument)),
|
||||
|
|
|
@ -346,8 +346,8 @@
|
|||
"name": "gen_exp"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\\\\"]"
|
||||
"type": "SYMBOL",
|
||||
"name": "_quoted_text"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -356,6 +356,26 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"_quoted_text": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "$"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\\\\"]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"unquoted_argument": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
|
@ -373,8 +393,8 @@
|
|||
"name": "gen_exp"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\s()#\\\"\\\\]"
|
||||
"type": "SYMBOL",
|
||||
"name": "_unquoted_text"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -384,6 +404,26 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"_unquoted_text": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"content": {
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "$"
|
||||
},
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^()#\"\\\\']"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"if_command": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
|
29322
src/parser.c
29322
src/parser.c
File diff suppressed because it is too large
Load diff
|
@ -123,6 +123,7 @@ struct TSLanguage {
|
|||
unsigned (*serialize)(void *, char *);
|
||||
void (*deserialize)(void *, const char *, unsigned);
|
||||
} external_scanner;
|
||||
const TSStateId *primary_state_ids;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue