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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.