• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

examples/H29-Jul-2008-862692

inc/H29-Jul-2008-4,5163,384

lib/Pugs/H29-Jul-2008-22,95719,102

t/H29-Jul-2008-6,1875,303

tracer/H03-May-2022-

util/H29-Jul-2008-482276

ChangesH A D29-Jul-200811.3 KiB335257

MANIFESTH A D29-Jul-20082.2 KiB10099

MANIFEST.SKIPH A D29-Jul-2008431 4544

Makefile.PLH A D29-Jul-20081.8 KiB8061

READMEH A D29-Jul-20084 KiB13896

TODOH A D29-Jul-20085.6 KiB249173

README

1NAME
2    Pugs::Compiler::Rule - Compiler for Perl 6 regexes
3
4VERSION
5    This document describes Pugs::Compiler::Rule 0.28 released on 31 Oct,
6    2007.
7
8SYNOPSIS
9    Un-named rules are objects:
10
11        use Pugs::Compiler::Rule;
12
13        my $rule = Pugs::Compiler::Rule->compile( '((.).).' );
14        my $match = $rule->match( 'abc' );
15
16        if ($match) {               # true
17            print $match;           # "abc"
18            print $match->from;     # 0
19            print $match->to;       # 3
20            print $match->[0];      # "ab"
21            print $match->[0][0];   # "a"
22        }
23
24    Named rules are methods in a Grammar:
25
26        package MyGrammar;
27        use Pugs::Compiler::Rule;
28        use base 'Pugs::Grammar::Base';
29
30        Pugs::Compiler::Rule->install( rule => '((.).).' );
31        my $match = MyGrammar->rule( 'abc' );
32
33    Rules may have parameters:
34
35        $grammar->install(subrule => $source, { signature => $sig } );
36
37        $grammar->install(rule => q{
38                <subrule: param1, param2>
39        });
40
41    where $grammar is normally a Perl 5 package.
42
43DESCRIPTION
44    This module provides an pure Perl 5 implementation for Perl 6 regexes,
45    which does not depend on the Haskell Pugs.
46
47    It is a front-end to several other modules:
48
49    Front-end Modules
50
51    * Pugs::Compiler::Grammar compiles Perl 6 grammars to Perl 5.
52    * Pugs::Compiler::Rule compiles Perl 6 rules to Perl 5.
53    * Pugs::Compiler::Token compiles Perl 6 tokens to Perl 5.
54    * Pugs::Compiler::Regex compiles Perl 6 regexes to Perl 5.
55    * Pugs::Compiler::RegexPerl5 wraps Perl 5 regexes to return a Match
56    object.
57
58    Runtime Classes
59
60    * Pugs::Runtime::Rule provides the runtime engine for Rules.
61    * Pugs::Runtime::Match represents a Match object.
62    * Pugs::Runtime::Grammar represents a Grammar class / object.
63
64    Grammars
65
66    * Pugs::Grammar::Rule parses the Rules syntax.
67    * Pugs::Grammar::Base is the base Grammar: <ws>, <space>.
68
69    Code Emitters
70
71    * Pugs::Emitter::Rule::Perl5 converts parsed Rules to Perl 5 code.
72    * Pugs::Emitter::Rule::Perl5::Ratchet converts parsed :ratchet Rules to
73    Perl 5 code.
74    * Pugs::Emitter::Grammar::Perl5 converts parsed grammars to Perl 5 code.
75
76INHERITANCE
77      Pugs::Compiler::Rule
78         isa Pugs::Compiler::Regex
79
80METHODS
81    This class (i.e. Pugs::Compiler::Rule) is a subclass of
82    Pugs::Compiler::Regex and thus owns all the methods of its base class.
83    See Pugs::Compiler::Regex for the detailed docs.
84
85    "$rule = Pugs::Compiler::Rule->compile($p6_regex, $params)"
86        Specifically, this class overrides the "compile" method of
87        Pugs::Compiler::Regex which resets the following options' default
88        values:
89
90        "ratchet => 1"
91            Here is an example:
92
93                $rule = Pugs::Compiler::Rule->compile(
94                    'a*\w',
95                );
96                my $match = $rule->match('aaa');
97                # $match->bool is false since no backtracking
98                # happened
99
100        "sigspace => 1"
101            Here is an example:
102
103                my $rule = Pugs::Compiler::Rule->compile(
104                    'a b',
105                );
106                my $match = $rule->match('a     b');
107                ok $match->bool, 'sigspace works';
108                is $match->(), 'a     b', 'sigspace works (2)';
109
110CAVEATS
111    This is an experimental development version. The API is still in flux.
112
113    The set of implemented features depend on the "ratchet" switch.
114
115AUTHORS
116    The Pugs Team "<perl6-compiler@perl.org>".
117
118    Please join us on irc.freenode.net "#perl6" if you'd like to
119    participate.
120
121SEE ALSO
122    *   Pugs::Compiler::Regex
123
124    *   Pugs::Compiler::Grammar
125
126    *   compile_p6grammar.pl
127
128    *   The Perl 6 Rules Spec: <http://perlcabal.org/syn/S05.html>
129
130COPYRIGHT
131    Copyright 2006, 2007 by Flavio Soibelmann Glock and others.
132
133    This program is free software; you can redistribute it and/or modify it
134    under the same terms as Perl itself.
135
136    See <http://www.perl.com/perl/misc/Artistic.html>
137
138