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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:08:05+00:00 2026-05-31T07:08:05+00:00

I need to implement compiler (lexical, syntax and semantic analyzers). I have already implemented

  • 0

I need to implement compiler (lexical, syntax and semantic analyzers).
I have already implemented the lexical from flex++, syntax from hand (recursive descent),
and know I’m working on semantic (adding semantic rules to the existing parser).
My question is – how do I implement attributes.
For example, for production:

TYPE -> integer

I need to add semantic rule:

TYPE.type = integer

So here I need to create some structure for TYPE, and so on for all the grammar symbols.
So how do I implement that structures? Do I need to make some struct for each grammar symbol and it need to be global for scope of file?

p.s. maybe it is not the best compiler implementation, it is just requirment for assignment.

  • 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-31T07:08:07+00:00Added an answer on May 31, 2026 at 7:08 am

    It is easiest if you define a type (typically a struct) for each terminal and nonterminal in your language. Then each use of a (non)terminal has access to the type, and each assignment of an attribute goes against the corresponding slot in the structure associated with (non)terminal.

    I suggest you name your implementation structures after the grammar tokens. So, the type of the attribute structure for T would be “T_attributes { … } “

    For your example, “type” would be a slot in the T_attributes. Probably what you meant to write in the abstract was:

    TYPE -> 'integer' ;  -- 'integer is a keyword'
    TYPE.type = "int";   -- the type of an 'integer' is "int"
    

    Given you are doing this by hand, you will hand-compile the attribute assignment to execute when a tree walk hits the TYPE node.

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

Sidebar

Related Questions

In order to implement a tiny compiler that emits ECMAScript I need to know
I need to implement inter type declarations in a java compiler. Can anyone tell
I need to implement an idl-to-java compiler. In fact, it's not idl-to-java. Interface definition
I need to implement a custom handler for MVC that gives me the first
I need to implement login velocity checking for a web service. The service is
I need to implement Integrated Windows Authentication for a WCF service hosted on IIS
I need to implement a SOAP Web Service on Jboss Seam 2.1.0. The idea
I need to implement handling of redelivery of JMS messages in the application that
I need to implement threading to improve load time in a compact framework app.
I need to implement behavior of my UIViewController subclass like in standart iPod.app: when

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.