Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 861309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:57:32+00:00 2026-05-15T08:57:32+00:00

I did not understand how a unambiguous grammar is derived from a ambiguous grammar?

  • 0

I did not understand how a unambiguous grammar is derived from a ambiguous grammar? Consider the example on site: Example. How was the grammar derived is confusing to me.

Can anyone please guide me ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:57:33+00:00Added an answer on May 15, 2026 at 8:57 am

    The example has two grammars:

    Ambiguous:

    E → E + E | E ∗ E | (E) | a
    

    Unambiguous:

    E → E + T | T
    T → T ∗ F | F
    F → (E) | a
    

    The unambiguous grammar was derived from the ambiguous one using information not specified in the ambiguous grammar:

    • The operator ‘*’ binds tighter than the operator ‘+’.
    • Both the operators ‘*’ and ‘+’ are left associative.

    Without the external information, there is no way to make the transformation.

    With the external information, we can tell that:

    a * a + b * b
    

    is grouped as if written:

    (a * a) + (b * b)
    

    rather than as:

    a * ((a + b) * b)
    

    The second assumes that ‘+’ binds tighter than ‘*’, and that the operators bind from right to left rather than left to right.


    Comment

    How would associativity come into the picture for examples like:

        S → aA | Ba
        A → BA | a
        B → aB | epsilon
    

    This is an ambiguous grammar, so how to go about converting it to unambiguous?

    I wonder if the ‘epsilon’ is ε, the empty string; let’s analyze the grammar both ways.

    ε is the empty string

    The rule for B says a B is either an empty string or an a followed by a valid B, which amounts to an indefinitely long string of 0 or more a’s.

    The rule for A says an A is either an a or a B followed by an a. So, an indefinitely long string of a’s could be an A too. So, there is no way for the grammar to choose whether a string of a’s is either an A or B.

    And the rule for S is no help; an S is either an a followed by an indefinitely long string of a’s or an indefinitely long string of a’s followed by an a. It requires at least one a, but any number of a’s from one upwards is OK, but the grammar has no basis to decide between the left and right alternatives.

    So, this grammar is inherently ambiguous and cannot, in my estimation, be made unambiguous; it certainly cannot be made unambiguous without other information not in our possession.

    ε is not the empty string

    What about if ε is not the empty string?

    • B is either ε or an aε.
    • A is either an a or a B followed by an a (so either an a or an aε or an aaε).
    • Either: S is an a followed by an A (hence aa, aaε, or aaaε)
    • Or: S is a B followed by an a (hence εa or aεa).

    In this case, the grammar is unambiguous as it stands (though not necessarily LR(1)). Clearly, a lot hinges on the meaning of ‘epsilon’ in the comment/question.

    Associativity

    I don’t think associativity affects this grammar. It generally comes into play with infix operators (such as the ‘+’ in ‘a + b’).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There was an interesting question in a practice test that I did not understand
Lot of googling did not help me! Are there any good dictionary web based
Just could not get this one and googling did not help much either.. First
I create a new Button object but did not specify the command option upon
I have some code which I did not originally create that uses _beginthreadex and
I searched and found this question but did not like the answer. Is there
According to MSDN : If you did not use the Start method to start
If you do not know what Pipe Viewer is (I did not know about
I was asked a question in C last night and I did not know
After being troubled by an issue that I simply did not have the knowledge

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.