Compilers (CS362 2002F)



Summary: In today's lab, you will explore the translation of Stupid, Sam's Totally Unintelligble Program Instruction Doohicky, to PAL, the pseduo-assembly language that I've written (okay, started to write) as an intermediate language for your compilers.

Warning: Stupid, the Stupid translator, PAL, and this lab are under development. All of them probably have many bugs. Let me know which ones you notice.

Collaboration: Feel free to work on this lab in pairs or trios.

Turning It In: You do not need to turn in this lab. It is intended primarily for your edification.

Grading: Since you're not going to turn it in, I'm not going to grade it (not that I usually grade things anyway).

Supporting Files:


Make a copy of the Stupid directory. For example, you could execute the following instruction.

% cp -r /home/rebelsky/Web/Courses/CS362/2002F/Examples/Stupid .


Stupid, Sam's Totally Unintelligible Programing Instruction Doohicky, is a sample programming language I've written (okay, that I'm writing) as an example of various issues we've discussed in class. You can learn about the syntax of the language from You should be able to figure out the meaning of most parts of the language from the grammar.


Exercise 1: Stupid Basics

a. Scan through the programs in the Examples subdirectory. See if you can determine what each one should do.

b. Execute each in turn with

% java Stupid Examples/____.stupid

Exercise 2: Adding Operations

Update the translateExpression method in to handle subtraction, multiplication, and division in addition to addition.

Test your changes.

Exercise 3: Coercion

a. Update the translateAssignment method in so that it coerces from integers to reals and from reals to integers. You should find the PAL instruction I2F and F2I useful.

b. Update the translateExpression method in so that it coerces from integers to reals whentever an operation is applied to an integer and a real.



Monday, 2 December 2002 [Samuel A. Rebelsky]

  • Designed.

Tuesday, 3 December 2002 [Samuel A. Rebelsky]

  • Wrote.
  • Released.


Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Tue Dec 10 08:53:35 2002.
The source to the document was last modified on Tue Dec 3 09:15:00 2002.
This document may be found at

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Glimmer Labs: The Grinnell Laboratory for Interactive Multimedia Experimentation & Research