Homework Assignments for CSC 415
Spring 2004
1.1 Using the context-free grammar of Mini-Triangle on pages 8 and 9 in the textbook, draw syntax trees for the following:
a. x * y + z – 3 / 5
b. if x then y else z
c. let vasr x: Integer in x := x + y – 3
1.2 Using the grammar specificying the abstract syntax of Mini-Triangle, draw the abstract syntax tree for the following:
a. x * y + z – 3 / 5
b. if x then y else z
2.1 Assume that you have the following: a machine M; a C compiler that run 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:
a. compile and run a program P expressed in C;
b. compile the Java-into-C translator into machine code;
c. compile and run a program Q expressed in Java.
2.2 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.
3.1 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.)
4.1 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.
4.2 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’.
Become familiar with the Triangle compiler.
Become familiar with the Triangle compiler.
Become familiar with the Triangle compiler.
Requirements Analysis Peer Review Report
Requirements Analysis Document
Technical Specification Document Peer Review Report
Technical Specification Document
Working System Demonstration
Source Code with Documentation
User's Manual Peer Review Report
User's Manual