nyaapa has asked for the wisdom of the Perl Monks concerning the following question:

Hi, monks

How can i generate a Regexp::Grammars parser from file/scalar?

I use

my $str = " ^ <$start_rule> \$ $rules "; my $link = bless(\$str, 'Regexp::Grammars::Precursor'); $parser = qr{$link}ixs;
but i dont like this "hack"..

Update

It's ok to use

my $str = " ^ <$start_rule> \$ $rules "; $parser = qr{$link }ixs;

Replies are listed 'Best First'.
Re: Regexp::Grammars parser from scalar
by jakeease (Friar) on May 10, 2013 at 04:01 UTC

    There's lots of example code and explanation on CPAN: Regexp::Grammars

    Perhaps a little more about what you want to do?

      yep, it's true, but
      1. i cant use my $regexp = qr{$pattern}ixs, i need to write my $regexp = qr{$pattern }ixs because of caching
      2. there was a bug before version 1.028 with caching of post-translated regexes and because of it i thought that i cant use form like
        $regexp = qr{ ^ <$rule> $ $rules }ixs;
      thanks however )
Re: Regexp::Grammars parser from scalar
by Anonymous Monk on May 11, 2013 at 08:44 UTC
      thanks, i found that i couldn't use form like
      my $str = " ^ <$start_rule> \$ $rules "; $parser = qr{$link }ixs;
      because of a bug :)