How to write a language parser ?

Timothy Madden terminatorul at gmail.com
Fri Feb 22 17:29:42 CET 2013


Hello

I am trying to write a DBGp client in python, to be used for debugging 
mostly php scripts.

Currently the XDebug module for php allows me to set breakpoints on any 
line, include blank ones and lines that are not considered executable, 
resulting in breakpoints that will never be hit, even if program flow 
control appears to pass through the lines.

For that I would like to write a php parser, in order to detect the 
proper breakpoints line for statements spanning multiple lines.

Is there an (open-source) way to do to this in python code ? Most 
parsers I could see after a search are either too simple for a real 
programming language, or based on a python module written in C. My debug 
client is a Vim plugin, and I would like to distribute it as script 
files only, if that is possible. The generator itself my well be a C 
module, as I only distribute the generated output.

The best parser I could find is PLY, and I would like to know if it is 
good enough for the job. My attempt at a bison parser (C only) ended in 
about a hundred conflicts, most of which are difficult to understand, 
although I admit I do not know much about the subject yet.

Are there other parsers you have used for complete languages ?

Thank you,
Timothy Madden



More information about the Python-list mailing list