Make $.variable
recursive
This commit is contained in:
parent
b8c45d2a2b
commit
12ef0b4cab
|
@ -77,7 +77,7 @@ message("${var}")
|
|||
)
|
||||
|
||||
=========================================
|
||||
Two Variable references [quoted_argument]
|
||||
Two Variable references [quoted_argument]
|
||||
=========================================
|
||||
|
||||
message("${var} ${var}")
|
||||
|
@ -96,3 +96,23 @@ message("${var} ${var}")
|
|||
)
|
||||
)
|
||||
)
|
||||
|
||||
======================================================================
|
||||
Variable reference inside another variable reference [quoted_argument]
|
||||
======================================================================
|
||||
|
||||
message("${var_${var}}")
|
||||
|
||||
---
|
||||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(argument
|
||||
(quoted_argument
|
||||
(quoted_element
|
||||
(variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -85,3 +85,20 @@ message(${var_ref})
|
|||
)
|
||||
)
|
||||
|
||||
====================================================================
|
||||
Variable referencing inside variable referencing [unquoted_argument]
|
||||
====================================================================
|
||||
message(${var_${var_ref}})
|
||||
---
|
||||
|
||||
(source_file
|
||||
(normal_command
|
||||
(identifier)
|
||||
(argument
|
||||
(unquoted_argument
|
||||
(variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = grammar({
|
|||
_escape_encoded: (_) => choice("\\t", "\\r", "\\n"),
|
||||
_escape_semicolon: (_) => ";",
|
||||
|
||||
variable: ($) => prec.left(repeat1(choice(/[a-zA-Z0-9/_.+-]/, $.escape_sequence))),
|
||||
variable: ($) => prec.left(repeat1(choice(/[a-zA-Z0-9/_.+-]/, $.escape_sequence, $.variable_ref))),
|
||||
variable_ref: ($) => choice($.normal_var, $.env_var, $.cache_var),
|
||||
normal_var: ($) => seq("${", $.variable, "}"),
|
||||
env_var: ($) => seq("$ENV", "{", $.variable, "}"),
|
||||
|
|
|
@ -65,6 +65,10 @@
|
|||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "escape_sequence"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "variable_ref"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -579,6 +579,10 @@
|
|||
{
|
||||
"type": "escape_sequence",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "variable_ref",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
17018
src/parser.c
17018
src/parser.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue