From: Philipp Kempgen on
Philipp Kempgen wrote:
> I'm looking for a parser which can be fed with some (A)BNF-style rules.
...
> If so, which parser is more appropriate?
> 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?

Regards,
Philipp

From: Iain Barnett on

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.
> ...
>> If so, which parser is more appropriate?
>> 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?
>
> Regards,
> Philipp
>

I was trying to do the same thing and asked about repeated named captures.
http://osdir.com/ml/ruby-talk/2010-07/msg00361.html

It seems that using String#scan is the closest anything Ruby has, as the Oniguruma regex engine doesn't support it. I think it's a real shame as named capture groups are really useful.

Regards,
Iain