>>>>> "SC" == Simon Cozens <[EMAIL PROTECTED]> writes:
SC> raiddev /dev/md0 SC> raid-level 5 SC> option value SC> option value SC> ... SC> device /dev/sde1 SC> raid-disk 0 i have some comments/questions as i am trying to learn this myself. i could be way off base but here goes: SC> grammar Raidtab; SC> rule raidtab { <raiddev>+ }; SC> rule comment { <sp*> \# .* | shouldn't that . be \N so it won't eat the next line or even beyond? also you have <sp*> here and <sp>* below. i think the latter is correct. SC> # Or a blank line SC> ^^ \n }; shouldn't that have a <sp*> inside the blank line? SC> rule comm_eol { <sp*> <comment>? <sp*> \n }; aren't those <sp*>'s redundant? the first is overlapping with the one at the beginning of comment. and the second is subsumed by the .* at the end of comment. SC> rule raiddev { <comment>* i think that should be comm_eol as you want to skip all full comment lines. SC> <sp>* "raiddev" <sp>+ $name := (/dev/md\d+) <comm_eol> SC> (<devicelayout> | <option> | <comment>)+ }; same as above, comm_eol instead of comment. SC> rule option { <sp>* $key := (<[a-z]->+) <sp>* $value := (\w+) <comm_eol> }; i think that char class should be <[a-z-]>. <[]> marks a class and the - needs to be inside it. the second <sp>* should be <sp>+ as you need whitespace between the option and value. SC> rule devicelayout { <sp>* device <sp>+ $name := (/dev/\w+) <comm_eol> the \w+ after /dev/ needs to be more accepting as i think some devices could be in subdirs SC> <sp>* $type := (raid|spare|parity) -disk <sp>* SC> $index := (\d+) <comm_eol> SC> }; SC> What I can't figure out is how to drill down into the returned match SC> object and get at individual devices. I'd expect to be able to say SC> something like SC> $matchobject{raiddev}[0]{devicelayout}[1]{name} SC> and get "/dev/sdf1". Is that how it works, with multiply-matched rules SC> being put into arrays, or is it stored differently somehow? that is how i understand it. the grammar automatically build a tree of the grabs with hash keys being the rule names and multiples (rules with quantifiers) being arrays. what about the case where you have a descending set of rules but no quantifiers. would you just not have the [0] parts when you access it from the match object? uri -- Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com ----- Stem and Perl Development, Systems Architecture, Design and Coding ---- Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org