Re: Hacking language syntax

From: Date: Sat, 06 Mar 2010 09:48:43 +0000
Subject: Re: Hacking language syntax
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-47092@lists.php.net to get a copy of this message
The files you want to change in PHP core are the lexer
(http://code.google.com/p/php-alternative-syntax/source/browse/trunk/php-5.3.0/Zend/zend_language_scanner.l)
and the scanner
(http://code.google.com/p/php-alternative-syntax/source/browse/trunk/php-5.3.0/Zend/zend_language_parser.y)
and then recompile.

Unfortunately this approach makes your PHP code incompatible with all
other PHP installations. Furthermore the learning code is _very_ steep
because the files are pretty messy and hardly commented (IMO), which
makes everything but the simplest of changes pretty hard. I walked
down the same road you are now contemplating with
http://code.google.com/p/php-alternative-syntax/
but soon abandoned
the idea :) I collected some information about opcodes and the Zend
core here: http://code.google.com/p/php-alternative-syntax/source/browse/#svn/trunk/documentation
they might be useful for you.

At the moment - being interested in language design - I'm
contemplating building a meta language that compiles down to PHP
instead which would keep things compatible. If you are interested it
is called "snow" and looks like http://pastebin.com/9h1d3RpN .

Cheers
Rune


Thread (3 messages)

« previous php.internals (#47092) next »