Code Examples and Reading Assignments

This page documents what we do in class. It contains Java programs that we will discuss in class, reading assignments from our textbook, simple homework exercises that you can work on for practice and exam preparation (not for credit), and links to other sources of information.

The reading assignments and practice problems are listed by the date on which they were assigned. The sample program files are listed by the date on which they were used. You can click on a .java link and see the source code. When you are viewing the source code, you can use your browser's "File -> Save As..." menu item to save a copy of the file on your computer.

  • Wednesday, December 8.
    • The following zip file contains an example that shows how to implement a unary minus operator in Antlr.
    • The following zip file contains all of the languages that we worked on this semester.
  • Monday, December 6.
    • See the homework page for your seventh homework assignment. This assignment replaces the "final exam" mentioned in the course syllabus.
    • The following zip file contains an Antlr grammar and client program that demonstrate the kinds of errors you can get in an Antlr build process.
    • The following zip file contain several Antlr grammars and tree grammars that demonstrate some of the standard techniques for writing Antlr actions using token and rule attributes.
    • The following zip file contains an implementation of an infix version of Language-4 (from earlier in the semester). This implementation uses Antlr to write an infix "front end" to our previous tree walking AST interpreter.
  • Monday, November 29.
    • The following zip file contains an Antlr parser grammar and tree grammar for an infix version of Language-2 (from earlier in the semester). The zip file also contains four "hand written" recursive descent parsers for this language. The goal of Antlr is to automate the writing of these kinds of parsers.
    • The following zip file contains an Antlr parser grammar and tree grammar for Language-2. This is an Antlr implementation of the same language we did earlieer in the semester, with Scheme-like, S-expression syntax.
  • Monday, November 22.
  • Monday, November 8.
  • Monday, November 1.
    • See the homework page for your sixth homework assignment.
    • Language-10t adds type checking to Language-10.
  • Monday, October 25.
  • Wednesday, October 20.
    • Language-14 cleans up the syntax from Language-13 and fixes two inconsistencies in that language.
  • Monday, October 18.
    • Language-13 adds anonymous functions (or, function literals) to Language-12.
  • Wednesday, October 13.
    • The following implementation of Language-11 is in C++. Since the C++ runtime does not have a garbage collector, this implementation of Language-11 allows us to really see the difference between Language-11 (which doesn't need a garbage collector; all environments can be allocated on the runtime stack) and Language-12 (which must have a garbage collector for the environments).
    • Here is a Scheme file that shows how closures can be used to emulate Object Oriented Programming.
  • Monday, October 11.
  • Wednesday, October 6.
  • Monday, October 4.
    • See the homework page for your fifth homework assignment.
    • Here is a Scheme file with examples of nested function, function parameters, and function return values.
    • Here is a handy list of the languages that we are defining in this course.
  • Wednesday, September 29.
    • Here is a handy list of the languages that we are defining in this course.
    • Language-10 modifies language Language-9 to have static scope (rather than dynamic scope).
  • Monday, September 27.
  • Wednesday, September 22.
    • See the homework page for your fourth homework assignment.
    • Language-8 modifies language Language-7 so that the functions are first class objects in the new language.
  • Monday, September 20.
  • Monday, September 13.
    • See the homework page for your third homework assignment.
  • Wednesday, September 8.
    • For next Monday, read Chapter 5, Sections 5.1-5.2 (pages 101-107) and Chapter 6, Sections 6.1-6.3 (pages 131-141) from our textbook.
    • The following zip file contains files that define a language of "binary expressions with global variables". This language adds variables to the language Language-3.
    • The following zip file contains files that define a language of "binary expressions with local variables and nested scopes". This language has exactly the same syntax as Language-4. What changes is the semantics of the language.
    • The following zip file contains files that define a language that adds one new term to the previous language and fixes a limitation in that language.
    • Read the following web page to see a "real world" discussion of the limitation that the last language deals with.
  • Wednesday, September 1.
    • See the homework page for your second homework assignment.
    • For next Wednesday, read Chapter 4, Sections 4.1-4.2 (pages 73-83) from our textbook.
    • The following zip file contains files that define a language of "binary expression trees". This language is a subset of the language of binary trees, but it is a subset to which we can attach meaning (semantics). In the zip file is an interpreter which assigns a meaning (in this case, a value) to each binary expression tree.
    • The following zip file contains files that extend the language of binary expression trees by adding another data type to the language, boolean values. The second homework assignment will be based on this and the previous example.
  • Monday, August 30.


Return to the CS 50200 home page.


compliments and criticisms