Compilers and Interpreters: Assignment 1
September 7, 2010
The purpose of this assignment is for you to start getting familiar with the
Triangle programming language.
In this assignment, you have to write a Triangle program that takes as input a line of
text, and transforms it into a palindrome by first forming the reverse of the line
and then concatenating the original line.
Here is the Triangle program that reverses a line, taken from our textbook, section B.9.
type Line ~
content: array 80 of Char
proc getline (var l: Line) ~
l.length := 0;
while \ eol() do
l.length := l.length + 1
proc putreversedline (l: Line) ~
let var i : Integer
i := l.length;
while i > 0 do
i := i - 1;
var currentline: Line
while \ eof() do
Due Thursday, September 16, at the start of class, or 11pm if sent by e-mail.
- a printout of your Triangle program,
- a printout of the TAM code produced by compiling your code,
- a printout or a screenshot of the result of running the program,
- any documentation you think I should have.