1 / 8

Homework #1

Homework #1. J. H. Wang Oct. 4, 2011. Homework #1. Chap.1 1.8 1.11 Chap.2 2.1 (a) 2.2 (a) 2.4 2.5 (a). Chap.1

blake
Télécharger la présentation

Homework #1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Homework #1 J. H. Wang Oct. 4, 2011

  2. Homework #1 • Chap.1 • 1.8 • 1.11 • Chap.2 • 2.1 (a) • 2.2 (a) • 2.4 • 2.5 (a)

  3. Chap.1 • 1.8: Most programming languages, such as C and C++, are compiled directly into the machine language of a “real” microprocessor (for example, an Intel x86 or Sparc). Java takes a different approach. It is commonly compiled into the machine language of the JVM. The JVM is not implemented in its own microprocessor, but is instead interpreted on some existing processor. This allows Java to be run on a wide variety of machines, thereby making it highly platform independent.Explain why building an interpreter for a virtual machine like the JVM is easier and faster than building a complete Java compiler. What are the disadvantages of this virtual machine approach?

  4. 1.11: C is sometimes called the universal assembly language in light of its ability to be very efficiently implemented on a wide variety of computer architectures. In light of this characterization, some compiler writers have chosen to generate C code as their output instead of a particular machine language. What are the advantages to this approach to compilation? Are there any disadvantages?

  5. Chap.2 • 2.1(a): Based on the grammar in Figure 2.1, construct the parse tree for the following input:(a) i x x=100 x=x+30+1 p x • 2.2: For the above input in Exercise 2.1(a), (a) Construct the input’s AST.

  6. 2.4: The CFG shown in Figure 2.1 defines the syntax of ac programs. Explain how this grammar enables you to answer the following questions.(a) Can an ac program contain only declarations (and no statements)?(b) Can a print statement precede all assignment statements?

  7. 2.5: Sometimes it is necessary to modify the syntax of a programming language. This is done by changing the CFG that the language uses. What changes would have to be made to ac’s CFG (Figure 2.1) to implement the following changes?(a) All ac programs must contain at least one statement.

  8. Submission • Submission • Hand-written exercises: hand in your paper version in class • Programming exercises: to be announced • Due: two weeks (Oct. 18, 2011)

More Related