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

Justin Silverton's Blog: 5 reasons why oscommerce is a nightmare

Brandon Savage's Blog: Peer Review: Improving The Business Logic

Community News: O'Reilly Offers PHP/SQL Certificate Series

DevShed: Working with Multiple Template Files to Separate Logic from Presentation (Part 3)

Kore Nordmann's Blog: Evil bugs in your code


Community Events









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


opinion tool community zendframework2 object interview introduction functional code testing podcast unittest language event example development release api framework composer

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