[DGD] Re: parse_string() and ambiguity

Erwin Harte harte at is-here.com
Fri Oct 24 22:10:29 CEST 2003


On Fri, Oct 24, 2003 at 03:57:49PM -0400, S. Foley wrote:
> Consider the following (incomplete and useless) grammar:
> 
> word = /[a-zA-Z]+/
> 
> ...
> 
> SENTENCE : SUBJECT PREDICATE
> SUBJECT : word
> PREDICATE : word
> 
> I'm under the impression that this grammar is already ambiguous.  That is to
> say, any production rule that contains more than 1 production rule symbol on
> the right side (of the ':') is ambiguous because there's nothing to indicate
> the order in which the production rules should be applied.  Is this correct?

But there is only one way to match the tokens to the rules and that's
what is what you're talking about with respect to 'ambiguous'.

This would be ambiguous:

    SENTENCE : SUBJECT PREDICATE
    SENTENCE : PREDICATE SUBJECT
    SUBJECT : word
    PREDICATE : word

> I ask because many of the example grammars I've seen tend to use multiple
> production rule symbols on the right side of a production rule, and I've
> started to wonder whether I'm mistaken on this point.

I think you are.

Erwin.
-- 
Erwin Harte <harte at is-here.com>
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list