class 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:

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

Attributes

block[R]
name[R]

Public Class Methods

new(name, label=nil, &block) click to toggle source
# File lib/parslet/atoms/entity.rb, line 13
def initialize(name, label=nil, &block)
  super()
  
  @name = name
  @label = label
  @block = block
  @parslet = nil
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 26
def parslet
  return @parslet unless @parslet.nil?
  @parslet = @block.call
  raise_not_implemented if @parslet.nil?
  @parslet.label = @label
  @parslet
end
to_s_inner(prec) click to toggle source
# File lib/parslet/atoms/entity.rb, line 34
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 22
def try(source, context, consume_all)
  parslet.apply(source, context, consume_all)
end