Metalinguistic capability of Python?

Neel Krishnaswami neelk at brick.cswv.com
Sun May 7 12:26:01 EDT 2000


Courageous <jkraska1 at san.rr.com> wrote:
> 
> I'm looking to create a simulation environment (using stackless
> Python & continuations) that would need a pseudo simulation
> language to go along with it. In Lisp, I might make heavy use
> of macros in order to accomplish what I want. Is there any
> sane way to go about approaching this in Python, or is this
> a lost cause? (I don't believe that what I want to accomplish
> can be accomplished with methods or functions).

This is a lost cause -- Python has no macro system.

Depending on how badly you need it, you might want to look at John
Aycock's SPARK parsing system. It has a Python grammar as an example,
and you could probably subclass and extend it with the productions you
need, and then rewrite them into Python code.

If you want to build a generic language extension system for Python,
I'd recommend taking SPARK, and then implementing some of the ideas
described in the paper:

  Luca Cardelli, Florian Matthes, and Martín Abadi. Extensible syntax
  with lexical scoping. SRC Research Report 121, Digital Equipment
  Corporation Systems Research Center, February 21, 1994.

You can find it online at:
  
  http://research.microsoft.com/Users/luca/Papers/SRC-121.pdf


Neel



More information about the Python-list mailing list