Sha256: 4aba54863d4bc2c1f407c098f0a129e1f1ea4da23572bb39ff409f4ff7ae4d63

Contents?: true

Size: 1.89 KB

Versions: 16

Compression:

Stored size: 1.89 KB

Contents

# Augments all parslet atoms with an accept method that will call back 
# to the visitor given.

# 
module Parslet::Atoms
  class Base
    def accept(visitor)
      raise NotImplementedError, "No #accept method on #{self.class.name}."
    end
  end
  
  class Str
    # Call back visitors #visit_str method. See parslet/export for an example.
    #
    def accept(visitor)
      visitor.visit_str(str)
    end
  end
  
  class Entity
    # Call back visitors #visit_entity method. See parslet/export for an
    # example. 
    #
    def accept(visitor)
      visitor.visit_entity(name, block)
    end
  end
  
  class Named
    # Call back visitors #visit_named method. See parslet/export for an
    # example. 
    #
    def accept(visitor)
      visitor.visit_named(name, parslet)
    end
  end
  
  class Sequence
    # Call back visitors #visit_sequence method. See parslet/export for an
    # example. 
    #
    def accept(visitor)
      visitor.visit_sequence(parslets)
    end
  end
  
  class Repetition
    # Call back visitors #visit_repetition method. See parslet/export for an
    # example. 
    #
    def accept(visitor)
      visitor.visit_repetition(@tag, min, max, parslet)
    end
  end
  
  class Alternative
    # Call back visitors #visit_alternative method. See parslet/export for an
    # example. 
    #
    def accept(visitor)
      visitor.visit_alternative(alternatives)
    end
  end
  
  class Lookahead
    # Call back visitors #visit_lookahead method. See parslet/export for an
    # example. 
    #
    def accept(visitor)
      visitor.visit_lookahead(positive, bound_parslet)
    end
  end
  
  class Re
    # Call back visitors #visit_re method. See parslet/export for an example. 
    #
    def accept(visitor)
      visitor.visit_re(match)
    end
  end
end

class Parslet::Parser
  # Call back visitors #visit_parser method. 
  #
  def accept(visitor)
    visitor.visit_parser(root)
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
parslet-2.0.0 lib/parslet/atoms/visitor.rb
parslet-1.8.2 lib/parslet/atoms/visitor.rb
parslet-1.8.1 lib/parslet/atoms/visitor.rb
parslet-1.8.0 lib/parslet/atoms/visitor.rb
swift-pyrite-0.1.1 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/lib/parslet/atoms/visitor.rb
swift-pyrite-0.1.0 vendor/bundle/ruby/2.0.0/gems/parslet-1.7.1/lib/parslet/atoms/visitor.rb
parslet-1.7.1 lib/parslet/atoms/visitor.rb
parslet-1.7.0 lib/parslet/atoms/visitor.rb
parslet-1.6.2 lib/parslet/atoms/visitor.rb
parslet-1.6.1 lib/parslet/atoms/visitor.rb
parslet-1.6.0 lib/parslet/atoms/visitor.rb
parslet-1.5.0 lib/parslet/atoms/visitor.rb
ghazel-parslet-1.4.0.2 lib/parslet/atoms/visitor.rb
ghazel-parslet-1.4.0.1 lib/parslet/atoms/visitor.rb
parslet-1.4.0 lib/parslet/atoms/visitor.rb
parslet-1.3.0 lib/parslet/atoms/visitor.rb