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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:22:01+00:00 2026-06-02T03:22:01+00:00

Almost all compiler will return a line number along with error message. I am

  • 0

Almost all compiler will return a line number along with error message. I am wondering in compiler design perspective how does compiler handle line number message in terms of following different phases? thanks.

  • Scanner
  • Parser
  • AST data structure
  • Code generation

In additional:

  • Run time environment
  • Machine interpreter
  • 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-06-02T03:22:03+00:00Added an answer on June 2, 2026 at 3:22 am

    I have implemented a fairly simple compiler for my class assignment. It was a subset of Pascal with a few other limitations.

    Compiler is a tool that translates one language into another. It does that by performing error checking and then generates output code (if possible). Usually, the pipeline of a compiler is roughly equivalent to:

    Input Code -> Lexical Analyzer(Scanner) -> Syntax Analyzer -> Semantic
    Analyzer -> Code Generator -> Output Code *

    Since my language was simple I could make a bunch of assumptions e.g. an instruction will be only in one line. My Lexer used regular expressions to check for character that shouldn’t be there e.g. “Characters that are not numbers, letters, “(“, “,” “.” etc.” I read file into a list of strings where each string is a next line, so If I scan a line and find an error I return the index + 1 which is the number of the line.

    With the Syntax Analyzer (parser) that checks e.g. “If a variable name starts with a letter” the algorithm was similar.

    When I extended the parser I associated a token with the line in the code to return it in case of a error.

    I don’t know how modern compilers solve this problem but I can guess that is also some kind of association of AST and line number with mind that one AST could be in a few lines (well, that’s language dependent).

    With code generation compiler knows that the code is correct(to their knowledge) and the return error wouldn’t be about the code but rather that there is a problem with the compiler or the process(bug, not enough memory, cannot write to the location etc.).

    Runtime environments and machine interprets also could have compiler e.g. JIT but the error message return usually indicates bug in compiler or runtime, not the code.

    *Note that this is very simple model of 3 passes. Modern compilers have a lot more.

    EDIT: I found that AST have a field that indicates line number and a files for an error(for each node).

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

Sidebar

Related Questions

Almost all of the examples in the jQuery tutorials that I've read, usually use
Almost all of my JUnit tests are written with the following signature: public void
In almost all of my projects I have few files that are project wide
I noticed that almost all email messages I get do not embed images, but
I have tried almost all the solutions from SO but no success :(. I
I have carried the method here on almost all of the areas where I
I've been using px for almost all the measurement related styling, but I wanted
I'm buiding an HTML/jQuery site where almost all the content comes from remote JSON
I am using Zurb Foundation and it works great for almost all the browser
Backgroup: We are looking at SAS BI Dashboard. We have currently implemented almost all

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.