File Manager

Path: /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/parslet-1.8.2/lib/parslet/atoms/

Viewing File: scope.rb

# Starts a new scope in the parsing process. Please also see the #captures
# method. 
#
class Parslet::Atoms::Scope < Parslet::Atoms::Base
  attr_reader :block
  def initialize(block)
    super()

    @block = block
  end
  
  def cached?
    false
  end
  
  def apply(source, context, consume_all)
    context.scope do
      parslet = block.call
      return parslet.apply(source, context, consume_all)
    end
  end
  
  def to_s_inner(prec)
    "scope { #{block.call.to_s(prec)} }"
  end
end