4 ms·
I ended up writing a full compiler stack in XSLT for declarative, XML-based DSLs[0][1] and a few targets (mainly JavaScript and HTML). It didn't start out as t
by mikegerwitz 9y ago
I ended up writing a full compiler stack in XSLT for declarative, XML-based DSLs[0][1] and a few targets (mainly JavaScript and HTML). It didn't start out as that, but having already written basic HTML/JS generation from a simple DSL, it evolved from there.
It was originally written in XSLT 1.0 so that it could generate in the web browser, which had some serious limitations and was incredibly verbose. XSLT 2 is much less verbose, but obviously XML is verbose in general.
If I had to do it over, I'd use Lisp, but the functional and template-based style of XSLT made for very natural syntax-directed translation for the compilers. I still have the cruft of old XSLT 1 code (which was written when I was also _learning_ XSLT), but all things considered, it's not all that bad. Most of the pain points are the patchwork evolution of the project; done from scratch in XSLT, it'd be much more elegant.
And, like Lisp, XSLT can parse itself as data (sans xpath). That allowed me to use a semi-literate style (generate literate documentation from the sources), for example.
[0]: https://github.com/lovullo/tame https://github.com/lovullo/tame
[1]: https://github.com/lovullo/liza-proguic/tree/master/src https://github.com/lovullo/liza-proguic/tree/master/src
[2]: https://github.com/lovullo/literate-xsl https://github.com/lovullo/literate-xsl with example output https://mikegerwitz.com/hoxsl/manual/ https://mikegerwitz.com/hoxsl/manual/