Perl6::Rules

Perl6::Rules implements (most of) the Perl 6 regex syntax.
Download

Perl6::Rules Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Damian Conway
  • Publisher web site:
  • http://search.cpan.org/~dconway/

Perl6::Rules Tags


Perl6::Rules Description

Perl6::Rules implements (most of) the Perl 6 regex syntax. Perl6::Rules implements (most of) the Perl 6 regex syntax.SYNOPSIS # Perl 5 code... use Perl6::Rules; grammar HTML { rule doc :iw { Q < ?head > < ?body > Q } rule head :iw { Q < ?head_tag >+ Q } # etc. } $text =~ s:globally:2nd/ < ?HTML.doc > /$0{doc}{head}/; rule subj { < noun > } rule obj { < noun > } rule noun { time | flies | arrow } rule verb { flies | like | time } rule adj { time } rule art { an? } rule prep { like } "time flies like an arrow" =~ m:words:exhaustive/^ /; print "Found interpretation:n", $_->dump for @$0; $dna_seq =~ m:overlap{ A < > < >< 3,7 > }; print "Found sequence: $_ starting at " $_->pos for @$0; # etc.This module implements a close simulation of the Perl 6 rule and grammar constructs, translating them back to Perl 5 regexes via a source filter. (And hence suffers from all the usual limitations of a source filter, including the ability to translate complex code spectacularly wrongly).When it is use'd, the module expects that any subsequent match (m/.../) or substitution (s/.../.../) in the rest of the source file will be in Perl 6 syntax. It then translates every such pattern back to the equivalent Perl 5 syntax (where possible).When one of these translated matches/substitutions is executed, it generates a "match object", which is available as $0 (and so, if you use Perl6::Rules, the program name is no longer available as $0). This match object can be treated as a boolean (in which case it returns true if the match succeeded, and false if it did not), or as a string (in which case it returns the complete substring that the match matched), or as an array (in which case it contains all of the numbered captures -- $1, $2, etc. -- from the successful match), or as a hash (in which case it contains all of the internal variables created during the match).Requirements:· Perl


Perl6::Rules Related Software