Front page | perl.perl6.language |
Postings from September 2002
Re: Regex query
From:
Uri Guttman
Date:
September 20, 2002 00:17
Subject:
Re: Regex query
Message ID:
x7bs6tuo2p.fsf@mail.sysarch.com
>>>>> "SC" == Simon Cozens <simon@ermine.ox.ac.uk> writes:
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.
SC> But <comment> only matches if there *is* a comment, and there may not
SC> be, so I want to match optional space at the EOL anyway.
ok, but since comment is optional, if it doesn't match, the two <sp>*
are back to back. is that needed? i just see too many <sp>* and that
could lead to backtracking issues (something i recall from MRE1).
SC> rule raiddev { <comment>*
>> i think that should be comm_eol as you want to skip all full comment lines.
SC> I thought the .* (or \N*) would skip the whole line. comm_eol just means
SC> "comment at end of line".
i figured that was what it meant. but . matches any char now so .* will
eat all the text until it is forced to backtrack. so \N* will stop at
the newline which is what i think you want in comm_eol.
>> 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.
SC> Great.
actually i just had another thought. you don't need any of the $foo :=
stuff as the match tree will have it all for you. unless you need a
single var having some grabbed stuff, you might as well let the match
object hold it all. you do want a tree from this parser so the single
vars will do no good. unless they also put stuff into the tree based on
their names. also if you use a scalar to grab something which is in a
quantified outer rule what is put in the var? a ref to a list of the
grabbed things?
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org