guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PHP language translator for Guile?


From: Jon Herron
Subject: Re: PHP language translator for Guile?
Date: Thu, 1 Apr 2010 19:10:29 -0700 (PDT)

Just wanted to send a quick update, I haven't had as much time as I hoped to 
work on this, but do have a lexer generated with Silex.  So far in really quick 
tests this seems to produce the proper tokens (at least in simple cases).  I'm 
hooked up to the new LALR-SCM module (system base lalr) and am starting to 
define my grammars.  Currently only PHP's T_INLINE_HTML tokens are handled (any 
text outside the PHP tags).  Very basic I know, still no Tree-IL/runtime, but 
it's coming.  The needed files are added to modules/Makefile.am - after a make 
&& make install I can run guile and do a ,L php - at least to me that's pretty 
cool, heh.

I'm going to keep on trucking, but just wanted to say at least some progress 
has been made.  Hopefully before long I'll have some code that is worth 
sharing.  Big thanks to the Guile team for setting all the ground work, so far 
everything has been pretty smooth.

Thanks,

Jon



----- Original Message ----
From: Andy Wingo <address@hidden>
To: Jon Herron <address@hidden>
Cc: address@hidden
Sent: Thu, March 25, 2010 7:20:53 AM
Subject: Re: PHP language translator for Guile?

Hi Jon,

On Thu 25 Mar 2010 02:58, Jon Herron <address@hidden> writes:

> I have an interest in writing a PHP interpreter in Scheme and have spent
> the last couple of days evaluating various Scheme implementations to
> use. After looking at Guile for a bit it appears there is a framework
> for implementing languages besides scheme itself (I noticed ecmascript
> and brainfuck are the in tree), then after checking out the website some
> more I noticed PHP was mentioned as a desired language to be translated
> to Guile. Is this still true? If so I would really like to take a crack
> at adding this feature. I am very new to this type of development but
> feel this would be a great dive to take.

Sounds interesting!

Creating a good PHP implementation would be a lot of work, because PHP
users expect for there to be a big standard library. But if you just
wanted to implement the core semantics, it shouldn't be that
difficult -- a couple months' work, I would imagine.

I hand-wrote a lexer for ECMAScript, but you might want to investigate
Silex, a lexer generator; then use the LALR-SCM library that the ES
compiler uses to parse PHP. From there you compile to tree-il, then
write whatever pieces of a runtime that you need.

The ES compiler is really the reference here, but it is not as clean as
it could be. Apologies for that, and happy hacking!

Andy

ps. Check Guile out from git, build the manual, then look in the "Guile
Implementation" chapter for how to implement another compiler.
-- 
http://wingolog.org/



      




reply via email to

[Prev in Thread] Current Thread [Next in Thread]