You have a number of errors in your grammar:
- In the rule ip_nosemi, you forgot to backslash the last "</code>\d</code>".
- In hosts_or_range, you have host(s?), when you probably meant to put the (s?) in network object.
- You can't use $item as both a hash and an array in the same production!
I also reorganized your grammar a bit. It should work now, although I'm on a machine without PRD installed at the moment so you shouldn't just take my word on that. However, tachyon is right on this one; PRD is far too large of a hammer to use parse data like this. :)
startrule: network_object(s)
network_object: /network:(\w+)/ '=' '{'
'ip' '=' ip
'mask' '=' ip
hosts_or_range(s?)
'}'
{ print "Found network object named $item[1] ",
"with IP $item[6] and MASK $item[9]\n"
}
hosts_or_range: host | host_range
host_range: /host:\w+/ '=' '{' 'range' '=' ip '-' ip '}'
host: /host:\w+/ '=' '{' 'ip' '=' ip(s) '}'
ip: / \d{1,3} (?:\.\d{1,3}){3} ;? /x
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.