drym-org / symex.el

An intuitive way to edit Lisp symbolic expressions ("symexes") structurally in Emacs
Other
271 stars 22 forks source link

Ability to do transformations in the DSL #104

Closed countvajhula closed 1 year ago

countvajhula commented 1 year ago

Summary of Changes

Currently, the Symex DSL only has support for motions. We can perform transformations as side effects in traversals (via e.g. symex--do-while-traversing) but these side effects are performed at every step of the traversal and cannot be made more fine-grained. This PR adds support for performing arbitrary operations that may be specified in a traversal program at desired points in the traversal. In addition to such general support, it also adds "native" support for core primitives like delete and paste, using which it should be possible to implement a lot of other Symex transformations like emit and capture.

An advantage of doing this now is that, if the DSL uses only a few primitives to implement a large number of features, then we can reuse a lot of this work for Tree Sitter languages as well, as the implementation at the Symex level would be the same and we would just need to tweak a few general primitives (like delete and paste) and fine-tune the contracts between the primitive layer and the DSL layer in order to get the desired behavior, as opposed to tweaking a lot of different specialized functions like emit and capture that may develop specialized bugs.

Public Domain Dedication

(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)