pattern matching source code
Francois-Rene Rideau
Francois-Rene Rideau <fare@tunes.org>
Sat Apr 20 11:42:01 2002
Dear Tunesers,
I'm not doing much, but I happy to say that not much is strictly positive.
I've just written a pattern matcher for Common Lisp,
that brings you the power of Erlang/ML pattern matching.
More interestingly, I also reimplemented quasiquote in a way such
that you can use it to match source code, which makes it a fine tool
to use as the starting point of a compiler
(with the limitation that since the pattern-matcher still can't backtrack,
you can only use ,@ in terminal position).
The pattern-matcher still with rough edges, as far as exceptional situations
go -- i.e., error messages are minimal at best, and there are even a few
situations where things that shouldn't be allowed are; also, the or pattern
doesn't play as well with bindings as it should.
In any case, you can find it all down there:
file://bespin.org/~fare/fare/lisp/
http://tunes.org/cgi-bin/cvsweb/fare/fare/lisp/
Useful files are
fare.lisp [1.20] Many CL utilities
matcher.lisp [1.13] The core of the pattern matcher
quasiquote.lisp [1.1] `, using and externing the p.m.
fare-clos.lisp [1.2] silly CLOS macros
In brackets are a set of CVS release numbers known to work fine together
(not forcibly the latest and most featureful, but at least, they work).
Note that if you match source code with ` and , and ,@ you don't need
even know that the underlying implementation uses lists anymore --
actually, if you only ever deconstruct source code by matching backquote
patterns, and never use them to construct or deconstruct lists,
then you can abstract away from the underlying representation and change it.
PS: a cartoon sadly relevant to Tunes:
http://www.dilbert.com/comics/dilbert/archive/images/dilbert2002457060404.gif
Yours freely,
[ François-René ÐVB Rideau | Reflection&Cybernethics | http://fare.tunes.org ]
[ TUNES project for a Free Reflective Computing System | http://tunes.org ]
The trouble with opportunity is that it always comes disguised as hard work.
-- Herbert V. Prochnow