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

  • Home
  • SEARCH
  • 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 6930755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:29:20+00:00 2026-05-27T11:29:20+00:00

How do you identify whether a grammar is LL(1), LR(0), or SLR(1)? Can anyone

  • 0

How do you identify whether a grammar is LL(1), LR(0), or SLR(1)?

Can anyone please explain it using this example, or any other example?

X → Yz | a

Y → bZ | ε

Z → ε

  • 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-27T11:29:21+00:00Added an answer on May 27, 2026 at 11:29 am

    To check if a grammar is LL(1), one option is to construct the LL(1) parsing table and check for any conflicts. These conflicts can be

    • FIRST/FIRST conflicts, where two different productions would have to be predicted for a nonterminal/terminal pair.
    • FIRST/FOLLOW conflicts, where two different productions are predicted, one representing that some production should be taken and expands out to a nonzero number of symbols, and one representing that a production should be used indicating that some nonterminal should be ultimately expanded out to the empty string.
    • FOLLOW/FOLLOW conflicts, where two productions indicating that a nonterminal should ultimately be expanded to the empty string conflict with one another.

    Let’s try this on your grammar by building the FIRST and FOLLOW sets for each of the nonterminals. Here, we get that

    FIRST(X) = {a, b, z}
    FIRST(Y) = {b, epsilon}
    FIRST(Z) = {epsilon} 
    

    We also have that the FOLLOW sets are

    FOLLOW(X) = {$}
    FOLLOW(Y) = {z}
    FOLLOW(Z) = {z}
    

    From this, we can build the following LL(1) parsing table:

        a    b    z   $
    X   a    Yz   Yz  
    Y        bZ   eps
    Z             eps
    

    Since we can build this parsing table with no conflicts, the grammar is LL(1).

    To check if a grammar is LR(0) or SLR(1), we begin by building up all of the LR(0) configurating sets for the grammar. In this case, assuming that X is your start symbol, we get the following:

    (1)
    X' -> .X
    X -> .Yz
    X -> .a
    Y -> .
    Y -> .bZ
    
    (2)
    X' -> X.
    
    (3)
    X -> Y.z
    
    (4)
    X -> Yz.
    
    (5)
    X -> a.
    
    (6)
    Y -> b.Z
    Z -> .
    
    (7)
    Y -> bZ.
    

    From this, we can see that the grammar is not LR(0) because there is a shift/reduce conflicts in state (1). Specifically, because we have the shift item X → .a and Y → ., we can’t tell whether to shift the a or reduce the empty string. More generally, no grammar with ε-productions is LR(0).

    However, this grammar might be SLR(1). To see this, we augment each reduction with the lookahead set for the particular nonterminals. This gives back this set of SLR(1) configurating sets:

    (1)
    X' -> .X
    X -> .Yz [$]
    X -> .a  [$]
    Y -> .   [z]
    Y -> .bZ [z]
    
    (2)
    X' -> X.
    
    (3)
    X -> Y.z [$]
    
    (4)
    X -> Yz. [$]
    
    (5)
    X -> a.  [$]
    
    (6)
    Y -> b.Z [z]
    Z -> .   [z]
    
    (7)
    Y -> bZ. [z]
    

    The shift/reduce conflict in state (1) has been eliminated because we only reduce when the lookahead is z, which doesn’t conflict with any of the other items.

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

Sidebar

Related Questions

Is there any way to identify whether someone has refreshed the current page using
Is there any JS/CSS/jQuery magic I can work to identify whether the last visible
I am getting URLs like this: http://img23.example.com/images/j43j32k3.jpg And I need to identify whether it
I wanna know that how we can identify whether a page is redirecting to
What's the best heuristic I can use to identify whether a chunk of X
Can someone help me identify what the purpose of this unidentified syntax is. It
In PHP, I'm using an if statement to identify whether a user is logged
How to identify whether GPS is available in Windows Mobile Device. Can it be
Possible Duplicate: In javascript how can we identify whether an object is a Hash
I am using draggable and droppable features of jquery-ui. I need to identify whether

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.