class Citrus::Sequence

A Sequence is a Nonterminal where all rules must match. The Citrus notation is two or more expressions separated by a space, e.g.:

expr expr

Public Instance Methods

exec(input, events=[]) click to toggle source

Returns an array of events for this rule on the given input.

# File lib/citrus.rb, line 1197
def exec(input, events=[])
  events << self

  index = events.size
  start = index - 1
  length = n = 0
  m = rules.length

  while n < m && input.exec(rules[n], events).size > index
    length += events[-1]
    index = events.size
    n += 1
  end

  if n == m
    events << CLOSE
    events << length
  else
    events.slice!(start, index)
  end

  events
end