bablr-lang / bablr-vm

A VM for enforcing language rules on agAST trees
MIT License
40 stars 2 forks source link

Plugins/lifecycle #26

Closed conartist6 closed 1 year ago

conartist6 commented 1 year ago

I will need a highly flexible and expressive plugin API since I expect to have many plugins, many of them interdependent on each other. Plugins are particularly powerful due to a combination of abilities: they can inject metagrammars, they can declare their own grammars, and they can decorate API facades. The combination of these abilities in a scripted environment allows them to be used to accomplish virtually anything.

For example the needsParens plugin will decorate every path facade with path~.needsParens, while the javascript whitespace plugin takes a whitespaceless grammar and turns it into one that has completely correct separator semantics. Both these plugins are actually core plugins for the javascript grammar that are needed to define a javascript grammar at all, however they also show how easy it should be to create new languages just by recomposing reusable plugins, descriptors, and productions.

conartist6 commented 1 year ago

I've made the decision to allow extension of functionality through functional composition. So far it's working quite nicely! But it means that there is no explicit concept of a plugin API (for now).