JTopDowner /

Filename Size Date modified Message
27 B
8.6 KB
2.2 KB
166 B



A top-down recursive descent library in Java originally written as a university assignment for a programming paradigms class.


This small library was written in Java as an introduction to top-down parsing. It was originally prototyped by me in Ruby to serve as a mock up for this version. However I quickly saw the greater potential Ruby had for a library of this sort since Ruby can leverage metaprogramming and literal data structures such as the Hash and more flexible Array. Thus the Ruby version of this code, though much more raw, is more concise and elegant, something which I regard quite highly. Later in semester, I will be rewriting this library a third time in Racket.

While Dr. Smith is positive that we well be as frustrated by Racket as I was with Java, I'm confident that the list and associative list literals in Racket will be sufficient that a large portion of the evil hard-coded recognizers, and particularly, the first() function will be implemented in a much sleeker and sexier way.


Grab the repo:

hg clone

Or for the git inclined: git clone git://

Then just drop it into your project tree. If you want to build it using the accompanying Rakefile simply type: rake at the command line. Note that this requires a ruby interpreter.


Add a Grammar by defining an implementation of the Grammar interface then in your running code create an instance of Parser specifying that grammar. Then just pass it strings and have fun!

The files and are Copyright Dr. Jeff Smith of San Jose State University and may not be used or reproduced without explicit permission.

All other classes, methods, comments, and disparaging remarks about the Java language are Copyright 2011 Steven! Ragnarök and made available under the GPLv3.

A warning to all students: DO NOT USE THIS CODE TO CHEAT. Please use it to learn more about recursive descent parsing but if you copy this code without citing it, eventually karma will bite you in the ass. Just sayin'.