Calvin seal CS 382: Special Topics - Compilers
Fall 2004

Unit Testing & ANTLR

This document assumes that you're using Eclipse and the ANTLR and JUnit plugins. (Eclipse comes with JUnit; the ANTLR plugin must be installed separately.) I've written some support code to make unit testing with ANTLR a little easier. The examples presented here make use of this library.

Three Products from ANTLR

We will use ANTLR to generate three things for us: a scanner (a.k.a. lexer), a parser, and a tree parser. The scanner turns a character stream into token; the parser turns the token stream into an ANTLR abstract syntax tree (AST); the tree parser turns the ANTLR AST into our own AST.

In this document, I'll walk through writing these three things, unit testing along the way, for spreadsheet equations.