Inversion of control in compilers

Has anyone out there actually used inversion of control containers in compiler implementations yet? I know compilers are supposed to be very fast by design, but I've always wondered how IoC / DI can affect programming language design - hot-swappable syntaxes, anyone?

+1


source to share


3 answers


Lisp-lowercase languages ​​often do this. Read macros are snippets of custom code that extend the reader (and therefore the syntax) of a language. Regular macros are pieces of custom code that also extend the language.

All syntaxes are not hot-swappable, but some parts are extended in different ways.



All of this is not a new idea. Before it was deemed worthy of the three-letter acronym, the IoC was known as "late binding" and fairly agreed as a good idea.

+1


source


Usually LR (k) grammars use a common table driven parser system (action-goto / shift-reduce tables), so you use a table generator tool that creates these tables and feeds them to a common parser system, which can then parse your input. using tables. In general, these parsers are signaling to you that no terminal has been minified. See, for example, the GoldParser system, which is free.



0


source


I would not call this inversion of control, because it is natural for compilers. This is usually a series of passes that transform the input language code into the output language code. You can of course swap in a different pass (e.g. gcc compiles multiple languages ​​using a different interface).

-3


source







All Articles