Class: Parslet::Atoms::Entity

### Home Classes Methods

### In Files

- lib/parslet/atoms/entity.rb
- lib/parslet/atoms/visitor.rb

### Parent

Parslet::Atoms::Base

### Methods

- ::new
- #accept
- #parslet
- #to_s_inner
- #try

### Files

- README

### Class/Module Index

Quicksearch

- Parslet
- Parslet::Atoms
- Parslet::Atoms::Alternative
- Parslet::Atoms::Base
- Parslet::Atoms::CanFlatten
- Parslet::Atoms::Capture
- Parslet::Atoms::Context
- Parslet::Atoms::DSL
- Parslet::Atoms::Dynamic
- Parslet::Atoms::Entity
- Parslet::Atoms::Lookahead
- Parslet::Atoms::Named
- Parslet::Atoms::Precedence
- Parslet::Atoms::Re
- Parslet::Atoms::Repetition
- Parslet::Atoms::Scope
- Parslet::Atoms::Sequence
- Parslet::Atoms::Str
- Parslet::Cause
- Parslet::ClassMethods
- Parslet::DelayedMatchConstructor
- Parslet::ErrorReporter
- Parslet::ErrorReporter::Deepest
- Parslet::ErrorReporter::Tree
- Parslet::Expression
- Parslet::Expression::Treetop
- Parslet::Expression::Treetop::Parser
- Parslet::Expression::Treetop::Transform
- Parslet::ParseFailed
- Parslet::Parser
- Parslet::Parser::PrettyPrinter
- Parslet::Parser::Visitors
- Parslet::Parser::Visitors::Citrus
- Parslet::Parser::Visitors::Treetop
- Parslet::Pattern
- Parslet::Pattern::SequenceBind
- Parslet::Pattern::SimpleBind
- Parslet::Pattern::SubtreeBind
- Parslet::Scope
- Parslet::Scope::Binding
- Parslet::Scope::NotFound
- Parslet::Slice
- Parslet::Source
- Parslet::Source::LineCache
- Parslet::Source::RangeSearch
- Parslet::Transform
- Parslet::Transform::Context

No matching classes.

# Parslet::Atoms::Entity

This wraps pieces of parslet definition and gives them a name. The wrapped piece is lazily evaluated and cached. This has two purposes:

- Avoid infinite recursion during evaluation of the definition

- Be able to print things by their name, not by their sometimes complicated content.

You don't normally use this directly, instead you should generated it by using the structuring method Parslet.rule.

### Attributes

block[R]
name[R]

### Public Class Methods

new(name, &block) click to toggle source

    # File lib/parslet/atoms/entity.rb, line 13
    def initialize(name, &block)
      super()

      @name = name
      @block = block
    end

### Public Instance Methods

accept(visitor) click to toggle source

Call back visitors visit_entity method. See parslet/export for an example.

    # File lib/parslet/atoms/visitor.rb, line 24
    def accept(visitor)
      visitor.visit_entity(name, block)
    end

parslet() click to toggle source

    # File lib/parslet/atoms/entity.rb, line 24
    def parslet
      @parslet ||= @block.call.tap { |p|
        raise_not_implemented unless p
      }
    end

to_s_inner(prec) click to toggle source

    # File lib/parslet/atoms/entity.rb, line 30
    def to_s_inner(prec)
      name.to_s.upcase
    end

try(source, context, consume_all) click to toggle source

    # File lib/parslet/atoms/entity.rb, line 20
    def try(source, context, consume_all)
      parslet.apply(source, context, consume_all)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.