Re: compiler in php..
| From: | Aric Caley | Date: | Mon, 19 May 2003 22:18:09 +0000 |
| Subject: | Re: compiler in php.. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148222@lists.php.net to get a copy of this message | ||
I had thought of that, but, if I'm doing a C-style preprocessor:
#define blah
It just comes back as a comment with the tokenizer. The syntax of the
commands wont be PHP code anyway. And I dont necessarily want to parse all
of the php code since I'm not going to be doing anything with it (well,
later, I may try to add macro expansion in the php code, but not now..).
Additionaly, I need also to parse and compile the same commands in a
different syntax that resembles the typical html templates, ie, {variable}
and <!-- BEGIN block --> and <!-- END block -->. I dont think the php
tokenizer would help much here.
I understand the basics behind a compiler, I was just hoping there were some
tools to help with writing a compiler in PHP, even a good, fast tree class
would help...
(and for those curious what I'm doing, I'm trying to make a Frame Processor
for PHP, as described in the book "Framing Software Reuse". I want it to
run dynamicaly so you dont have to add a compile step.)
"Rasmus Lerdorf" <rasmus@lerdorf.com> wrote in message
news:Pine.LNX.4.44.0305191109291.1158-100000@thinkpad.lerdorf.com...
> php.net/tokenizer
>
> On Mon, 19 May 2003, Aric Caley wrote:
>
> > I'm trying to write a simple compiler in php. Actualy it will be more
akin
> > to C's preprocessor with similar syntax. I've been trying to find a php
> > version of Yacc or other tools to aid in making such a compiler *in*
php,
> > but I can't find anything.
> >
> > I figure I will need a basic tree datastructure class to put the parsed
> > commands into, but I can't find one suitable (the pear tree class seems
like
> > overkill as I dont need to save or load the tree data from xml or a db).
> >
> > Anybody got any ideas on how to make a simple C-like preprocessor for
php,
> > written in php?
> >
> >
> >
> >
>