[antlr-interest] PHP AST Grammar

Bernhard Schmalhofer Bernhard.Schmalhofer at gmx.de
Tue Mar 11 11:17:27 PDT 2008


Adam Cooney schrieb:
> Hey,
> I've been searching for a grammar for PHP that can build ASTs and so 
> far have come up with nothing for ANTLR (in fact, nothing at all 
> related to PHP). However, I did find a program called PHC which 
> contains a php grammar I am thinking of attempting to convert to 
> ANTLR, but was wondering if anyone has attempted to build a PHP AST 
> grammar before or has a PHP grammar.
Hi,

I have been toying with parsing and tree processing of PHP.

My Project is called Plumhead, name after ther *P*lum*h*eaded *P*arakeet,
http://www.perlfoundation.org/parrot/index.cgi?plumhead.
The compilation target is the Parrot Abstract Syntax Tree, which can be
compiled into bytecode for the Parrot virtual machine, 
http://parrotcode.org.

I have started implementation of three different frontends.
i. Convert XML output of PHC with XSLT
ii. ANTLR3 Lexer, Parser, and Tree Parser
iii. Perl 6 like grammar, executed with the Parrot Compiler Tools.

I am not very far yet, so any comments and suggestions are very appreciated.

The Plumhead-code is part of the Parrot SVN repository, 
https://svn.perl.org/parrot/trunk.
It can be found in the 'languages/plumhead' directory.

Best regards,
  Bernhard Schmalhofer





More information about the antlr-interest mailing list