Class: Rattler::Parsers::CombinatorParser

Inherits:
Runtime::Parser show all
Defined in:
lib/rattler/parsers/combinator_parser.rb

Instance Attribute Summary

Attributes inherited from Runtime::Parser

#source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Runtime::Parser

#fail, #fail!, #fail_parse, #failure, #failure?, #parse, #parse!, parse!, #parse_fully, #parse_fully!, parse_fully!, #pos, #pos=

Methods inherited from Util::Node

#==, #[], [], #attrs, #can_equal?, #child, #children, #each, #empty?, #eql?, #inspect, #method_missing, #name, #respond_to?, #same_contents?, #to_graphviz, #with_attrs, #with_attrs!, #with_children

Constructor Details

#initialize(source, start_rule, rule_set) ⇒ CombinatorParser

Returns a new instance of CombinatorParser.



21
22
23
24
25
# File 'lib/rattler/parsers/combinator_parser.rb', line 21

def initialize(source, start_rule, rule_set)
  super source
  @start_rule = start_rule
  @rule_set = rule_set
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rattler::Util::Node

Class Method Details

.as_class(start_rule, rule_set) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/rattler/parsers/combinator_parser.rb', line 13

def self.as_class(start_rule, rule_set)
  new_class = Class.new(self)
  new_class.send :define_method, :initialize do |source|
    super source, start_rule, rule_set
  end
  new_class
end

Instance Method Details

#__parse__Object



27
28
29
# File 'lib/rattler/parsers/combinator_parser.rb', line 27

def __parse__
  @start_rule.parse(@scanner, @rule_set)
end