Brent Dax asked:
Will that handle captures correctly?
I believe so. Each (successful) time through the loop we cache
a reference to the candidate's match object, which will successfully
have stored all the captures from the candidate's matching.
Then we reinstate the best candidate, by
On Thu, Jun 13, 2002 at 03:48:25PM -0700, Larry Wall wrote:
But the most straightforward way to match longest is probably to use
:any to get a superposition of matches, and then pull out the longest
match.
So, does :any return a list of the substrings that matched or a list
of match
On Fri, 14 Jun 2002, Jonathan Scott Duff wrote:
: On Thu, Jun 13, 2002 at 03:48:25PM -0700, Larry Wall wrote:
: But the most straightforward way to match longest is probably to use
: :any to get a superposition of matches, and then pull out the longest
: match.
:
: So, does :any return a
I'm still unclear as to how you implement lex-like longest token rule with
P6 regexes. If the | operator grabs the first one it matches, how do I
match bacamus out of this?:
bacamus =~ / b.*a | b.*s /
Borrow this trick from Parse::RecDescent:
rule max (*@candidates) {{
Damian Conway:
# I'm still unclear as to how you implement lex-like longest
# token rule
# with P6 regexes. If the | operator grabs the first one it matches,
# how do I match bacamus out of this?:
#
# bacamus =~ / b.*a | b.*s /
#
# Borrow this trick from Parse::RecDescent:
#
#
I figured that (I actually did it, in a less-pretty form, in my early
Perl days when I wrote a syntax highlighter for my website). So there's
no elegant way the new regexes support it? That's a shame.
But I see now how state objects are a very cool idea.
Oh, and I'd just thought I'd let
Luke Palmer wrote:
So there's no elegant way the new regexes support it?
That's a shame.
max(/b.*a/, /b.*s/)
seems fairly elegant to me, with 2 caveats:
First, we need assertions as part of the default library. I.e. we shouldn't
need a Cuse for things like min and max.
Second, we should
On Thu, 13 Jun 2002, David Whipp wrote:
: Second, we should eliminate as much of the syntactic noise as possible:
:
: max b.*a b.*s
:
: would be nice -- with parenthesis, or the like, needed only when things
: become ambiguous. I think, though am not sure, that having whitespace act as
: an