Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following grammar for simple declarations: decl - list decl - list ; decl | decl decl simple - decl | structured - decl

Consider the following grammar for simple declarations:
decl-list decl-list ; decl | decl
decl simple-decl|structured-decl
simple-decl type var-list
structured-decl type var[num]// id[num] means an array whose size is
given by num.val
type integer | real
var-list var, var-list | var
var id
a)(10 marks) Write an attribute grammar to insert the type of the variables in the
symbol table. If it is an array you have to insert its elements type and its size in
addition to indicating that this variable is a structured variable.
(Hint: consider the type field in the symbol table as a structure that has the fields:
category(simple/structured),
element-type which includes simply integer or real in case of a simple
type, and includes the element type of an array (also integer or real) in
case of an array, and
size which includes the size of an array and null in case of simple types
you can also assume that you have the following semantic actions insert-
category, insert-type, insert-size, and insert-link with appropriate parameters.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Outlook 2023

Authors: James Holler

1st Edition

B0BP9P1VWJ, 979-8367217322

More Books

Students also viewed these Databases questions