Cramster.com - Homework Solutions, Lecture Notes, Exams, and Free Online Homework Help
Sign Up Now! Login Customer Support Cramster Blog
McAfee Secure sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams
Problem Solved.
    Home    
    Homework Help    
   Answer Board   
    Resources (Beta)    
   
Member's Topic Headline:

help me please

Know the answer? Have a better solution? Share it.
Get Help Now.
View homework problems
explained for free!
Member Testimonials

Question:

Advertisement:

Answer | Ask New Question | Customize Profile | Leaderboards | 
FAQ

Member's Avatar

Rookie
Karma Points: 0
Respect (83%):
Date Posted: 7/23/2008 4:38:23 PM  Status: Live
help me please
Course Textbook Chapter Problem
N/A N/A N/A N/A
Question Details:
 

Q3. Consider following the attribute grammar for simple declaration.    [15]

Your task is to define semantic rules for calculating the values of the attributes.

 

Grammar:

 

<dlist>    → <tspec> ID <rest>

<tspec> → int

<tspec> → float

<tspec> → char

<rest>     → ε

<rest>     → , ID <rest>

 

Terminal symbols:

   “ int   float   char ε ID   , “

 

Nonterminal symbols:

   <dlist> <tspec> <rest>

 

Start symbol:

    <dlist>

 

 

Answers:

Member's Avatar

Expert
Karma Points: 811
Date Posted: 7/24/2008 12:40:38 AM  Status: Live
Asker's Rating: Helpful   
Response:
first we will have to add attributes for sematics rules.

int.type = integer //integer
float.type = real // real number.
char.type = character // 1 byte chracter.



Here is list of semantic rules assosiated with each production.
<dlist> -> <tspec> ID <rest>
(i) <dlist>.type = <tspec>.type
(ii) ID.type = <dlist>.type
(iii) <rest>.type = <dlist>.type


<tspec> -> int

(i) <tspec>.type = int.type

<tspec> -> float
(i) <tspec>.type = float.type

<tspec> -> char

(i) <tspec>.type = char.type

<rest> ->
ε
..no rules

<rest> -> , ID <rest>

(i) <rest>[2].type = <rest>[1].type
(ii) ID.type = <rest>[1].type




By reading or posting messages on these forums, you are agreeing to the Answer Board's Terms of Service and Conduct (TSC).


About Cramster | Terms of Use | Privacy Policy | Contact Us | Press Room | Site Map | Support | Anti-Cheating Policy

Cramster.com is not affiliated with any publisher. Book covers, title and author names appear for reference only.
Copyright © 2008 Cramster, Inc.