Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39588

Re: How to write a language parser ?

References <51279cfe$0$293$14726298@news.sunsite.dk>
Date 2013-02-23 03:38 +1100
Subject Re: How to write a language parser ?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2281.1361551115.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Feb 23, 2013 at 3:29 AM, Timothy Madden <terminatorul@gmail.com> 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:

http://php.net/manual/en/function.token-get-all.php

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.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to write a language parser ? Timothy Madden <terminatorul@gmail.com> - 2013-02-22 18:29 +0200
  Re: How to write a language parser ? Chris Angelico <rosuav@gmail.com> - 2013-02-23 03:38 +1100
  Re: How to write a language parser ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-23 00:06 +0000
  Re: How to write a language parser ? mbg1708@planetmail.com - 2013-02-22 17:25 -0800
  Re: How to write a language parser ? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-02-23 02:14 +0000
  Re: How to write a language parser ? Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-02-23 05:57 -0500

csiph-web