There's more than one way to do things | |
PerlMonks |
Re: Cannot get Marpa::R2 to prioritise one rule over anotherby Discipulus (Canon) |
on Jan 21, 2021 at 07:57 UTC ( [id://11127195]=note: print w/replies, xml ) | Need Help?? |
Hello J. UPDATE I probably missed your point.. now I see the IP is never reachead but always treated as if it was and hostname. I'll think a bit more about it.. The problem seems to be fixed if you put NAME ~ [\D]+ but you will fail again with a hostname like 42.perl.org Perhaps a more strict rule definition is needed to tell difference from ip and hostname. original reply My help can be very limited because I still do not understand Marpa::R2 and I'm just moving my first, baby steps. I dont understand the rank nor the show_progress part (atm). So I reduced the example to something I know (removing the colors). Is not the hostname coming from your :default ::= action => [name,values] ? This is what proposed in the synopsis but I find it a bit misleading. If you see A dice roller system with Marpa::R2 and its prequel First steps with Marpa::R2 and BNF you will see an anonymous hash is used and is populated during the parsing phase. Maybe you can use a pattern like this (then you can check the validity of an IP or of a valid hostname in distinct part of the code). I ended with the following code that seems to produce the expected result
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
In Section
Seekers of Perl Wisdom
|
|