PHP uses one-pass compiler + additional pass for bytecode fixup.
Usage of AST will require at least two passes and as result more time and
memory.
One-pass compiler is always faster, but not any language can be compiled in
one pass (PHP can).

I think AST is not a good representation for type inference and
optimization.
Various kind of graphs, webs and "static assignment" forms are used for code
optimization in modern compilers.
I knew only one old Modula-2 compiler from DEC those did optimization on AST
level.
So some optimizations may be done fine on AST level too.

Thanks. Dmitry.

> -----Original Message-----
> From: William Candillon [mailto:[EMAIL PROTECTED] 
> Sent: Friday, April 14, 2006 12:07 PM
> To: internals@lists.php.net
> Subject: Re: [PHP-DEV] PHP Abstract Syntax Tree
> 
> 
> I already wrote an program which converts PHP source code to 
> AST but I don't understand why the native PHP compiler 
> doesn't use this approach.
> 
> On 4/14/06, Tomas Matousek <[EMAIL PROTECTED]> wrote:
> >
> > Hi William,
> > if you are interested in converting PHP source code to AST, you may 
> > find the Phalanger system useful.
> > See http://php-compiler.net.
> >
> > Tomas
> >
> > ----- Original Message -----
> > Hi,
> >
> > Is it planned to  modify the PHP compiler in order to create an 
> > abstract syntax tree rather than generating directly the 
> opcode ? It 
> > will allow to perform tasks like Type inference, optimization etc...
> >
> > Best regards,
> >
> > William
> >
> > --
> > William Candillon
> > Telecom Lille Student
> > E-mail: [EMAIL PROTECTED]
> > Tel: +33(0) 6 67 99 13 16
> > Resume: http://wcandillon.netcv.org
> >
> 
> 
> 
> --
> William Candillon
> Telecom Lille Student
> E-mail: [EMAIL PROTECTED]
> Tel: +33(0) 6 67 99 13 16
> Resume: http://wcandillon.netcv.org
> 

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to