Re: question on directive <commit> and subrules

[email protected] (Marcel Grunauer)
Newsgroups perl.recdescent
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.