Re: PHP_Parser class - any plans?

From: Date: Thu, 16 May 2002 20:31:05 +0000
Subject: Re: PHP_Parser class - any plans?
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6171@lists.php.net to get a copy of this message
IMHO trying to parse PHP with code written in PHP is nonsense. Extend ext/tokenizer, add another mode to the executor, or don't. First of all, the language is not well-defined, so the task of writing a second parser is difficult in the first place. Doing it in PHP is beyond sub-optimal. There's a saying that goes "When you have a hammer, all problems appear to be like a nail.". Well, in this case, you would be trying to use the screwdriver to build a hammer out of nails, or something like that. - Stig On Thu, 2002-05-16 at 19:31, Lux wrote: > This would definitely be interesting, and I can see many potential uses > for such a class/extension. It would probably be wisest to reuse the > Zend engine as much as possible, for speed reasons, and to try to avoid > duplicating efforts on a likely significantly sized project (if one were > to rewrite the parser entirely in php-land). > > Lux > > On Thu, 2002-05-16 at 12:19, Simon Willison wrote: > > Are there any plans to put together a PEAR tool for parsing and > > "understanding" PHP scripts? Several times over the past few months I have > > come across situations where such a thing could be useful, mostly related > > to documentation. For example, a well written parser class could allow the > > construction of a tool like lxr (as used on http://lxr.php.net/"J¸¬Á > > ©?©- ) for > > "browsing" PHP source code. It could also be very useful for writing > > debuggers, profilers and other development tools. > > > > I have no experience of language parsing at all but I imagine it's a lot > > more complicated than just putting together a few regular expressions. Is > > it even viable to write such a thing in PHP or would it make more sense to > > write it as a C extension (perhaps for PECL) that re-uses some of the > > parsing code from the actual Zend engine? > > > > In fact now that I think about it PHP's built in syntax highlighting > > functions must have access to a parser of some sort. How hard would it be > > to add an interface to this parser (I would have thought this is straying > > in to PHP development territory as opposed to PEAR). > > > > Regards, > > > > Simon Willison > > > > > > -- > > PEAR Development Mailing List (http://pear.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.pear.dev (#6171) next »