Answered step by step
Verified Expert Solution
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:
decllist decllist ; decl decl
decl simpledeclstructureddecl
simpledecl type varlist
structureddecl type varnum idnum means an array whose size is
given by num.val
type integer real
varlist var, varlist var
var
a 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:
categorysimplestructured
elementtype 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, inserttype, insertsize, and insertlink with appropriate parameters.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started