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

The Archive Base Latest Questions

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

I am writing a compiler for a compiler design course that I am taking

  • 0

I am writing a compiler for a compiler design course that I am taking and I am currently at the Syntax Analysis where I need to write a parser.

I need to have the FIRST and FOLLOW sets to handle any errors that may appear in the source text. I have precalculated the FIRST and FOLLOW sets for all of the non-terminals in my grammar but I am having trouble deciding where I should actually encode them inside of my program.

Should I place them in a map where the key is the name of the non-terminal?

Any advice would be helpful

This post may seem a little unclear, I can clarify any points if needed.

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

    If you want to keep them, you want to attach them to the nonterminals they represent. You probably also want an inversion, e.g., a map from set members back to the nonterminals of which they are the FIRST or FOLLOW.

    Then you error recovery routine can use previous or more likely the “next” input token (that’s the one which caused you report an error) to decide what you might insert into the input stream instead.

    I don’t actually store these. I use a GLR parser, whose parse tables are essentially LALR parse tables, and simply build a recursive algorithm to crawl over the tables to see what tokens might allow the parser to proceed. Indirectly, I’m taking advantage of FIRST and FOLLOW, since those were used to construct the parse tables.

    If you are taking a compiler design course, I’m recommend focusing on the post-parsing issues. You can sink tons of time into trying to “patch up” the source in response to an error, and all you’ll learn is that a) this is hard, and b) nobody will particularly like the choice you offer them. You can spend energy on syntax repair until you’re blue in the face but I’d wait until somebody asked you to do it for a job. In the meantime, for a compiler class, I’d let my compiler simply say, “Syntax error on line N” and abort.
    Crummy but good enough to let you get on with the more interesting part.

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

Sidebar

Related Questions

I'm taking a compiler-design class where we have to implement our own compiler (using
I'm currently writing a compiler for a small language that compiles to JavaScript. In
I'm writing a compiler which uses C as an intermediate code which is (Currently)
I'm writing a compiler in C and need to get the ASCII value of
I've heard of the idea of bootstrapping a language, that is, writing a compiler/interpreter
I am experimenting with writing a toy compiler in ocaml. Currently, I am trying
I'm writing a compiler that generates Jasmin code and want to invoke a method
I'm in my first year of Computer Sciences and I have to design a
I am writing a compiler for a c-like language. Currently, the compiler supports arrays
I am currently writing a compiler for a big subset of java and i

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.