RE: [PHP-DEV] PHP Abstract Syntax Tree
| From: | Dmitry Stogov | Date: | Fri, 14 Apr 2006 09:10:28 +0000 |
| Subject: | RE: [PHP-DEV] PHP Abstract Syntax Tree | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-22755@lists.php.net to get a copy of this message | ||
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:wcandillon@gmail.com]
> 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 <tomas_matousek@hotmail.com> 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: wcandillon@elv.enic.fr
> > Tel: +33(0) 6 67 99 13 16
> > Resume: http://wcandillon.netcv.org
> >
>
>
>
> --
> William Candillon
> Telecom Lille Student
> E-mail: wcandillon@elv.enic.fr
> Tel: +33(0) 6 67 99 13 16
> Resume: http://wcandillon.netcv.org
>