Created by: levjj
For rule macros, it is possible to automatically refactor code with macros by using the template (body of the rule macro) to match syntax and replace it with the corresponding macro invocation based on the pattern. This pull request adds support for this type of "macrofication" refactoring. In order to use this features, I added a command line flag (-r) and integrated the refactoring into the sweet.js editor. Using the editor is definitely the preferred way of refactoring as it highlights the code and let's you chose which code to replace by a macro:
The macrofication option in the editor is off by default but seems to work pretty good. Limitations are some special kind of "expr" pattern classes and locally scoped macro definitions. Also, the highlighting is mutually exclusive with the expansion highlighting due to a limitation in CodeMirror. The only way around this problem would be to write some extension to CodeMirror that supports multiple syntax highlighters at the same time.
This pull request is based on the patch for supporting repeated variables: #540.