Method: Puppet::Pops::Parser::InterpolationSupport#interpolate_uq
- Defined in:
- lib/puppet/pops/parser/interpolation_support.rb
#interpolate_uq ⇒ Object
This is the starting point for a un-quoted string with possible interpolation The logic is explicit (where the former implementation used parameters/strucures) given to a generic handler. (This is both easier to understand and faster).
| 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | # File 'lib/puppet/pops/parser/interpolation_support.rb', line 106 def interpolate_uq scn = @scanner ctx = @lexing_context before = scn.pos value, terminator = slurp_uqstring() text = value after = scn.pos loop do case terminator when '' # simple case, there was no interpolation, return directly enqueue_completed([:STRING, text, scn.pos - before], before) return when '${' count = ctx[:brace_count] ctx[:brace_count] += 1 # The ${ terminator is counted towards the string part enqueue_completed([:DQPRE, text, scn.pos - before], before) # Lex expression tokens until a closing (balanced) brace count is reached enqueue_until count break when '$' varname = scn.scan(PATTERN_VARIABLE) if varname # The $ is counted towards the variable enqueue_completed([:DQPRE, text, after - before - 1], before) enqueue_completed([:VARIABLE, varname, scn.pos - after + 1], after - 1) break else # false $ variable start text += terminator value, terminator = slurp_uqstring() text += value after = scn.pos end end end interpolate_tail_uq nil end |