Building a better interface

Right now, the parser that we have built is not really easy to use. In order to use the parser correctly, a user (in this context, read "user" as "another developer that uses your parser") has to call the match_Expr() method (which is just one of many public match_* functions offered by the parser that are not actually supposed to be called by external users), extract the node property from the returned array, and then call the evaluate function on the root node contained in this property. Also, the parser also matches partial strings (remember the example (1 + 2)) * 3, which was recognized as partially correct by our parser), which might really surprise some users.

This reason is enough to extend our project by a new ...

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.