Robert Klemme wrote: > On 13.08.2010 00:50, Iain Barnett wrote: >> On 12 Aug 2010, at 19:52, Philipp Kempgen wrote: >> >>> Philipp Kempgen wrote: >>>> I'm looking for a parser which can be fed with some (A)BNF-style rules. >>> ... >>>> It should hand back a parse tree. >>> >>> Alternatively I'd appreciate if Regexps could return *all* >>> occurrences of named capture groups inside repetitions etc. >>> instead of just the last match for each name. Feasible? > > As I understand you want /f(o)+/ =~ "foo" to return ["o", "o"] as match > for the group (used normal capturing groups for simplicity). FRUIT = '(?<FRUIT> Apple|Banana|Pear|Orange)' FRUIT_COLLECTION = '(?<FRUIT_COLLECTION> ' << FRUIT << '*)' re = Regexp.new( '^' << FRUIT_COLLECTION << '$', Regexp::EXTENDED ) re.match( 'PearBananaApple' )[:FRUIT] => "Apple" I would want e.g. matchdata[:FRUIT] to be an Array [ 'Pear', 'Banana', 'Apple' ] and not just 'Apple' (the last FRUIT). Actually something similar to a concrete syntax tree / parse tree would be even better: ROOT "PearBananaApple" FRUIT_COLLECTION "PearBananaApple" FRUIT "Pear" FRUIT "Banana" FRUIT "Apple" >> the Oniguruma regex engine doesn't support it. I think it's a real shame as named capture groups are really useful. Exactly. Anyway thanks for your input. Regards, Philipp