0% found this document useful (0 votes)
15 views1 page

BNF Grammar and Programming Concepts Tutorial

This document contains 3 questions about programming language concepts. Question 1 asks about BNF grammar for integers and identifiers, parsing trees, and the advantages of extended BNF. Question 2 asks about information hiding in object-oriented programming, constructors and destructors, and friend functions and classes. Question 3 asks about bound variables in lambda expressions, evaluating lambda expressions, and applying lambda expressions.

Uploaded by

Ashvin Grace
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

BNF Grammar and Programming Concepts Tutorial

This document contains 3 questions about programming language concepts. Question 1 asks about BNF grammar for integers and identifiers, parsing trees, and the advantages of extended BNF. Question 2 asks about information hiding in object-oriented programming, constructors and destructors, and friend functions and classes. Question 3 asks about bound variables in lambda expressions, evaluating lambda expressions, and applying lambda expressions.

Uploaded by

Ashvin Grace
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Tutorial 1 Programming Language and Algorithm

Question 1
(a) If an integer is defined as one or more digits, write down the BNF grammar for the digit and the
integer.
(b) Using the BNF from part (a) draw the parse tree for an integer.
(c) Use the above to derive that a number 657 is an integer.
(d) Explain the advantages of the extended BNF over BNF. Use appropriate examples to illustrate
your answer.
(e) Write down your definition of an indentifier, its BNF grammar and derive that best1 is an
integer.

Question 2
(a) Explain how the concept of information hiding is implemented in an object oriented
programming language.
(b) Illustrate with appropriate examples the importance of constructors and destructors as member
function of a class.
(c) What are friend functions and classes and how are they important?
(d) What is an ADT and how is it used?

Question 3
a) What do you understand by bound variables in a lambda expression?
b) The lambda expression (x.+x 3) is applied to an expression (+y 3), what is the resulting
expression? Explain the details of the substitutions to arrive at your result.
c) Distinguish between the two expressions (x.*x x) and (y.*y y). What results do they produce
when the following are applied to them (i) the value 5, and (ii) the value (*x 5)?
d) What is the result when the expression (*x x) is applied to the the function y.([Link]) as follows
y.([Link]) (*x x)? Explain clearly all the steps of your substitutions.

You might also like