2 # Implements the Composite pattern on SexpProcessor. Need we say more?
4 # Yeah... probably. Implements a SexpProcessor of SexpProcessors so
5 # you can easily chain multiple to each other. At some stage we plan
6 # on having all of them run +process+ and but only ever output
7 # something when +generate+ is called, allowing for deferred final
10 class CompositeSexpProcessor
13 # The list o' processors to run.
15 attr_reader :processors
17 def initialize # :nodoc:
22 # Add a +processor+ to the list of processors to run.
25 @processors << processor
29 # Run +exp+ through all of the processors, returning the final
33 @processors.each do |processor|
34 exp = processor.process(exp)
39 def on_error_in(node_type, &block)
40 @processors.each do |processor|
41 processor.on_error_in(node_type, &block)