Hi John! 

I have written a (currently mostly defunct) compiler in Python for a 
specialized programming language. The parser may serve as an example 
for you.

Introduction:
http://freeode.berlios.de/

The parser:
https://svn.berlios.de/wsvn/freeode/trunk/freeode_py/freeode/simlparser.py

The method --- Parser._defineLanguageSyntax --- creates the Pyparsing 
object. There are gigantic amounts of (mostly correct) comments in 
the file. Excuse the bad English and the typos. The style is somewhat 
adapted to the IDE Pydev. 

The parser reads the program text (no scanner) and creates a tree 
structure from it. I call it AST or Parse Tree (I can't decide how to 
call it). This tree is used in subsequent passes of the compiler.

I use a modified version of Pyparsing where I fixed things that I 
considered bugs, and where I implemented some of my wishes:
https://svn.berlios.de/wsvn/freeode/trunk/freeode_py/freeode/third_party/pyparsing.py

Kind regards,
Eike.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to