I have been LaTeX-ifying the M2R10 specification, using the Listings package to make
LaTeX render Modula-2 source code within the document.
I then noticed that the Modula-2 language definition included with the Listings package
isn't up to scratch. It covers PIM only, and it renders all predefined identifiers as reserved
words. Even so some predefined identifiers are missing, for example NEW and DISPOSE.
I have then made three language definitions for the Listings package, one each covering
PIM, ISO and R10, and uploaded them to Github in my repo for syntax highlighting stuff.
This repo also has a wiki page with instructions how to use the files and an example.
I tried to define a style where reserved words and predefined identifiers are rendered
in the Algol style, lowercase bold either with/without underline or upright/italic.
Unfortunately, the Listings styles are what LaTeX calls fragile, which means there
are certain commands that simply cannot be used with them and the \MakeLowercase
command is one on which the Listings package chokes. There may be a way to work
around that using a \protect command but this is one of those areas of LaTeX that is
extremely cumbersome and it is quite time consuming to learn the inner workings of
TeX/LaTeX, so I have left this alone for now. If anyone on the list happens to have a
TeX/LaTeX expert in the family, maybe they can take a look at this ;-)
Otherwise, it is probably good enough as it is. Feel free to reuse.