Homework Assignments for CSC 415

Spring 2005

 

 

 

Homework 1:

 

a. Using the context-free grammar of Mini-Triangle on pages 8 and 9 in the textbook, draw syntax trees for the following Mini-Triangle code segment:

 

if x > y then

      let const xcopy – x

      in

                  begin x := y; y := xcopy end

else

 

b. Using the grammar specificying the abstract syntax of Mini-Triangle, draw the abstract syntax tree for the following Mini-Triangle code segment:

 

let

      const taxable ~ if income > allowance

                              then income – allowance

                              else 0

in

      taxable / 4

 

Homework 2:

 

a. Assume that you have the following: a machine M; a C compiler that runs on machine M and generates machine code M; and a Java-into-C translator expressed in C.  Use tombstone diagrams to represent these language processors.  Also show how you would use these language processors to:

 

compile and run a program P expressed in C;

compile the Java-into-C translator into machine code;

compile and run a program Q expressed in Java.

 

b. The Triangle language processor (see Section 2.7 in textbook) is expressed entirely in Java.  Use tombstone diagrams to show how the compiler, interpreter, and disassembler would be made to run on machine M.  Assume that a Java-into-M compiler is available.

 

Homework 3:

 

The Mini-Triangle source program below would be compiled to the object program listed.

 

            Source Program                       Object Program

 

Let                                           PUSH  1

  const m ~ 7;                           LOAD 7

  var x: Integer                          LOAD 0[SB]

in                                              CALL mult

  x := m * x                               STORE    0[SB]

                                                            POP     1

                                                            HALT

Describe the compilation in the same manner as Examples 3.1, 3.2, 3.4 in the textbook.  (You may ignore the generation of the PUSH and POP instructions.)

 

Homework 4:

 

a. Perform syntactic analysis of the Mini-Triangle program:

 

            begin while true do putint (1); putint (0) end

 

along the lines of Figures 4.1 through 4.4 in the textbook.

 

b. The micro-English parser (Example 4.11 in textbook) generates some sentences, such as ‘I sees the cat.’, that are ungrammatical in English itself.  Modify the grammar to ensure that th esugject agrees with the verb.  ‘I’ should agree with ‘like’ or ‘see’, and other subjects should agree with ‘is’ or ‘sees’.


Homework 5:

 

Become familiar with the Triangle compiler.

Requirements Analysis Peer Review Report

Requirements Analysis Document

Weekly Progress Report

 

Homework 6:

Technical Specification Document Peer Review Report

Technical Specification Document

Development Schedule and Plan

Weekly Progress Report

 

Homework 7:

Test Plan Peer Review Report

Test Plan

Code Peer Review Report

Weekly Progress Report

 

Homework 8:

Test Results Report

Working System Demonstration

Weekly Progress Report

 

Homework 9:

Source Code with Documentation

User's Manual Peer Review Report

User's Manual

Weekly Progress Report