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.
Tags:
also see handouts page 104...there is another possibility..
Handouts page frm where i took help are 109,and 113...check them..and inform me whether m right or wrong??..
Topic : Three-Address statement types...
check hint in it which is like a<b..
ys chked...
u r wrong.
chk that attached idea solution in my previous comments.our type checking is right and
follow rules given lecture 38 under ur mentioned topic.
INt and BooL can't be conditional statements.
ok..lemme make final solution..then will share..
In fact " INT " and BOOL are types..we can't apply jumps on these.
assignmnet ker li app ne mjuye se ni hui can u help me salma iqbal
E ---->CONST {E.type= INT ;}
| ID {E.type =getType (ID.name) ;}
| E1 +E2 {E.type=INT ;}
| E1 +E2 {if ((E1.type==INT&& E2.type==INT))
E.type==INT;
else
E.type==BOOL;//error
}
| E1< E2 {E.type=BOOL ;}
| E1< E2 {if ((E1.type== BOOL && E2.type== BOOL))
E.type== BOOL;
else
E.type== INT; //error
}
| E1= =E2 {E.type=BOOL ;}
| E1= =E2 {if ((E1.type== BOOL && E2.type== BOOL))
E.type== BOOL;
else
E.type== INT; //error
}
Still its incomplete solution..Confusion regarding ID is stil there and lso regarding | (E1)...@sny2ksa..Is this correct solution??
No,its not correct according to me...
still rules are missing in it..you are just printing errors.
if any one else can say about it..most welcome.
at least we will be able to submit it .
:-( koi kar day uplod .............sny2ksa ager koi mistak ha ti identify karo na plzzzzzz
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post