Re: Need simple parser/interpreter - reinvent the wheel?

Andrew Cooke <andrew@andrewcooke.free-online.co.uk>
3 Jun 2000 17:34:05 -0400

          From comp.compilers

Related articles
Need simple parser/interpreter - reinvent the wheel? pld@fc.hp.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? andrew@andrewcooke.free-online.co.uk (Andrew Cooke) (2000-06-03)
Re: Need simple parser/interpreter - reinvent the wheel? peter@abbnm.com (2000-06-03)
| List of all articles for this month |

From: Andrew Cooke <andrew@andrewcooke.free-online.co.uk>
Newsgroups: comp.compilers,comp.lang.misc
Date: 3 Jun 2000 17:34:05 -0400
Organization: Deja.com - Before you buy.
References: 00-05-125
Keywords: parse

Hi,


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


Andrew





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.