How to write a language parser ?

Chris Angelico rosuav at
Fri Feb 22 17:38:19 CET 2013

On Sat, Feb 23, 2013 at 3:29 AM, Timothy Madden <terminatorul at> wrote:
> For that I would like to write a php parser, in order to detect the proper
> breakpoints line for statements spanning multiple lines.

Are you able to drop to PHP itself for that? It makes its own lexer
available to user-code:

It's supposed to be able to tell you line numbers, too, though I
haven't actually used that. In theory, you should be able to use
token_get_all, then JSON encode it, and write the whole lot out to
stdout, where Python can pick it up and work with it.


More information about the Python-list mailing list