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 4045892
In Process

The Archive Base Latest Questions

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

Working through this for fun: http://www.diku.dk/hjemmesider/ansatte/torbenm/Basics/ Example calculation of nullable and first uses a

  • 0

Working through this for fun: http://www.diku.dk/hjemmesider/ansatte/torbenm/Basics/

Example calculation of nullable and first uses a fixed-point calculation. (see section 3.8)

I’m doing things in Scheme and relying a lot on recursion.

If you try to implement nullable or first via recursion, it should be clear you’ll recur infinitely on a production like

N -> N a b

where N is a non-terminal and a,b are terminals.

Could this be solved, recursively, by maintaining a set of non-terminals seen on the left hand side of production rules, and ignoring them after we have accounted for them once?

This seems to work for nullable. What about for first?

EDIT: This is what I have learned from playing around. Source code link at bottom.

Non terminals cannot be ignored in the calculation of first unless they are nullable.

Consider:

N -> N a
N -> X
N -> 

Here we can ignore N in N a because N is nullable. We can replace N -> N a with N -> a and deduce that a is a member of first(N).

Here we cannot ignore N:

N -> N a
N -> M
M -> b

If we ignored the N in N -> N a we would deduce that a is in first(N) which is false. Instead, we see that N is not nullable, and hence when calculating first, we can omit any production where N is found as the first symbol in the RHS.

This yields:

N -> M
M -> b

which tells us b is in first(N).

Source Code: http://gist.github.com/287069

So … does this sound OK?

  • 1 1 Answer
  • 1 View
  • 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-20T13:29:35+00:00Added an answer on May 20, 2026 at 1:29 pm

    I suggest to keep on reading 🙂

    3.13 Rewriting a grammar for LL(1) parsing and especially 3.13.1 Eliminating left-recursion.

    Just to note you can run into indirect left recursion as well:

    A -> Bac
    B -> A
    B -> _also something else_
    

    But the solution here is quite similar to eliminating the direct left recursion as in your first example.

    You might want to check this paper which explains it in a little bit more straight-forward way. Less theory 🙂

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

Sidebar

Related Questions

I am working through this tutorial -> http://ruby.railstutorial.org/chapters/filling-in-the-layout You can experience the problem here
I am currently working through this tutorial: Getting Started with jQuery For the two
I am working through this tutorial https://developers.google.com/cloud-print/docs/android for google cloud print. I am trying
I'm looking through some code for learning purposes. I'm working through this portion of
I've been working through the tutorials on this webpage which progressively creates a bootloader
I'm working through the Demo: Binding Data with the SqlDataSource of this pluralsight video
I'm working through the NerdDinner MVC tutorial and came across this and was wondering
I am working through Beginning iPhone Development . In the book is this method:
I send email through Outlook using VB.Net 2005; this is working fine. At the
I'm working my way through K&R's 2nd edition, and I've been stumped with this

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.