# File lib/puppet/parser/scope.rb, line 329
329:     def strinterp(string, file = nil, line = nil)
330:         # Most strings won't have variables in them.
331:         ss = StringScanner.new(string)
332:         out = ""
333:         while not ss.eos?
334:             if ss.scan(/^\$\{((\w*::)*\w+|[0-9]+)\}|^\$([0-9])|^\$((\w*::)*\w+)/)
335:                 # If it matches the backslash, then just retun the dollar sign.
336:                 if ss.matched == '\\$'
337:                     out << '$'
338:                 else # look the variable up
339:                     # make sure $0-$9 are lookupable only if ephemeral
340:                     var = ss[1] || ss[3] || ss[4]
341:                     if var and var =~ /^[0-9]+$/ and not ephemeral?(var)
342:                         next
343:                     end
344:                     out << lookupvar(var).to_s || ""
345:                 end
346:             elsif ss.scan(/^\\(.)/)
347:                 # Puppet.debug("Got escape: pos:%d; m:%s" % [ss.pos, ss.matched])
348:                 case ss[1]
349:                 when 'n'
350:                     out << "\n"
351:                 when 't'
352:                     out << "\t"
353:                 when 's'
354:                     out << " "
355:                 when '\\'
356:                     out << '\\'
357:                 when '$'
358:                     out << '$'
359:                 else
360:                     str = "Unrecognised escape sequence '#{ss.matched}'"
361:                     if file
362:                         str += " in file %s" % file
363:                     end
364:                     if line
365:                         str += " at line %s" % line
366:                     end
367:                     Puppet.warning str
368:                     out << ss.matched
369:                 end
370:             elsif ss.scan(/^\$/)
371:                 out << '$'
372:             elsif ss.scan(/^\\\n/) # an escaped carriage return
373:                 next
374:             else
375:                 tmp = ss.scan(/[^\\$]+/)
376:                 # Puppet.debug("Got other: pos:%d; m:%s" % [ss.pos, tmp])
377:                 unless tmp
378:                     error = Puppet::ParseError.new("Could not parse string %s" %
379:                         string.inspect)
380:                     {:file= => file, :line= => line}.each do |m,v|
381:                         error.send(m, v) if v
382:                     end
383:                     raise error
384:                 end
385:                 out << tmp
386:             end
387:         end
388: 
389:         return out
390:     end