Re: Feature wishlist for P::RD 2.0 ore perhaps 1.81

[email protected] (Karl Gaissmaier)
Newsgroups perl.recdescent
Message-ID <[email protected]>
Hi Yves, (sorry Mr. Orton)

> > > salutation : /Mrs?/ first_name last_name
> > > first_name : /(?!Mrs?)\S+/
> > > last_name  : /\S+/
> > >
> > > Or using lookahead matches
> > >
> > > salutation : 'Mr' ...!'Mrs'
> > >            | 'Mrs' ...!'Mr'
> >
> > but this works only for terminals
> 
> No, using lookahead matches applies to nonterminals as well.  But you're
> (sortof) correct about the regex solutions.

sure, I was speaking about the regex solution not the lookahead

> 
> >and this is again not what
> > I need. I've choosen Mr and Mrs as subrule names just for an easy
> > demonstration what is needed, but in general this is necessary
> > for subrules:
> >
> > exor    : subrule-1 ^ subrule-2 ^ subrule-3
> > subrule-1: subrule-11 ^ subrule-12 ....
> 
> Umm, ok now maybe im confused, but I would go with Marco on this.  This is
> exactly the same as
> 
> option  : optlist
> optlist : rule1 | rule2 | rule3
> rule1   : subrule1 | subrule 2
> 
> Optlist may now only match 1 of rule1 rule2 or rule3, and likewise if it
> does match rule1 it may only be subrule1 or subrule2.
> 
> I believe the impact of changing the above to
> 
> option  : optlist(s)
> optlist : rule1 | rule2 | rule3
> rule1   : subrule1 | subrule 2
> 
> which allows any selection of the rule1 is causing you problems.  It is the
> rule option that allows multple optlist elements to be chosen, not optlist
> itself.

no, you didn't really catch my problem. I'll try it again:

option : optlist(s)
optlist: ip | pw 
ip     : 'ipaddr' '=' value
pw     : 'passw'  '=' value
value  : /".*?"/

then the input:
ipaddr = "10.0.0.1";
passw  = "private";

or

ipaddr = "10.0.0.1";

or

passw = "private";

should succeed but not

ipaddr = "10.0.0.1";
passw  = "private";
ipaddr = "192.168.10.1"

and I see no chance to do this without {action code}.
It could be done with:

option : optlist(s)
optlist: ip ^ pw 
ip     : 'ipaddr' '=' value
pw     : 'passw'  '=' value
value  : /".*?"/

that means any of the options ip or pw but not any option more than
one time. The wish is not so strange, you will stumble over it when
you try for example to write a parser for named or dhcp cfg files,
and of course in my config files for network management.

regards
	Charly

-- 
Karl Gaissmaier          Computing Center,University of Ulm,Germany
Email:[email protected]          Network Administration
Tel.: ++49 731 50-22499
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.