Java Reference
In-Depth Information
4. Cross-compilation assumes that a compiler for language X exists on some
machine. When the first compiler for a new language is created, this
assumption does not hold. In this situation, a bootstrapping approach
can be taken. First, a subset of language X is chosen that is su
cient to
implement a simple compiler. Next, a simple compiler for the X subset
is written in any available language. This compiler must be correct, but
it should not be any more elaborate than is necessary, since it will soon
be discarded. Next, the subset compiler for X is rewritten in the X subset
and then compiled using the subset compiler previously created. Finally,
the X subset, and its compiler, can be enhanced until a complete compiler
forX,writteninX,isavailable.
Assume you are bootstrapping C
or Java (or some comparable lan-
guage). Outline a suitable subset language. What language features
must be in the language? What other features are desirable?
++
5. To allow the creation of camera-ready documents, languages like TeXand
LaTeX have been created. These languages can be thought of as varieties
of programming languages whose output controls a printer or display.
Source language commands control details like spacing, font choice,
point size, and special symbols. Using the syntax-directed compiler
structure of Figure 1.4, suggest the kind of processing that might occur
in each compiler phase if TeX or LaTeX input was being translated.
An alternative to “programming” documents is to use a sophisticated ed-
itor suchas that provided inMicrosoft R
to interactively enter and edit the document. (Editing operations allow
the choice of fonts, selection of point size, inclusion of special symbols,
and so on.) This approach to document preparation is called WYSI-
WYG —what you see is what you get—because the exact form of the
document is always visible.
What are the relative advantages and disadvantages of the two ap-
proaches? Do analogues exist for ordinary programming languages?
Word orAdobe R
FrameMaker R
6. Although compilers are designed to translate a particular language, they
often allow calls to subprograms that are coded in some other language
(typically, Fortran, C, or assembler). Why are such “foreign calls” al-
lowed? In what ways do they complicate compilation?
 
Search WWH ::




Custom Search