Skip to main content

parse_var_ref

Function parse_var_ref 

Source
pub fn parse_var_ref(source: &str) -> Result<Vec<String>, LexerError>
Expand description

Parse a variable reference, extracting the path segments. Input: "${VAR.field[0].nested}"["VAR", "field", "[0]", "nested"]

The [...] collector is quote-aware (GH #183): a subscript opening with " or ' consumes verbatim up to its OWN matching closing quote before resuming the search for the subscript’s terminating ] — so an embedded ] inside a quoted key (${r["weird]key"]}) is just data, not the bracket’s end. Un-quoted subscripts ([0], [$k], [web]) are unaffected — the quote check only fires when the subscript’s first character is actually a quote.