> yes that's what I want. I know that the solution could be the
> permutation of the pieces but this blows up the grammar with n!.

Sure does... :-)
 
> > however, what you're talking about is a semantic validation 
> of input,
> > something which usally happens after parsing and hence isn't dealt
> > with by grammars.
 
Well, thats not quite correct.  Its not that uncommon for parsers to handle
some semantic validation during the parser phase.  Especially recursive
descent ones.

> hmm, I'm not sure that this is semantik. The semantik is, that the
> value of email could be used in a To: field, but the required pieces
> are still syntax, as we can see that this could be done with permuting
> the pieces.

Yes, but that syntax is not context-free.  And as I said and Marco implied
parsers can only directly handle context-free grammars (and P::RD can only
handle a subset of CFG's due to it being a recursive descent parser anyway
:-)
 
> > 
> > >
> > > And the following would also be sometimes useful:
> > >
> > >   exor : Mr ^ Mrs ^ hybrid


Hmm, again (afaict) as presented this is a non-context-free constraint.

But with a bit of gymnastics you can do this with P:RD using regexes:

salutation : /Mrs?/ first_name last_name
first_name : /(?!Mrs?)\S+/
last_name  : /\S+/

Or using lookahead matches

salutation : 'Mr' ...!'Mrs'
           | 'Mrs' ...!'Mr'

Cheers,
Yves

Reply via email to