Optimizing the interpreter by adding a compiler

Our parser now works as it should, and you could use it in any kind of application to offer very flexible customization options to the end user. However, the parser does not work very efficiently. In general, parsing expressions are computationally expensive, and in most use cases, it is reasonable to assume that the actual expressions that you're working with do not change with every request (or at least, are evaluated more often than they are changed).

Because of this, we can optimize the parser's performance by adding a caching layer to our interpreter. Of course, we cannot cache the actual evaluation results of an expression; after all, these could change when they are interpreted with different ...

Get PHP 7 Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.