SPARK
Scanning, Parsing, and Rewriting Kit
John Aycock
Department of Computer Science
University of Calgary
aycock@ucalgary.ca
SPARK stands for the Scanning, Parsing, and Rewriting Kit. It formerly
had no name, and was referred to as the "little language framework."
The first version (circa 1998) was described in the paper
Little Languages in Python at the 7th International Python
Conference.
SPARK is written in 100% pure
Python,
and is made available as
open source.
- 19 May 2009: I should clarify that. SPARK is in the Python
distribution in the "Parser" source directory,
not in the Python library. This means that you
can't just import it directly, unfortunately.
- 26 June 2007: John DeGood pointed out that SPARK is in the
Python distribution now – yay!
- 02 March 2006: added a link to Andrea Mocci's elcc project
on SourceForge.
- 26 August 2002: David Mertz' Charming Python column
looks at SPARK in
this
article.
- 14 May 2002: SPARK version
0.7 pre-alpha-7 is available. It fixes a scanner bug that
manifested itself when a pattern matched zero characters (not an
especially practical thing to do before pre-alpha-6 was released
yesterday!).
- 13 May 2002: SPARK version
0.7 pre-alpha-6 is available, which adds a method to
GenericScanner to get and set the scanner's position.
- 16 February 2002: SPARK version
0.7 pre-alpha-5 is available. This version should work
properly with Python 2.2.
- 26 November 2001: A
Japanese translation of the IPC7 paper is available,
thanks to Yasuhiro Osawa.
- 01 November 2001: SPARK version
0.7 pre-alpha-4 is available for testing. This version fixes
a bug which could arise under an obscure set of circumstances.
- 19 September 2001: it looks like Python's garbage collector can
really kill off the performance of 0.7pre3; brilliant
solutions are, as always, welcome!
- 14 September 2001: another alpha
pre-release, version 0.7 pre-alpha-3, is available for testing.
- 29 August 2001: an alpha pre-release, version 0.7 pre-alpha-2,
is available for testing. (Finally!)
- 27 April 2000: Version 0.6.1 released,
to fix a bug in GenericParser.
- 13 April 2000: Version 0.6 released.
Mostly bug fixes, and parser performance improvements.
- 02 February 2000: some new features (including speed enhancements)
are coming in the next major version, but they fall under the heading
of "research" so I won't commit myself to a release date
yet. Problems reported in the current release:
- I broke the ordering guarantee when doing reflection, which
should only affect you if you're subclassing scanners.
Thanks to Gordon McMillian and Richard White for pointing
this out.
- Nicky Sandhu reports that a slight modification is required
to get things working with JPython. I will verify this
before the next release.
If the next major release is delayed I may issue a minor release
to fix these problems and get some of the less-radical changes
distributed.
- 20 October 1999: Version 0.5 released.
Major changes include scanner speedups and a proper ambiguity-resolution
mechanism. (I haven't included the VHDL example since it needs some
changes to work with the latest version, sorry!)
- 20 August 1999: Coming attractions in the next release, which
I expect to be late September-October, will include:
- Some new examples, including a contributed VHDL parser
from Jan Decaluwe.
- Enhancements and speedups to the scanner class, thanks to Tim
Peters.
- The reflection mechanism used by GenericScanner and
GenericParser will follow the usual inheritance rules,
so t_ and p_ methods can be overridden properly.
- 11 May 1999: Version 0.4 released. New classes for
automagic tree building
and tree pattern matching.
- 15 March 1999: a PDF version of my paper
is available, thanks to Darrell Gallion.
- 04 February 1999: Version 0.3 released.
- 29 January 1999: Much to my surprise, empty rules seem to
work properly -- sorry for any inconvenience this may
have caused. Also, the next release (next week?) will
include a parser for Python.
- 19 January 1999: Version 0.2 released.
Currently, the documentation is in two parts. The distribution contains
a copy of both parts.
- The IPC7 paper describes the early version of SPARK.
- The release notes document changes and
enhancements, as well as hints and caveats.
- The latest version (0.6.1).
Please note: this version has not been updated for
some time; I strongly recommend you use
SPARK version 0.7 pre-alpha-7
instead. Despite the "pre-alpha" status, it's been
used for years successfully.
Problems uncompressing? Some people have downloaded one of the
.gz files above, only to have it be un-unzippable. Seems that
some browsers do you the favor of automagically uncompressing the file for
you, but neglect to rename it! So if GNU Zip complains about the file,
check to see if it's already uncompressed.
These are some projects I know of which have used SPARK, in no
particular order. Please let me know of any that I've missed!
I've used it for a compiler for Guide,
compiling a subset of Java, an experimental type inferencer for Python,
and probably a few other things I've forgotten.
People who have helped me out by sending suggestions, patches,
and/or large sums of money in small unmarked bills:
- Jan Decaluwe
- Paul Dubois
- Mike Fletcher
- Darrell Gallion
- Kevin Jacobs
- Nick Mathewson
- David Mertz
- Gordon McMillan
- Amit J. Patel
- Tim Peters
- François Pinard
- Eric S. Raymond
- Dickon Reed
- Nicky Sandhu
- Richard White
Early work on SPARK was supported in part by development of Guide.
Legalese
SPARK is not
affiliated in any manner with any
other project or product which uses the name "SPARK", including
but not limited to:
- SPARK
- SPARK
- SPARK
- SPARK
- SPARC
(For Heaven's sake, this
one isn't even spelled the same way! If someone can't tell the
difference, they probably shouldn't be doing anything as exacting
as writing software.)