Class Parslet::Atoms::Context
In: lib/parslet/atoms/context.rb
Parent: Object

Helper class that implements a transient cache that maps position and parslet object to results. This is used for memoization in the packrat style.

Also, error reporter is stored here and error reporting happens through this class. This makes the reporting pluggable.

Methods

err   err_at   new   scope   try_with_cache  

Attributes

captures  [R]  Returns the current captures made on the input (see Parslet::Atoms::Base#capture). Use as follows:
  context.captures[:foobar] # => returns capture :foobar

Public Class methods

@param reporter [err, err_at] Error reporter (leave empty for default

  reporter)

Public Instance methods

Report an error. @see ErrorReporter

Report an error at a given position. @see ErrorReporter

Starts a new scope. Use the scope method of Parslet::Atoms::DSL to call this.

Caches a parse answer for obj at source.pos. Applying the same parslet at one position of input always yields the same result, unless the input has changed.

We need the entire source here so we can ask for how many characters were consumed by a successful parse. Imitation of such a parse must advance the input pos by the same amount of bytes.

[Validate]