Capturing subpatterns

Carlos Antunes cmantu... at gmail.com
Tue Jul 3 23:04:50 UTC 2007


HI Adrian,

As promised, here's my request for a capture feature.

I base my request on a similar feature used on PCRE called Named
Subpatterns. This is useful because it obviates the need to do capture
byte-by-byte. A typical expression would be (as given in the
pcrepattern(3) man-page :

(?P<DN>Mon|Fri|Sun)(?:day)?|
(?P<DN>Tue)(?:sday)?|
(?P<DN>Wed)(?:nesday)?|
(?P<DN>Thu)(?:rsday)?|
(?P<DN>Sat)(?:urday)?

The syntax uses '?' as a modifier to '(' and allows different and
context-sensitive extensions to its regular meaning. The 'P<name>' is
the one used for naming capturing subpatterns. (The fact that
subpatterns in Ragel don't currently do any capturing is of no
consequence, I would suggest.)

Personally, I think this feature would be very useful as it would make
the life of the programmer easier.It would facilitate the capture of
portions of the input stream without relying on byte-by-byte copying.

So, here I am, humbly requesting yet another feature! :)

Thanks!

Carlos

-- 
"We hold [...] that all men are created equal; that they are
endowed [...] with certain inalienable rights; that among
these are life, liberty, and the pursuit of happiness"
        -- Thomas Jefferson



More information about the ragel-users mailing list