For each of the run time environments (static, stack or dynamic) describe some component of a language that requires the run time environment. Also mention the language you are referring to.
List all the tokens in the C declaration/initialization from the question above.
[5 pts]
Why is this grammar for simple expressions considered ambiguous? Be sure to explain how a parse tree is used in defining ambiguity, or show an example.
E → E + E | E * E | ( E ) | |
[5 pts]
Language design criteria.
[10 pts]
Explain how the “readability” and “writability” criteria may be in conflict.
How does Java support the “portability” criterion?
Assume a language contains a set of simple data types and the standard 6 relational operators and we said the language was highly “orthogonal”, what do we mean?
Put these modules of a compiler in order of theoretical data flow:
Assume language L contains and infinite number of elements and the patterns of those elements are,
{ ab, ac, aab, aac, aaab, aaac, aaaab, aaaac,……, abc, abd, acc, acd, abcc, abcd, abdc, abdd. accc, accd,…},
That is, a string of a’s, followed by a ‘b’ or ‘c’, followed by a string of c’s and d’s in any order.
[15 pts]
a) Give a regular expression to define this language:
b) Draw a FSM from this regular expression
c) Write a corresponding BNF grammar limited to the form AxB | y
FSM
BNF
Give an example programming language that represents the language paradigm and a short reason why you chose the language to represent it.
Assume the set of productions representing simple algebraic expressions.
[20 pts]
S ® V := E
E ® E + T | T
T ® T * F | F
F ® V | ( E )
V ® i | j | k
The alphabet or set of terminals is ____________________________________ [3]
The set of nonterminals is ___________________________________ [3]
The start symbol is ____________ [2]
Show a top down derivation for j := i + k * j starting with the start symbol. [5]
Draw the corresponding parse tree. [5]
Derivation
Parse tree
f) Was your derivation leftmost? ______ (it wasn’t required to be) [2]
What is a coercion? What happens in C when assigning reals to integers?
[4 pts]
Describe how a Java program is executed in terms of the various layers of software and hardware necessary to accomplish it. Consider the JVM, what it’s written in, operating system support and the hardware instruction set.