d11wtq/boris — pull request #76 by alexpw (2014-09-05 01:55:29+00:00)
Title: full support for use stmts via new macro system

Created as an alternative and as a reply to https://github.com/d11wtq/boris/pull/72

User supplied macros:

A new Boris::setMacro(), provides a hook that users can leverage in .borisrc/etc to supply match/replace code to be called in EvalWorker::_transform(). Similar to the 'exit' => 'exit(0)' transform that existed (but did nothing in my tests), macros are defined as a mapping of a regex pattern to a replacement string or a callback, suitable for preg_replace/preg_replace_callback, respectively.

I then added full support for "use" stmts by creating a builtin macro, that transform a use stmt into one or more calls to class_alias() (one for each alias). However, my initBuiltinMacros()/addUseMacro() organization/approach feels lacking, and like it should be moved elsewhere.

Finally, I added "use" to the list of keywords that are not "returnable" (not needing a "return " prefix).

Cheers, and thank you for boris!