News Feed
Jobs Feed
Sections




News Archive
Sankuru Blog:
Adding support for if/while/do while, to a simple compiler & virtual machine in PHP
January 04, 2012 @ 11:40:22

Improving on his last post about creating a bytecode compiler in PHP, the Sankuru blog has a new post in the series looking at extending the basic compiler to add support for if/while and do while logic.

In order to obtain a turing-complete programming language, that is, a language in which we can implement and execute any arbitrary algorithm, that is, that other turing-complete machines can execute too, we now need to add a way of (conditionally) branching, that is, the IF statement, and at least one way of repeating statements, that is the WHILE or the DO WHILE statements.

He includes a simple TL-based script as an end goal for the compiler to be able to execute and shows how to add rules for it to the lexer/parser. Rules for the "if" are relatively simple, but there's a hitch in dealing with embedded "while" statements he had to work around. The post ends with the bytecode results for the sample program and the resulting output from the compiled versions execution.

0 comments voice your opinion now!
bytecode compiler virtual machine while if whiledo logic


blog comments powered by Disqus

Similar Posts

Ralph Schindler's Blog: Exception Best Practices in PHP 5.3

ThinkPHP Blog: Virtual Data Grid: becoming reality soon

Sankuru Blog: Adding support for if/while/do while, to a simple compiler & virtual machine in PHP

PHPMaster.com: Overriding Strategy Logic - The Template Method Pattern

Sankuru Blog: Adding support for if/while/do while, to a simple compiler & virtual machine in PHP


Community Events











Don't see your event here?
Let us know!


application release unittest phpunit interview zendframework2 language introduction example opinion functional podcast development object community tool series code testing framework

All content copyright, 2013 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework