Review Questions
1. What are the design issues for names?
- Are names case sensitive?
- Are the special words of the language reserved words or keywords?
4. What is an alias?
a hindrance to readability because it allows a variable to have its value changed by an assignment to a different variable
5. Which category of C++ reference variable is always aliases?
union types
6. What is the l-value of a variable? What is the r-value?
l-value is an address of a variable
r-value is a variable’s value
7. Define binding and binding time.
binding is an association between an attribute and an entity, such as between a variable and its type or value, or between an operation and a symbol. Binding time is the time at which a binding takes place
15. What is the general problem with static scoping?
First, in most cases it allows more access to both variables and subprograms than is necessary. It is simply
too crude a tool for concisely specifying such restrictions. Second, and perhaps more important, is a problem related to program evolution. Software is highly dynamic-programs that are used regularly continually change
16. What is the referencing environment of a statement?
referencing environment of a statement is the collection of all variables that are visible in the statement
18. What is block?
Such variables are typically stack dynamic, so their storage is allocated when the section
is entered and deallocated when the section is exited
Problem set
1. Decide which of the following identifier names is valid in C language. Support your decision
Student & Student123
because no consist of special character and number at the first of names
2. What is l-value? Write a statement in C language which gives the compile time error “l-value required”.
The address of a variable is sometimes called its l-value
scanf(“%d”,num);
4. Why is the type declaration of a variable necessary? What is the value range of the int type variable in Java?
because it must include an initial value, byte
5. Approaches to building a lexical analyzer:
- Write a formal description of the token patterns of the language
using a descriptive language related to regular expressions. These
descriptions are used as input to a software tool that automatically
generates a lexical analyzer. There are many such tools available for
this. The oldest of these, named lex, is commonly included as part of
UNIX systems
- Design a state transition diagram that describes the token
patterns of the language and write a program that implements the
diagram
- Design a state transition diagram that describes the token
patterns of the language and hand-construct a table-driven
implementation of the state diagram
6. State transition diagram is a directed graph. The nodes of a
state diagram are labeled with state names.
The arcs are labeled with
the input characters that cause transitions among the states
8.a.Assuming static scooping, in the following, which declaration of x is the correct one for a reference to x?
b.Repeat part a, but assume dynamic scoping.
(a) i. Sub1
ii. Sub126
iii. Main
(b) i. Sub1
ii. Sub1
iii. Sub1
9. The differences between top-down and bottom-up parsers:
- Syntax analyzers are either top-down, meaning they construct
left most derivations and a parse tree in top-down order, which mean the
tree built from the root downward to the leaves
- Bottom-up meaning case they construct the reverse of a rightmost
derivation and a parse tree in bottom-up order, which mean the parse
tree is built from leaves upward to the root
Tidak ada komentar:
Posting Komentar