|Need simple parser/interpreter - reinvent the wheel? email@example.com (2000-05-31)|
|Re: Need simple parser/interpreter - reinvent the wheel? William.H.Duquette@jpl.nasa.gov (2000-06-01)|
|Re: Need simple parser/interpreter - reinvent the wheel? firstname.lastname@example.org (Andrew Cooke) (2000-06-03)|
|Re: Need simple parser/interpreter - reinvent the wheel? email@example.com (2000-06-03)|
|From:||Andrew Cooke <firstname.lastname@example.org>|
|Date:||3 Jun 2000 17:34:05 -0400|
|Organization:||Deja.com - Before you buy.|
Well, you could use yacc to help write an interpreter or compiler for
C, but (1) yacc is taking a sledgehammer to crack a nut and (2) you're
left to implement the language in C, hardly famous for the ease with
which it parses text files.
It would be nice to have something much more specific - a package that
takes languages like yours ("languages that match patterns"). But I
don't know of anything like that.
So the best compromise seems to be a generic compiler compiler written
in a language that supports text processing. I'd suggest using the
Spark package in Python. At its simplest you extend a class by adding
a description of the grammar your language implements. Spark then
provides you with an AST (given some input in your program) and which
you can traverse in Python, using Python's regular expression support
to make this simple.
Spark is the language described in the "famous" paper "Compiling Little
Languages in Python"
More info at http://www.csr.uvic.ca/~aycock/python/content.html
Return to the
Search the comp.compilers archives again.