in reply to Re: How to use Regexp::Common patterns in Regexp::Grammars? (Properly)
in thread How to use Regexp::Common patterns in Regexp::Grammars?
I've no idea what I'm doing wrong but unfortunately for me, both a bare $RE... and #$RE... fails for me.
use 5.026; use Carp; use Data::Dumper; use Readonly; use Regexp::Common qw[ delimited ]; use Regexp::Grammars; use Try::Tiny; BEGIN { say "Regexp::Common: $Regexp::Common::VERSION"; say "Regexp::Grammars: $Regexp::Grammars::VERSION"; } try { my $grammar = qr{ <nocontext:> <TEST> <rule: TEST> <Quoted_String> <token: Quoted_String> $RE{delimited}{-delim=>q{'}}{-esc=> +q{'}} }; if (q{'some string with containing a '''} =~ $grammar) { warn Data::Dumper->new([\%/],[qw(*/)])->Deepcopy(1)->Indent(1) +->Maxdepth(3)->Sortkeys(1)->Dump(),q{ }; }; } catch { Carp::cluck $_ }; # line 24 try { my $grammar = qr{ <nocontext:> <TEST> <rule: TEST> <Quoted_String> <token: Quoted_String> #$RE{delimited}{-delim=>q{'}}{-esc= +>q{'}} }; if (q{'some string with containing a '''} =~ $grammar) { warn Data::Dumper->new([\%/],[qw(*/)])->Deepcopy(1)->Indent(1) +->Maxdepth(3)->Sortkeys(1)->Dump(),q{ }; }; } catch { Carp::cluck $_ }; # line 36
yields
>perl re.t Regexp::Common: 2017060201 Regexp::Grammars: 1.057 Not a SCALAR reference at C:/berrybrew/5.32.1_64/perl/site/lib/Regexp/ +Grammars.pm line 106. at ..\..\test\re.t line 24. main::catch {...} ("Not a SCALAR reference at C:/berrybrew/5.3 +2.1_64/perl/site/li"...) called at C:/berrybrew/5.32.1_64/perl/lib/Tr +y/Tiny.pm line 123 Try::Tiny::try(CODE(0xf9c1a0), Try::Tiny::Catch=REF(0x2819630) +) called at ..\..\test\re.t line 24 Not a SCALAR reference at C:/berrybrew/5.32.1_64/perl/site/lib/Regexp/ +Grammars.pm line 106. at ..\..\test\re.t line 36. main::catch {...} ("Not a SCALAR reference at C:/berrybrew/5.3 +2.1_64/perl/site/li"...) called at C:/berrybrew/5.32.1_64/perl/lib/Tr +y/Tiny.pm line 123 Try::Tiny::try(CODE(0xf9c1a0), Try::Tiny::Catch=REF(0xe581f8)) + called at ..\..\test\re.t line 36
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: How to use Regexp::Common patterns in Regexp::Grammars? (Properly)
by Anonymous Monk on Jun 10, 2022 at 09:22 UTC |