Class Citrus::Sequence

  1. lib/citrus.rb
Parent: Object

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

Methods

public instance

  1. exec

Included modules

  1. Nonterminal

Public instance methods

exec (input, events=[])

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

[show source]
      # File lib/citrus.rb, line 1198
1198:     def exec(input, events=[])
1199:       events << self
1200: 
1201:       index = events.size
1202:       start = index - 1
1203:       length = n = 0
1204:       m = rules.length
1205: 
1206:       while n < m && input.exec(rules[n], events).size > index
1207:         length += events[-1]
1208:         index = events.size
1209:         n += 1
1210:       end
1211: 
1212:       if n == m
1213:         events << CLOSE
1214:         events << length
1215:       else
1216:         events.slice!(start, index)
1217:       end
1218: 
1219:       events
1220:     end