def parse(parent_node)

    # run element parser
    begin
      parent_node.parser.matching_negative if negative
      match = parser.call(parent_node)
    ensure
      parent_node.parser.unmatching_negative if negative
    end

    # Negative patterns (PEG: !element)
    match = match ? nil : EmptyNode.new(parent_node) if negative

    # Optional patterns (PEG: element?)
    match = EmptyNode.new(parent_node) if !match && optional

    # Could-match patterns (PEG: &element)
    match.match_length = 0 if match && could_match

    if !match && (terminal || negative)
      # log failures on Terminal patterns for debug output if overall parse fails
      parent_node.parser.log_parsing_failure parent_node.next, :pattern => self.to_s, :node => parent_node
    end

    match.delimiter = delimiter if match

    # return match
    match
  end
def parse(parent_node)

    # run element parser
    begin
      parent_node.parser.matching_negative if negative
      match = parser.call(parent_node)
    ensure
      parent_node.parser.unmatching_negative if negative
    end

    # Negative patterns (PEG: !element)
    match = match ? nil : EmptyNode.new(parent_node) if negative

    # Optional patterns (PEG: element?)
    match = EmptyNode.new(parent_node) if !match && optional

    # Could-match patterns (PEG: &element)
    match.match_length = 0 if match && could_match

    if !match && (terminal || negative)
      # log failures on Terminal patterns for debug output if overall parse fails
      parent_node.parser.log_parsing_failure parent_node.next, :pattern => self.to_s, :node => parent_node
    end

    match.delimiter = delimiter if match

    # return match
    match
  end
attempt to match the pattern defined in self.parser in parent_node.src starting at offset parent_node.next