Results 1 to 5 of 5

Thread: why there will be ambiguous grammar?

  1. #1
    Eager!
    Join Date
    Oct 2007
    Posts
    31
    Rep Power
    6


    Good post? Yes | No

    why there will be ambiguous grammar?

    hi, all
    I know what's the ambiguous grammar, but i am not clear why there will be ambiguous grammar? in other words, what's the essential reason that leading the ambiguous grammar?

    thanks!

  2. #2
    TestMagic Guru CalmLogic's Avatar
    Join Date
    Feb 2006
    Posts
    2,133
    Rep Power
    16


    Good post? Yes | No
    I don't know if this answers your question, but here is a practical example:

    For example, in C the following:

    x * y ;

    can be interpreted either as the declaration of an identifier y of type pointer to x, or as an expression in which x is multiplied by y and the result is discarded. To choose between the two possible interpretations, a compiler must consult its symbol table to find out whether x has been declared as a typedef name that is visible at this point.

    Ambiguous grammar - Wikipedia, the free encyclopedia

  3. #3
    Trying to make mom and pop proud
    Join Date
    Sep 2007
    Posts
    23
    Rep Power
    6


    Good post? Yes | No
    An ambiguous grammar is a grammar that generates a language L and there exist one word w in L such that there are 2 or more different possible parsings for it.

    For example

    S-> SS | 0

    is ambiguous. The string 000 is part of the generated language and can be parsed 2 different ways:
    1. S->SS -> 0 S -> 0 S S-> 0 0 S -> 0 0 0
    2. S->SS -> SS S -> 0 S S-> 0 0 S -> 0 0 0

  4. #4
    Eager!
    Join Date
    Oct 2007
    Posts
    31
    Rep Power
    6


    Good post? Yes | No
    i know this, but actually I'd like to ask how to determine one grammar is an ambiguoius grammar, such like your example, S-> SS|0 the only method is just to illustrate an example? if the grammar is very complicated, then maybe we can not obtain an example soon

  5. #5
    Eager!!
    Join Date
    Oct 2007
    Posts
    28
    Rep Power
    6


    Good post? Yes | No
    Recognizing an ambiguous grammar

    The general question of whether a grammar is ambiguous is undecidable. No algorithm can exist to determine the ambiguity of a grammar because if so, the undecidable halting problem could be encoded as an ambiguity problem.

    Inherently ambiguous languages

    While some languages (the set of strings that can be generated by a grammar) have both ambiguous and unambiguous grammars, there exist languages for which no unambiguous grammar can exist. An example of an inherently ambiguous language is the union of {a^nb^mc^md^n | n,m > 0} with {a^nb^nc^md^m | n,m > 0}. This is context-free, since it is a union of context-free languages, but Introduction to Automata Theory... contains a proof that there is no way to unambiguously parse strings in the (non-context-free) subset {a^nb^nc^nd^n | n > 0} which is the intersection of the two languages.


    frm WIKI

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Do you think that the question is ambiguous?
    By computer-bot in forum GRE Math
    Replies: 4
    Last Post: 10-10-2008, 05:47 PM
  2. Ambiguous CS question
    By windriver in forum GMAT Critical Reasoning
    Replies: 5
    Last Post: 07-31-2007, 06:23 PM
  3. Ambiguous wording?
    By zednom in forum GMAT Problem Solving
    Replies: 3
    Last Post: 08-26-2006, 02:50 PM
  4. Ambiguous they
    By lilmorethan740 in forum GMAT Sentence Correction
    Replies: 2
    Last Post: 11-09-2005, 12:29 PM
  5. Ambiguous question
    By aivoges in forum TOEFL Grammar
    Replies: 3
    Last Post: 04-12-2004, 10:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO ©2010, Crawlability, Inc.