Experimental project to interpret and convert PHP code to Scala
The project consists of a PHP lexer/parser using Scala combinators, an interpreter based on a syntax tree that can be converted to Scala, a runtime library encapsulating all the quirks of PHP type and class system and various sub-projects corresponding to the PHP-extensions.
The talk should emphasize on the following topics:
- How to extend Scala combinators to realize a complex lexer with different states (like the states in a classical flex grammar).
- Performance issues with Scala combinators in a complex grammar like PHP. Potentially: Comparison to a more classic lexer/parser approach (jflex, javacc, jay, antlr ...)
- How to structure the runtime library so that it can be used in an AST-based interpreter as well as in converted code by utilizing operator overloading.
- How to use Scala macros to generate glue-code between Scala functions/classes and their PHP counterparts.
- Demonstration how the interpreter can be used to to drop-in PHP files into a Play 2 application, though with currently rather poor performance due to the complex lexer/parser.
- Demonstration how converted code actually looks like - and might look like in the future. (I.e. demonstrate that a conversion is indeed possible and not just gibberish of a mad-man).
- Demonstration how a converted PHP codeblock/class can be used in interpreted code and vice versa, allowing a step-by-step (or function-by-function, class-by-class) migration from PHP to Scala.
- Open issues and missing "buildin" extensions that are commonly used in PHP project. (Most likely still a lot in June.)
- Fair warning that a simple conversion to Scala will not improve the quality of the existing code at all, but at least opens the door for refactoring in a structured way.
The current state of the project can be found here: https://github.com/leanovate/jbj
Länge: normal; Slides:
JBJ_-_BED-Con.pdf



















