www.vustudents.ning.com

# CS606 Assignment No 04 Solution & Discussion Due Date:05-02-2013

Question No 1: Marks 20
Consider the following grammar productions. Suppose you have an attribute E.type which can
be set to either INT, BOOL. Assume that the type of an expression is set to INT if an error is
detected and you have a routine msg() similar to printf() that can be used to print error
message.
E → CONST {E.type=??}
| ID {E.type =getType(ID.name);}
| E1 +E2 {E.type=??}
| E1< E2 {E.type=??}
| E1= =E2 {E.type=??}
| (E1) {E.type=??}
You are required to add rules to the attribute grammar to calculate E.type for each grammar
production.

Views: 2255

Attachments:

### Replies to This Discussion

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.

kindly guide me.

from which lecture is this assignment..?

Lecture 38..

what i can understand in it that this assignment relates to "type checking".

but still don't know the solution.

it can be like this.

 | E1< E2 {E.type=BOOL}

but what will be next.

having no idea.

kindly share yout ideas.

come all,will discuss and solve it.

| E1= =E2                                         {E.type=ASSIGNMENT}

IS this true?

yes it is...

then | E1+E2 should also be BOOLEAN??

it seems.will confirm u soon

ok..in handouts on Page 111 expression E---> (E1) has beenn mentioned..bt not getting it..kindly confirm it too..Is this also boolean??

actually i am not according to scheduled lectures and started late to work on this assignment.let me listen lecture first.

ok i am also working on it..@Sweet Heart..plzz confirm it 100%...:)

1

2

3

4

5

## Latest Activity

Mifa Fadel joined + M.Tariq Malik's group

### PSY406 Educational Psychology

9 minutes ago
Mifa Fadel joined + M.Tariq Malik's group

### ETH201 Ethics (for Non-Muslims)

10 minutes ago
ǟʍռǟ ɮɦǟƭƭɨ updated their profile
13 minutes ago
Mifa Fadel joined + M.Tariq Malik's group

### ENG201 Business and Technical English Writing

13 minutes ago
Mifa Fadel and Palwashy joined + M.Tariq Malik's group

### ENG506 World Englishes

16 minutes ago
Mifa Fadel and Palwashy joined + M.Tariq Malik's group

### ENG503 Introduction to English Language Teaching

17 minutes ago
Palwashy and Mifa Fadel are now friends
26 minutes ago
Mifa Fadel and Chaudhary Faizy are now friends
34 minutes ago