Pugs-Compiler-Rule

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN


my $pmc  = abs_path('lib/Pugs/Grammar/Rule.pmc');

my $mtime = time;
utime $mtime, $mtime, $pmc;

name                ('Pugs-Compiler-Rule');
perl_version        ('5.006001');
all_from            ('lib/Pugs/Compiler/Rule.pm');
requires            ('Parse::Yapp' => '0');
requires            ('PadWalker' => '1.0');
requires            ('Cache::Cache' => '1.05');
recommends          ('YAML::Syck' => '0.60');
requires            ('File::Slurp');

install_script      ('util/compile_p6grammar.pl');

eval "use_test_base();";
if ($@) {
    my $error = $@;
    eval 'use Test::Base 0.53;';

TODO  view on Meta::CPAN


* 2007-04-30

- <rule( param... )> doesn't always emit the parameter list

* 2007-03-09

- reuse kp6's AST processor
  - fix repeated capture counting problems

- remove PadWalker dependency?

- move all unicode tables (\n, \t, \v, \h, char classes) into 
  Pugs::Emitter::Rule::Perl5::CharClass

- try to compile Perl-6.0.0-STD.pm 

- finish | || & &&
  - DFA
  - [done] check precedence in Rule2.pm
  - workaround Rule2.pm problems (see the header in that file)
    (see MP6 for a workaround)

- document how to install a rule using eval $rule->source
  in order to access local variables (without PadWalker)

- implement compile-as-closure in order to allow ratchet/non-ratchet in
  the same rule

- finish **{...} implementation
- finish modifiers implementation

- check failing (infinite-loop) tests

* OLDER TODO

TODO  view on Meta::CPAN


- add rollback for [ x <!before k> ]+
  - should 'unmatch' last 'x' if there is a 'k' after it

- add 'negate' node to Regex
- add tests for 'negate'
- finish remaining metasyntax in <!...> Grammar

- static signature for '$^a' 

- add 'inlined' switch to disable PadWalker lookups

- fix the <ws> rule

Sigspace switch:

- 'doubled' <ws> doesn't work
  my $rule = Pugs::Compiler::Rule->compile('a (b) * c' );
  - but this works:  
  my $rule = Pugs::Compiler::Rule->compile('a (b )*c' );
- implement, test in non-ratchet rules

TODO  view on Meta::CPAN

- implement Perl 6 minilanguages (and categories).
  each language generate entries for the tokenizer hash
  <%statement_control|%prefix|%term>
- implement the main tokenizer using the minilanguages as terms

Priorities:

- features used in PGE P6 Grammar
- <after ...> in non-ratchet

- make PadWalker optional, as most distros don't hold PW 1.0

- '%var := xxx'; '@var := xxx'; %<var> := ; @<var> :=

- rule parameters 

- add placeholder 'not implemented' messages in the right places

- make Emitter::Rule::Perl5 subclassable - such that closures can be 
  parsed/compiled by a custom parser
- make the 'return' block functionally detectable (instead of regex)

lib/Pugs/Runtime/Regex.pm  view on Meta::CPAN

}

# not a 'rule node'
# gets a variable from the user's pad
# this is used by the <$var> rule
sub get_variable {
    my $name = shift;
    
    local $@;
    my($idx, $pad) = 0;
    while(eval { require PadWalker; $pad = PadWalker::peek_my($idx) }) {
        $idx++, next
          unless exists $pad->{$name};

        #print "NAME $name $pad->{$name}\n";
        return ${ $pad->{$name} } if $name =~ /^\$/;
        return $pad->{$name};  # arrayref/hashref
    }
    croak "Couldn't find '$name' in surrounding lexical scope.";
}

t/04-rule.t  view on Meta::CPAN

}

{
    # calling unnamed subrules
    my $match;
    eval {
    my $rule2 = Pugs::Compiler::Regex->compile( '.' );
    *test::rule_method6 = Pugs::Compiler::Regex->compile( '<$rule2>' )->code;
    $match = test->rule_method6( "xyzw" );
    };
    warn "# *** Please check if CPAN module 'PadWalker' is properly installed\n",
         "# *** This is the resulting error: $@"
        if $@;
    is( "$match", "x", 'a named subrule calls a lexical unnamed subrule' );
}

{
    my $rule = Pugs::Compiler::Regex->compile( '^x' );
    my $match = $rule->match( "\nx\n" );
    #print "Source: ", do{use Data::Dumper; Dumper($rule->{perl5})};
    #print "Match: ", $match->perl;

t/09-ratchet.t  view on Meta::CPAN


{
    # calling unnamed subrules
    my $match;
    my $rule2 = Pugs::Compiler::Token->compile( '.', { ratchet => 1 } );
    #print "Source: ", do{use Data::Dumper; Dumper( $rule2->perl5 )};
    eval {
    *test::rule_method6 = Pugs::Compiler::Token->compile( '<$rule2>', { ratchet => 1 } )->code;
    $match = test->rule_method6( "xyzw" );
    };
    warn "# *** Please check if CPAN module 'PadWalker' is properly installed\n",
         "# *** This is the resulting error: $@"
        if $@;
    #print "Source: ", do{use Data::Dumper; Dumper( Pugs::Compiler::Token->compile( '<$rule2>', { ratchet => 1 } )->perl5 )};
    #print "Match: ", do{use Data::Dumper; Dumper($match)};
    is( "$match", "x", 'a named subrule calls a lexical unnamed subrule' );
}

### XXX built-in subrule <alpha> not formally specified in S05
{
    # generated rules



( run in 0.794 second using v1.01-cache-2.11-cpan-05444aca049 )