Re: STILL NOT RIGHT, <commit> and subrules
[email protected] (Dave McD)
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
Actually, after looking at this further, this is still not what I need. Note that any subrule with a repetition specifier is going to attempt to backtrack if it fails on its last repeated attempt since it assumes that text must be something else if it does not match. So, even though you can get it to fail by anchoring it with a negative lookahead after it or with your technique Marcel, any <error?> <reject> production within the repeated rule after a commit is useless, because of the backtracking. IE. if the repeated rule can be successful by backtracking by 1 match, that rule's queued error messages are automatically discarded. Therefore, using the <commit> directive along with the <error?> directive here is broken. If you guys have any other suggestions, let me know. Maybe Damian, you could enable a <commit> directive to propagate up the rule stack so it forces a failure of the parse? Since your primary use of <commit> was to prune the parse, maybe another directive like <hard_error?> could be used to force the failure of the rule and all of its calling parents regardless of any repetition specifiers? :) Dave Mc --- Marcel Grunauer <[email protected]> wrote: > On Donnerstag, Februar 7, 2002, at 02:14 Uhr, > damian wrote: > > > Usually by "anchoring" the end of the match. That > might be: > > > > myrule: 'stuff' mysubrule(?) ...!ID > > it seems necessary to return a { 1 } here, as the > rule > fails otherwise, presumably because of the negative > lookahead: > > myrule: 'stuff' mysubrule(?) ...!ID { 1 } > > > mysubrule: ID <commit> '[' ']' > > | <error?> <reject> > > > > or > > > > myrule: 'stuff' mysubrule(?) /\s*\Z/ > > > > mysubrule: ID <commit> '[' ']' > > | <error?> <reject> > > > > > > or whatever addition confirms that there really > wasn't anything else > > after 'stuff'. > > another option would be the use of a rulevar: > > myrule : <rulevar: local $failed> > myrule : 'stuff' mysubrule(?) <reject:$failed> > > mysubrule: ID <commit> '[' ']' > | <error?> { $failed++ } > > this way you don't have to specify a potentially > complex negative > lookahead, and the method works over several levels > of subrules > as well. > > marcel > > __________________________________________________ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com