class Rattler::Parsers::AttributedSequence

AttributedSequence combines one or more parsers with a semantic action and matches the parser in sequence and applies the action to the captured results.

Public Instance Methods

capture_count() click to toggle source

(see Sequence#capture_count)

# File lib/rattler/parsers/attributed_sequence.rb, line 45
def capture_count
  @capture_count ||= children[0...-1].count {|_| _.capturing? }
end
capturing?() click to toggle source

(see Parser#capturing?)

# File lib/rattler/parsers/attributed_sequence.rb, line 35
def capturing?
  children.last.capturing?
end
capturing_decidable?() click to toggle source

(see Parser#capturing_decidable?)

# File lib/rattler/parsers/attributed_sequence.rb, line 40
def capturing_decidable?
  false
end
parse(scanner, rules, scope = ParserScope.empty) { |scope| ... } click to toggle source

Parse each parser in sequence, and if they all succeed return the result of applying the semantic action to the captured results.

@param (see Match#parse)

@return the result of applying the semantic action to the captured

results of each parser, or +false
# File lib/rattler/parsers/attributed_sequence.rb, line 24
def parse(scanner, rules, scope = ParserScope.empty)
  result = false
  backtracking(scanner) do
    if scope = parse_children(scanner, rules, scope.nest) {|r| result = r }
      yield scope if block_given?
      result
    end
  end
end