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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:27:24+00:00 2026-05-26T22:27:24+00:00

I am implementing a compiler for a school class and I have some problems

  • 0

I am implementing a compiler for a school class and I have some problems on how to proceed.
Lexical analysis is already made. Lexical analysis to me is that I have a function that returns token objects and also prints some errors that can be inspected during lexical analysis.

The token holds id, string (if the current id is a string, if not it is null), number (if the token is a number, if not it is null) and the line where the token found.

I want to make the syntax analysis but i am not sure if i have to generate a syntax tree during this procedure. I am sure that this will be necessary while generating intermediate code but the teacher leaves the decision to us.

So to end. The teacher want us to understand that it is necessary?
If it is really necessary what is the best way to construct a syntax tree?
Also am i missing something that will cause me trouble in later stages?

  • 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-26T22:27:24+00:00Added an answer on May 26, 2026 at 10:27 pm

    Basically, your syntax analysis will end up being some form of a finite-state machine. The result of this process is usually an AST; the syntax analysis seems somewhat pointless if you don’t store the result of it somewhere.

    While there are many different well-known and established algorithms for creating the state tables and for implementing the actual processor, you might want to start thinking like the compiler and define your states by hand (which is feasible for really simple languages):

    • At the very beginning, what tokens would be acceptable? (Start state)
    • Each token will lead you to another state and possibly have you perform an operation to consolidate your tokens into an abstract syntax tree. (State transitions)
    • I suggest to treat “End of file” as a special token returned by the tokenizer, so that your syntax analysis doesn’t need any special code to handle the end of file (just normal state transition dealing with the EOF token).

    Note that, instead of using tables, you can also use functions to represent your states.

    What is the language you’re trying to implement?

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

Sidebar

Related Questions

I have to implement template specialization, in implementing the constructor for specialized template class
I'm new to C++ and I have this problem that the compiler is throwing
Working on a web application and implementing a class called Calculator that calculates certain
Possible Duplicates: How can a language's compiler be written in that language? implementing a
I'm having some trouble implementing pure virtual functions inherited from some abstract class, when
I have this interface and a class implementing it: interface Scraper { string DateToUrl(DateTime
I'm having problems implementing IEnumerable<T> in my custom collection class in C++/CLI. Here is
I have two Java interfaces and one implementing class. (I have used Eclipse to
I did see on internet some pattern for implementing singleton class as following: class
Given that a class actually is moveable , manually implementing the move constructor and

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.