3. | The following program undergoes scope checking using a stack of symbol tables: 1. void main() { 2. 5. 6. 7. 8. int a; int b%3B int c%;B if (a == b) { float c%;B for (int c = 1; c <10%;B c++ ) { cout << a; 9. } 10. } 11. 12. 13. int a; else { } /* else */ } /* main */ (a) [10] Draw the symbol tables created for this program as follows: List in each sym- bol table all the identifiers in that scope as pairs (identifier,type). Then draw the links (pointers) between the symbol tables that establish the stack structure. (b) [5] Let the scope checking algorithm process line 8 of the program. Identify in your answer to the previous question the symbol table corresponding to the current scope as well as the symbol tables corresponding to all the open scopes. Explain then how are the symbol tables inspected to obtain the type of variable a.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question
3.
| The following program undergoes scope checking using a stack of symbol tables:
1.
void main() {
2.
5.
6.
7.
8.
int a; int b%3B int c%;B
if (a == b) {
float c%;B
for (int c = 1; c <10%;B c++ ) {
cout << a;
9.
}
10.
}
11.
12.
13.
int a;
else {
} /* else */ } /* main */
(a) [10] Draw the symbol tables created for this program as follows: List in each sym-
bol table all the identifiers in that scope as pairs (identifier,type). Then draw the links
(pointers) between the symbol tables that establish the stack structure.
(b) [5] Let the scope checking algorithm process line 8 of the program. Identify in your
answer to the previous question the symbol table corresponding to the current scope as
well as the symbol tables corresponding to all the open scopes. Explain then how are
the symbol tables inspected to obtain the type of variable a.
Transcribed Image Text:3. | The following program undergoes scope checking using a stack of symbol tables: 1. void main() { 2. 5. 6. 7. 8. int a; int b%3B int c%;B if (a == b) { float c%;B for (int c = 1; c <10%;B c++ ) { cout << a; 9. } 10. } 11. 12. 13. int a; else { } /* else */ } /* main */ (a) [10] Draw the symbol tables created for this program as follows: List in each sym- bol table all the identifiers in that scope as pairs (identifier,type). Then draw the links (pointers) between the symbol tables that establish the stack structure. (b) [5] Let the scope checking algorithm process line 8 of the program. Identify in your answer to the previous question the symbol table corresponding to the current scope as well as the symbol tables corresponding to all the open scopes. Explain then how are the symbol tables inspected to obtain the type of variable a.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning