Homework 1
CS 3411 - Programming Language Concepts - Fall '98
Due: 1:30pm Thursday 15 October
Got Questions? Try office hours, email or the class
newsgroup.
-
Answer the following questions based on Sebesta Ch 2 "Evolution of the
Major Programming Languages". You should be able to answer each question
in a couple of well-chosen paragraphs.
-
In your own words, what does the term "orthogonality" mean when
applied to programming language design?
-
What are the arguments for and against the idea of a typeless programming
language?
-
Many languages have been designed by a single individual, others
by committee. What's the best approach? Use historical examples to support
your argument.
-
Choose any language you are familiar with and briefly describe three
positive aspects and three negative aspects of the language design.
In other words, what did the designers do right and what did they do wrong?
-
Show that the following grammar is ambiguous and rewrite
it to eliminate ambiguity:
<S> -> <A>
<A> -> <A> + <A> | <id>
<id> -> a | b | c
-
Given the following grammar:
<assign> -> <id> := <expr>
<id> -> A | B | C
<expr> -> <expr> + <expr>
-> <expr>
* <expr>
-> ( <expr>
)
-> <id>
show a parse tree and a leftmost derivation for
each of the following sentences accepted by this grammar:
A := C * ( A * C + B )
A := A + ( B + ( C ) )
-
What language (set of strings) does the following grammar accept?
You can either describe the language "intuitively" using precise English
or use mathematical notation to describe the set of strings. (The word
"epsilon" means the empty string.)
<S> ->
( <S> ) <S> | epsilon
-
Show the token stream that a scanner would generate given the following
C program as input. (You should provide both the "lexeme" for the token
and a "lexical value" where appropriate.)
/* main if else 1.234 what does
this do? */
int main()
{
int x = 10;
printf( "Hello,
world! %d\n", x );
}
-
Describe the language generated by the following regular expressions
(e means epsilon):
((e|0)1*)*
0*10*10*10*
-
Describe the meaning of the C while and do-while
loops using operational semantics. In other words, translate the
while and do-while loops into a lower-level virtual machine that
has no loops but uses if (e) goto label to
implement looping.