develooper Front page | perl.perl6.language | Postings from May 2005

s/.../{ $junction }/

From:
Ingo Blechschmidt
Date:
May 19, 2005 10:45
Subject:
s/.../{ $junction }/
Message ID:
d6ij1d$vrr$1@sea.gmane.org
Hi,

while writing a preliminary p6explain, I wondered if the following
should work:
  my $text = "aBc";
  $text ~~ s/B/{ "C"|"D" }/;
  say $text.values; # aCc aDc

This would be extremely handy for p6explain, as I'm currently parsing a
datafile which looks like...
  +
    Standard mathematical infix operator.
  @infix_ops
    + - * /
  [@infix_ops]
    Reduce metaoperator.
    Think of a join on the syntax level.

I could then do something like this:
  # $rule is '[@infix_ops]'
  $rule ~~ s/\@infix_ops/{ any split " ", %rule{'@infix_ops'} }/;
  copy_contents_to $rule.values;


Comments?


--Ingo

-- 
Linux, the choice of a GNU | self-reference, n. - See self-reference  
generation on a dual AMD   | 
Athlon!                    |




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About