|Problems? Is your data what you think it is?|
Cannot get Marpa::R2 to prioritise one rule over anotherby Anonymous Monk
|on Jan 21, 2021 at 04:58 UTC||Need Help??|
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a Marpa::R2 parser that is attempting to differentiate between IP addresses and hostnames without a difference in leading keywords. The actual grammar I am using is complicated enough not to try and replicate it here, but a minimally-reproducable example of the same problem is below:
From what I can tell, Marpa always picks the <hostname> form of the grammar, even on lines that look more like IPs. I assume this is because the character class [\S]+ also includes the characters which make up an IP address.
So far, in my grammar definition, I've tried:
...and none seem to make a difference. They all yield the ['hostname', '192.0.2.1'] array.
The only thing that does it is removing the <hostname> alternate from <hostaddr4> (which does not match the grammar of the data I am parsing), and then the representation changes to ['ipv4', '192', '0', '2', '1']
Can anyone advise the correct approach in this (seemingly) simple case?J.