University of Texas at El Paso
Banner
Compuer Science
   
Assignment 1 Minimize    

Compilers and Interpreters: Assignment 1

September 5, 2008

In the first part of this class we will be building an interpreter for a simple robot control language.

In this assignment you will build an interpreter to handle the first subset.

The robot hardware accepts commands such as the following

!PN09  rotate 90 degrees left
!PN39  rotate 90 degrees right
!PN5X  move forward X
!PN7X  move backwards X
!PN101 face forward
!PN10E face right
!PN10C face left
!PX01  explode

where the value of X determines the distance moved, as follows

0 means 6 inches
1 means 12 
2 means 18 
3 means 24
4 means 36
5 means 48
6 means 60
7 means 72

The commands you are to implement this time are:

right
left
go N
back N
head left
head right
head forward
; 

N is a number of inches
; means that the rest of the line is a comment

Thus an example command sequence is:

; patrol a square foot
go 12
right
go 12
right
go 12
right
go 12

Here is a second example

; wander around some
go 36
right
go 12
right
go 24
right 
go 24
left
go 12
left
left
head left

The robot emulator code is available as a 7zip file at https://faculty.utep.edu/longpre (follow the menus from CS 4352, to assignments and to assignment 1.)

The main() method is in the class RE.

Due Thursday, September 17, at the start of class. Hand in:

  1. a printout of your revised Interpret.java,
  2. screenshots showing how it works on the two code fragments above,
  3. any documentation you think I should have.
ocumentation you think I should have. html>