Some people say, “Don’t trust a developer that didn’t write his own compiler.”. A few days ago I finished the first version of my first compiler. It compiles typoscript to a php array.
a.line.of = Typopscript $TS['a.']['line.']['of'] = 'Typoscript';
It is implemented using Flex and Bison the open source implementations of Lex and Yacc. The result is a little C progam. You can feed TS into the compiler from within any PHP script and get a PHP array back in return.
Is that a compiler? Doesn’t a compiler build binaries not arrays?
Well, one definition is that a compiler is a translator. It typically tokenizes the input in one language into atomic pices, checks the syntax and maybe sematics and transforms it into another language. In traditional compilers the target language is machine code. In newer compilers it is often C. In this case it’s PHP and it’s focused upon compiling an array.
What is it good for?
If you have discovered the advantages of TS, it’s likely that you want to use TS not only within TYPO3. In the moment I want to use it for configuration within a non-TYPO3 PHP script.
Could it be used in TYPO3?
Certainly it would be possible to use it within TYPO3 itself, to get a faster TS engine. Speaking error messages, even checks of semantics could be implemented. That are features of the compiler approach.
For now it’s only a prototype and some features are still lacking to use it as a replacement for the PHP based TS engine. It will also be a bunch of work, to build a PHP extension around, that provides exaclty the same API of the current TS engine, including the handling of conditions etc. We will see if I find the time and drive to do such an implementation.
glass trust no glass microsoft stay mail dog