Re: Hacking language syntax
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)