Re: How to resolve ambiguity?

Derk Gwen <derkgwen@HotPOP.com>
2 Jan 2004 03:40:40 -0500

          From comp.compilers

Related articles
How to resolve ambiguity? idht@yahoo.com (2003-12-27)
Re: How to resolve ambiguity? snicol@apk.net (Scott Nicol) (2004-01-02)
Re: How to resolve ambiguity? derkgwen@HotPOP.com (Derk Gwen) (2004-01-02)
Re: How to resolve ambiguity? snicol@apk.net (Scott Nicol) (2004-01-02)
| List of all articles for this month |
From: Derk Gwen <derkgwen@HotPOP.com>
Newsgroups: comp.compilers
Date: 2 Jan 2004 03:40:40 -0500
Organization: Quick STOP Groceries
References: 03-12-143
Keywords: parse
Posted-Date: 02 Jan 2004 03:40:40 EST

# <struct-type> ::= <type-name>
# | <simple-type>


# <class-type> ::= <type-name>
# | object
# | string


# Could somebody explain why they provide a grammar like that
# and how my parser-compiler is supposed to handle that
# to not be ambiguous?


Don't try to write a context sensitive grammar with a context free notation.


Presumably somewhere you have something like
        <type> ::= <struct-type> | <class-type> | <scalar-type> | ...
If so, instead doing something like
        <type> ::= <type-name> | <struct-type> | <class-type> | <scalar-type> | ...
        <struct-type> ::= <simple-type>
        <class-type> ::= <object> | <string>


Your grammar is trying to make a context-sensitive constraint, whether the
type-name was defined as struct-type or class-type. In the context free
grammar at most you would know it was a type-name, not what kind.


C does have an ambiguity in the language (and so in all grammars) with
type-names, but not this.


--
Derk Gwen http://derkgwen.250free.com/html/index.html


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.