There is a quasi-standard for dialect tags agreed among several compiler maintainers. Any newly developed syntax highlighting should aim to support this.
For example, the pygments syntax rendering framework for Python, Gaius Mulley's Emacs highlighting for Modula-2 and Benjamin Kowarsch's highlighting for vim support the tags.
A dialect tag is a special comment that indicates in which dialect the code has been written.
dialectTag :=
"(*!" dialectMnemonic ( "+" compilerMnemonic )? "*)"
;
A dialect mnemonic indicates the dialect
dialectMnemonic :=
"m2pim" /* for PIM */
| "m2iso" /* for ISO */
| "m2r10" /* for R10 */
| ...
;
An optional compiler mnemonic indicates language extensions of a specific compiler.
compilerMnemonic :=
"ack" | "gm2" | "mocka" | "p1" | ...
;
No whitespace is permitted.
At the very least the dialect mnemonics for PIM, ISO and R10 should be supported.
A dialect tag is placed ideally before or directly after the module header in a Modula-2 source file. The highlighting script should scan for the first occurrence of such a tag within the first 100-200 lines of source (accounting for a copyright header that may occur at the top).
If a tag is found, the highlighting script should render the source code according to the dialect indicated by the dialect tag. Otherwise it may use a default setting. A more sophisticated script could search for a keyword that is unique in only one dialect, but this is not really necessary since people who want their source files to be rendered properly will soon learn to add dialect tags to all their sources.
For more details, see the Modula-2 documentation for pygments at:
https://www.pydoc.io/pypi/Pygments-2.1.3/autoapi/modula2/index.html
and the Modula-2 support package for Vim at:
https://bitbucket.org/trijezdci/m2syntaxcolour/src/default/Vim/
There is a quasi-standard for dialect tags agreed among several compiler maintainers. Any newly developed syntax highlighting should aim to support this.
For example, the pygments syntax rendering framework for Python, Gaius Mulley's Emacs highlighting for Modula-2 and Benjamin Kowarsch's highlighting for vim support the tags.
A dialect tag is a special comment that indicates in which dialect the code has been written.
A dialect mnemonic indicates the dialect
An optional compiler mnemonic indicates language extensions of a specific compiler.
No whitespace is permitted.
At the very least the dialect mnemonics for PIM, ISO and R10 should be supported.
A dialect tag is placed ideally before or directly after the module header in a Modula-2 source file. The highlighting script should scan for the first occurrence of such a tag within the first 100-200 lines of source (accounting for a copyright header that may occur at the top).
If a tag is found, the highlighting script should render the source code according to the dialect indicated by the dialect tag. Otherwise it may use a default setting. A more sophisticated script could search for a keyword that is unique in only one dialect, but this is not really necessary since people who want their source files to be rendered properly will soon learn to add dialect tags to all their sources.
For more details, see the Modula-2 documentation for pygments at:
https://www.pydoc.io/pypi/Pygments-2.1.3/autoapi/modula2/index.html
and the Modula-2 support package for Vim at:
https://bitbucket.org/trijezdci/m2syntaxcolour/src/default/Vim/