Method: Parslet.scope

Defined in:
lib/parslet.rb

.scope(&block) ⇒ Object

Introduces a new capture scope. This means that all old captures stay accessible, but new values stored will only be available during the block given and the old values will be restored after the block.

Example:

# :a will be available until the end of the block. Afterwards, 
# :a from the outer scope will be available again, if such a thing 
# exists. 
scope { str('a').capture(:a) }


183
184
185
# File 'lib/parslet.rb', line 183

def scope(&block)
  Parslet::Atoms::Scope.new(block)
end