Code generation in the Unicon preprocessor
After the preprocessor, the rest of the Unicon translator takes Unicon input and outputs an extended dialect of Icon that has no name but is occasionally referred to as Icon’ (Icon prime). Unicon is written in around 7,000 lines of Unicon code and another 1,100 lines of iyacc specification. It is tiny compared to a conventional compiler, but ten times the size of the preprocessor’s preprocessor described in the previous section.
Transforming objects into classes
The output of Unicon frequently resembles the input closely enough to qualify as a preprocessor. Regular Icon code such as user-defined procedures with their statements and expressions pass through Unicon almost unmodified. However, the Unicon translator implements several language extensions by changing the source code. For example, packages are implemented via name mangling. You can see what Unicon does with a given input file foo.icn
, if anything, by running...