6 Describe the form in which a program is passed from:
a The scanner to the parser.
b The parser to the semantic analyzer.
4.7 Here is a context-free grammar in BNF form:
expr --> expr + term | expr - term | term
term --> term * factor | term / factor | factor
factor --> ex ** factor | ex
ex --> (expr) | id
Rewrite this grammar in EBNF form.
4.8 What does this Scheme function do?
(define whatsThis
(lambda (n)
(cond((null? n) 0)
((null? (cdr n)) (car n))
((> (car n) (whatsThis (cdr n))) (car n))
( else (whatsThis (cdr n)))
)))
4.9 Give an example of an irregularity in a language with which you are familiar.
4.10 Would it ever make sense to write a program in one language, planning from the beginning to rewrite
the program later in a different language? Give an example of a situation in which such a plan might
make sense, and not simply result in wasted time and effort.
CHAP. 4] SOFTWARE 65
66
CHAPTER 5
Programming in Java
INTRODUCTION
Java is one of a great many computer programming languages in use today. Since it is a fairly new language,
having been first released in 1994 by Sun Microsystems, its design takes advantage of modern ideas about what
makes a good programming language. Historically, new programming languages have usually taken years to
become popular, but Java enjoyed unprecedented growth in popularity from the very day of its release.
Pages:
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186