Class: Parsby::Splicer

Inherits:
Object
  • Object
show all
Defined in:
lib/parsby.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.start(label = nil, &b) ⇒ Object



89
90
91
92
93
94
# File 'lib/parsby.rb', line 89

def self.start(label = nil, &b)
  m = new
  p = b.call m
  p % label if label
  m.start p
end

Instance Method Details

#end(p) ⇒ Object



106
107
108
109
110
111
112
113
114
# File 'lib/parsby.rb', line 106

def end(p)
  Parsby.new("splicer.end(#{p.label})") { |c|
    begin
      p.parse c
    ensure
      c.parsed_ranges.children[0].markers << self
    end
  }
end

#start(p) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/parsby.rb', line 96

def start(p)
  Parsby.new("splicer.start(#{p.label})") { |c|
    begin
      p.parse c
    ensure
      c.parsed_ranges.splice_to! self
    end
  }
end