Assignment 9

Due Date: 2015-3-29, 11:59pm


This is another two part assignment. The first part will continue looking at the Jack "OS" by implementing the library methods that draw things to the screen. The second part will be the first component of the compiler: the tokenizer/scanner.

Part I: Jack OS Pixels

Write Jack code that implements the following two libraries.
  • Output
  • Screen
Each class will be compiled and tested in isolation. Like String and Keyboard last time, these classes need to be tested interactively by comparing your implementation's output to the provided screenshot gif. When you run into an error condition, you should call Sys.error with the appropriate error code.

Part II: Tokenizer/Scanner

The tokenizer will break up the string of characters that represents the entire file into specific tokens.

You are given 4 test programs, located in the Data910 folder. You will use these again in the next assignment.

  • 1_ExpressionlessSquare (a non-functioning version of the Square program from last week, without expressions)
  • 2_Square (Square!)
  • 3_ArrayTest (Check for the Array Syntax as well as String literals)
  • 4_Quadratic Equation (Tests complex expressions, else statements, and a few other things)
For each of these program, you are given multiple files. The .jack files are the source files (i.e. Square.jack). You are also given the desired output for the tokenizer (SquareT.xml). The folder also contains the desired parser output (Square.xml) which you will use next week.

The code for generating the XML is included in the provided source files, as long as you fill out the given data structures. The are main method in the tokenizer will output the XML for the Jack file passed in as input. However, there is also the BigAssignment9 test file, which, given any list of folders and jack files, will find all jack files therein, and tokenize each, and say whether your output matches. Your outputs will be written to files with the "my" prefix, i.e. mySquareT.xml.

To compare your output to the given output, Linux/Mac users can use the command-line tool diff. Windows users can use TextComparer.bat, included with cse365bin. I also highly recommend visual diff tools, like meld.


This assignment requires you to write code. Stubs for Java and Python are provided in your repos. Your code will be run with one of the following commands:

  • Java - java JackTokenizer Something.jack
  • Python - python Something.jack
  • C/C++ - ./jack_tokenizer Something.jack


  • The token definitions are listed at the top of the Jack API
  • The XML output is already implemented, and you shouldn't need to adjust it.
  • Once again, you do not have to check for errors.
  • Unlike previous coding assignments, this assignment has no flexibility in the output. The output of your tokenizer and parser must match those given.