{"id":154127,"date":"2023-08-02T14:53:11","date_gmt":"2023-08-02T09:23:11","guid":{"rendered":"https:\/\/www.gkseries.com\/blog\/?p=154127"},"modified":"2023-08-02T14:57:30","modified_gmt":"2023-08-02T09:27:30","slug":"consider-the-following-grammar-and-the-semantic-actions-to-support-the-inherited-type-declaration-attributes-let-%f0%9d%91%8b1-%f0%9d%91%8b2-%f0%9d%91%8b3-%f0%9d%91%8b4-%f0%9d%91%8b5-and","status":"publish","type":"post","link":"https:\/\/www.gkseries.com\/blog\/consider-the-following-grammar-and-the-semantic-actions-to-support-the-inherited-type-declaration-attributes-let-%f0%9d%91%8b1-%f0%9d%91%8b2-%f0%9d%91%8b3-%f0%9d%91%8b4-%f0%9d%91%8b5-and\/","title":{"rendered":"Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let \ud835\udc4b1, \ud835\udc4b2, \ud835\udc4b3, \ud835\udc4b4, \ud835\udc4b5, and \ud835\udc4b6 be the placeholders"},"content":{"rendered":"\n<p>Q. Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let \ud835\udc4b<sub>1<\/sub>, \ud835\udc4b<sub>2<\/sub>, \ud835\udc4b<sub>3<\/sub>, \ud835\udc4b<sub>4<\/sub>, \ud835\udc4b<sub>5<\/sub>, and \ud835\udc4b<sub>6<\/sub> be the placeholders for the non- terminals D, T, L or L1 in the following table:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Production rule<\/td><td>Semantic action<\/td><\/tr><tr><td>D \u2192 T L<\/td><td>\ud835\udc4b<sub>1<\/sub>.type = \ud835\udc4b<sub>2<\/sub>.type<\/td><\/tr><tr><td>T \u2192 int<\/td><td>T.type = int<\/td><\/tr><tr><td>T \u2192 float<\/td><td>T.type = float<\/td><\/tr><tr><td>L \u2192 L1 , id<\/td><td>\ud835\udc4b<sub>3<\/sub>.type = \ud835\udc4b<sub>4<\/sub>.type addType(id.entry, \ud835\udc4b<sub>5<\/sub>.type)<\/td><\/tr><tr><td>L \u2192 id<\/td><td>addType(id.entry, \ud835\udc4b<sub>6<\/sub>.type)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Which one of the following are the appropriate choices for \ud835\udc4b<sub>1<\/sub>, \ud835\udc4b<sub>2<\/sub>, \ud835\udc4b<sub>3<\/sub> and \ud835\udc4b<sub>4<\/sub>?<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>(A) \ud835\udc4b<sub>1<\/sub> = \ud835\udc3f , \ud835\udc4b<sub>2<\/sub> = \ud835\udc47, \ud835\udc4b<sub>3<\/sub> = \ud835\udc3f<sub>1<\/sub>, \ud835\udc4b<sub>4<\/sub> = \ud835\udc3f<\/td><td>(B) \ud835\udc4b<sub>1<\/sub> = \ud835\udc47 , \ud835\udc4b<sub>2<\/sub> = \ud835\udc3f, \ud835\udc4b<sub>3<\/sub> = \ud835\udc3f<sub>1<\/sub>, \ud835\udc4b<sub>4<\/sub> = \ud835\udc47<\/td><\/tr><tr><td>(C) \ud835\udc4b<sub>1<\/sub> = \ud835\udc3f , \ud835\udc4b<sub>2<\/sub> = \ud835\udc3f, \ud835\udc4b<sub>3<\/sub> = \ud835\udc3f<sub>1<\/sub>, \ud835\udc4b<sub>4<\/sub> = \ud835\udc47<\/td><td>(D) \ud835\udc4b<sub>1<\/sub> = \ud835\udc47 , \ud835\udc4b<sub>2<\/sub> = \ud835\udc3f, \ud835\udc4b<sub>3<\/sub> = \ud835\udc47, \ud835\udc4b<sub>4<\/sub> = \ud835\udc3f<sub>1<\/sub><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Solution: <\/p>\n\n\n\n<p>The correct answer is X<sub>1<\/sub>\u00a0= L, X<sub>2<\/sub>\u00a0= T, X<sub>3<\/sub>\u00a0= L<sub>1<\/sub>, X<sub>4<\/sub>\u00a0= L<\/p>\n\n\n\n<p>According to Inherited attribute definition, an attribute is inherited if the attribute value of a parse-tree node is determined from attribute values of its parent and siblings.<\/p>\n\n\n\n<p>So, semantic rules should be as following below:<\/p>\n\n\n\n<p>D \u2192 TL {L.idtype = T.stype}<\/p>\n\n\n\n<p>T \u2192 int {T.stype = int}<\/p>\n\n\n\n<p>T \u2192 float {T.stype = float}<\/p>\n\n\n\n<p>L \u2192 L1, id {L1.itype = L.itype}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addtype(id.entry, L.itype)<\/p>\n\n\n\n<p>L \u2192 id addtype(id.entry, L.itype)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q. Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let \ud835\udc4b1, \ud835\udc4b2, \ud835\udc4b3, \ud835\udc4b4, \ud835\udc4b5, and \ud835\udc4b6 be the placeholders for the non- terminals D, T, L or L1 in the following table: Production rule Semantic action D \u2192 T L \ud835\udc4b1.type = \ud835\udc4b2.type T \u2192 int T.type [&hellip;]<\/p>\n","protected":false},"author":419,"featured_media":154128,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[5141],"tags":[5140],"class_list":["post-154127","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gate","tag-gate-questions"],"_links":{"self":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts\/154127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/users\/419"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/comments?post=154127"}],"version-history":[{"count":1,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts\/154127\/revisions"}],"predecessor-version":[{"id":154129,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts\/154127\/revisions\/154129"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/media\/154128"}],"wp:attachment":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/media?parent=154127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/categories?post=154127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/tags?post=154127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}