Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Semantic Analysis (30) Consider programs consisting of two parts (a) The first part has only one function declaration: functionName(parameterList) where functionName is an identifier (i.e.,

Semantic Analysis

image text in transcribed

image text in transcribed

image text in transcribed

(30) Consider programs consisting of two parts (a) The first part has only one function declaration: functionName(parameterList) where functionName is an identifier (i.e., a sequence of letters) and parameterList is of the form type id1, type id2, ..., type idn, where type is int or bool, and idi's are identifiers. An example of a function declaration is f(int x, bool y) (b) The second part has only a function call of the form functionName(argumentlist) where argumentlist is of the form idi, id2, ..., idn where idi's are identifiers. For example, f(x, z) An example program is f(int x, bool y) f(x, z) Questions. b) We would like to introduce two attributes name and number for the non- terminal symbol in your CFG that defines the function declaration. The former has a value of the function name and the latter means the number of arguments of the function. Similarly we introduce name and number for the non-terminal sym- bol in your CFG that defines the function call. The former takes, as its value, the name of the function and the latter takes, as its value, the number of arguments in the function call. Write an attribute grammar for such programs using the given attributes (and aux- iliary attributes you may need)

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

=+What forms of industrial action are common?

Answered: 1 week ago