# Collect alternatives to an array by pushing them onto an internal # instance variable @__alternatives. We can then assemble all the alternatives # (including self) into an Array. This is used for specifying alternative # RightHandSides in a Rule in a Grammar. class Array def __alternatives @__alternatives ||= Array.new end def /(other) self.__alternatives << other self end def assemble_alternatives alternatives = self.__alternatives alternatives.unshift self alternatives end end