Debian Codegraph @

data/syntax/modula-2-pim-only.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE language>
3 <language name="Modula-2 (PIM only)" mimetype="text/x-modula2" version="4"
4 kateversion="5.0" section="Sources" priority="4" extensions="*.mod;*.def"
5 casesensitive="1" author="B. Kowarsch (trijezdci@github)" license="MIT">
6 <!--
7 *****************************************************************************
8 PIM Modula-2 syntax highlighting profile for Kate
9
10 Copyright (C) 2018 Modula-2 Software Foundation
11
12 Licensed under the MIT license <https://opensource.org/licenses/MIT>
13
14 The authoritative reference for classic Modula-2 is Niklaus Wirth's monograph
15 "Programming in Modula-2" published by Springer, Heidelberg, commonly known
16 as PIM. The most recent edition is the 4th edition, commonly known as PIM4.
17
18 In Modula-2 terminology, keywords are called reserved words. A list of
19 reserved words can be found in PIM4, page 135, at the end of section 3.
20
21 There are three kinds of built-in identifiers: (1) standard identifiers, also
22 called pervasive identifiers or simply pervasives, (2) built-in macros and
23 (3) identifiers provided by a built-in module called SYSTEM. There is no
24 terminology for the latter group.
25
26 A list of pervasives can be found in PIM4 page 136, at the end of section 4.
27 Built-in macros NEW and DISPOSE are given in PIM4 at the bottom of page 77.
28 Procedures ALLOCATE and DEALLOCATE to which macros NEW and DISPOSE resolve
29 are not given in PIM4 but have been implemented in all of Wirth's Modula-2
30 compilers, then followed by all other compiler implementations. Although
31 the implementations of ALLOCATE and DEALLOCATE are library supplied, their
32 identifiers are hardcoded into the language. For the purpose of syntax
33 highlighting, they should therefore be treated as built-in identifiers.
34 Identifiers exported by built-in module SYSTEM are given in PIM4, page 121.
35
36 In Modula-2 terminology, there are two kinds of procedures: those that return
37 a result in their own name, and those that do not. When it is necessary to
38 differentiate, the former are called function procedures and the latter
39 proper procedures. For this reason, both function and procedure identifiers
40 are listed together under a single group "procedures" in this profile.
41
42 Some classic Modula-2 compilers implemented additional built-in types, most
43 notably BYTE, LONGCARD, SHORTCARD and SHORTINT. However, these types are
44 not part of the classical Modula-2 language definition and consequently
45 they are not recognised as built-in identifiers in this profile.
46 *****************************************************************************
47 -->
48 <highlighting>
49 <list name="workaround">
50 <!-- BUG: Kate ignores first entry in context 'Normal' -->
51 <!-- WORKAROUND: Use the name of this dummy list as first entry -->
52 <item>???</item> <!-- use '???' in source to test/verify this bug -->
53 </list>
54
55 <!-- Reserved Words -->
56 <list name="keywords">
57 <item>AND</item>
58 <item>ARRAY</item>
59 <item>BEGIN</item>
60 <item>BY</item>
61 <item>CASE</item>
62 <item>CONST</item>
63 <item>DEFINITION</item>
64 <item>DIV</item>
65 <item>DO</item>
66 <item>ELSE</item>
67 <item>ELSIF</item>
68 <item>END</item>
69 <item>EXIT</item>
70 <item>EXPORT</item>
71 <item>FOR</item>
72 <item>FROM</item>
73 <item>IF</item>
74 <item>IMPLEMENTATION</item>
75 <item>IMPORT</item>
76 <item>IN</item>
77 <item>LOOP</item>
78 <item>MOD</item>
79 <item>MODULE</item>
80 <item>NOT</item>
81 <item>OF</item>
82 <item>OR</item>
83 <item>POINTER</item>
84 <item>PROCEDURE</item>
85 <item>QUALIFIED</item>
86 <item>RECORD</item>
87 <item>REPEAT</item>
88 <item>RETURN</item>
89 <item>SET</item>
90 <item>THEN</item>
91 <item>TO</item>
92 <item>TYPE</item>
93 <item>UNTIL</item>
94 <item>VAR</item>
95 <item>WHILE</item>
96 <item>WITH</item>
97 </list>
98
99 <!-- Built-in Constant Identifiers -->
100 <list name="constants">
101 <item>FALSE</item>
102 <item>NIL</item>
103 <item>TRUE</item>
104 </list>
105
106 <!-- Built-in Type Identifiers -->
107 <list name="types">
108 <!-- Pervasives -->
109 <item>BOOLEAN</item>
110 <item>BITSET</item>
111 <item>CARDINAL</item>
112 <item>CHAR</item>
113 <item>INTEGER</item>
114 <item>LONGINT</item>
115 <item>LONGREAL</item>
116 <item>PROC</item>
117 <item>REAL</item>
118 </list>
119
120 <!-- Built-in Procedure Identifiers -->
121 <list name="procedures">
122 <!-- Pervasives -->
123 <item>ABS</item>
124 <item>CAP</item>
125 <item>CHR</item>
126 <item>DEC</item>
127 <item>EXCL</item>
128 <item>FLOAT</item>
129 <item>HALT</item>
130 <item>HIGH</item>
131 <item>INC</item>
132 <item>INCL</item>
133 <item>MAX</item>
134 <item>MIN</item>
135 <item>ODD</item>
136 <item>ORD</item>
137 <item>SIZE</item>
138 <item>TRUNC</item>
139 <item>VAL</item>
140 </list>
141
142 <!-- Built-in Macros -->
143 <list name="macros">
144 <!-- NEW resolves to ALLOCATE -->
145 <item>NEW</item>
146 <item>ALLOCATE</item>
147
148 <!-- DISPOSE resolves to DEALLOCATE -->
149 <item>DISPOSE</item>
150 <item>DEALLOCATE</item>
151 </list>
152
153 <!-- Module SYSTEM -->
154 <list name="unsafe">
155 <!-- Module Identifier -->
156 <item>SYSTEM</item>
157
158 <!-- Types -->
159 <item>ADDRESS</item>
160 <item>PROCESS</item>
161 <item>WORD</item>
162
163 <!-- Procedures -->
164 <item>ADR</item>
165 <item>NEWPROCESS</item>
166 <item>TRANSFER</item>
167 <item>TSIZE</item>
168 </list>
169
170 <contexts>
171 <context attribute="Plain Source" lineEndContext="#stay" name="plain">
172 <!-- BUG: first entry is ignored, leave Dummy at first position -->
173 <keyword attribute="Dummy" context="#stay" String="workaround"/>
174
175 <!-- Reserved Words -->
176 <keyword attribute="Keyword" context="#stay" String="keywords"/>
177
178 <!-- Built-in Constant Identifiers -->
179 <keyword attribute="Const" context="#stay" String="constants"/>
180
181 <!-- Built-in Type Identifiers -->
182 <keyword attribute="Type" context="#stay" String="types"/>
183
184 <!-- Built-in Procedure Identifiers -->
185 <keyword attribute="Builtin" context="#stay" String="procedures"/>
186
187 <!-- Built-in Macro Identifiers and Translations -->
188 <keyword attribute="Builtin" context="#stay" String="macros"/>
189
190 <!-- Facilities from Built-in Module SYSTEM -->
191 <keyword attribute="Unsafe" context="#stay" String="unsafe"/>
192
193 <!-- Base-16 Integer Literals -->
194 <!-- Base-8 Integers and Character Code Literals -->
195 <RegExpr attribute="Number" context="#stay" String="0[0-9A-F]*H|[0-7]+[BC]"/>
196
197 <!-- Real Number Literals -->
198 <Float attribute="Number" context="#stay"/>
199
200 <!-- Decimal Integer Literals -->
201 <Int attribute="Number" context="#stay"/>
202
203 <!-- Start of Double-Quoted String Literal -->
204 <DetectChar attribute="String" context="DoubleQuotedString" char="&quot;" />
205
206 <!-- Start of Single-Quoted String Literal -->
207 <DetectChar attribute="String" context="SingleQuotedString" char="'" />
208
209 <!-- Start of Modula-2 Dialect Tag -->
210 <StringDetect attribute="DialectTag" context="InDialectTag" String="(*!"/>
211
212 <!-- Start of Pragma -->
213 <StringDetect attribute="Pragma" context="InPragma" String="(*$"/>
214
215 <!-- Start of Comment -->
216 <Detect2Chars attribute="Comment"
217 context="InComment" char="(" char1="*" beginRegion="FoldableComment"/>
218 </context>
219
220 <!-- End of Double-Quoted String Literal -->
221 <context attribute="String" lineEndContext="#pop" name="DoubleQuotedString">
222 <DetectChar attribute="String" context="#pop" char="&quot;"/>
223 </context>
224
225 <!-- End of Single-Quoted String Literal -->
226 <context attribute="String" lineEndContext="#pop" name="SingleQuotedString">
227 <DetectChar attribute="String" context="#pop" char="'" />
228 </context>
229
230 <!-- End of Dialect Tag -->
231 <context attribute="DialectTag" lineEndContext="#pop" name="InDialectTag">
232 <Detect2Chars attribute="DialectTag" context="#pop" char="*" char1=")"/>
233 </context>
234
235 <!-- End of Pragma -->
236 <context attribute="Pragma" lineEndContext="#stay" name="InPragma">
237 <Detect2Chars attribute="Pragma" context="#pop" char="*" char1=")"/>
238 </context>
239
240 <context attribute="Comment" lineEndContext="#stay" name="InComment">
241 <!-- Start of nested Comment -->
242 <Detect2Chars attribute="Comment"
243 context="InComment" char="(" char1="*" beginRegion="FoldableComment"/>
244 <!-- End of Comment -->
245 <Detect2Chars attribute="Comment"
246 context="#pop" char="*" char1=")" endRegion="FoldableComment"/>
247
248 <DetectSpaces />
249 <IncludeRules context="##Comments" />
250 </context>
251 </contexts>
252
253 <itemDatas>
254 <!-- Style for Plain Source Text -->
255 <itemData name="Plain Source"
256 defStyleNum="dsNormal" bold="0" italic="0" />
257
258 <!-- Style for Reserved Words -->
259 <itemData name="Keyword"
260 defStyleNum="dsKeyword" bold="1" italic="0" />
261
262 <!-- Style for Built-in Constant Identifiers -->
263 <itemData name="Const"
264 defStyleNum="dsBuiltIn" bold="1" italic="0" />
265
266 <!-- Style for Built-in Type Identifiers -->
267 <itemData name="Type"
268 defStyleNum="dsDataType" bold="1" italic="0" />
269
270 <!-- Style for Facilities from Module SYSTEM -->
271 <itemData name="Unsafe"
272 defStyleNum="dsWarning" bold="1" italic="0"/>
273
274 <!-- Style for Built-in Procedure Identifiers -->
275 <itemData name="Builtin"
276 defStyleNum="dsBuiltIn" bold="1" italic="0" />
277
278 <!-- Style for Number Literals -->
279 <itemData name="Number"
280 defStyleNum="dsDecVal" bold="0" italic="0" />
281
282 <!-- Style for Quoted Literals -->
283 <itemData name="String"
284 defStyleNum="dsString" bold="0" italic="0" />
285
286 <!-- Style for Dialect Tags -->
287 <itemData name="DialectTag"
288 defStyleNum="dsComment" bold="1" italic="0" />
289
290 <!-- Style for Pragmas -->
291 <itemData name="Pragma"
292 defStyleNum="dsPreprocessor" bold="1" italic="0" />
293
294 <!-- Style for Comments -->
295 <itemData name="Comment"
296 defStyleNum="dsComment" bold="0" italic="1" />
297
298 <!-- Dummy style for testing -->
299 <itemData name="Dummy" defStyleNum="dsError" />
300 </itemDatas>
301 </highlighting>
302
303 <general>
304 <keywords casesensitive="1" />
305 <comments>
306 <comment name="multiLine" start="(*" end="*)" region="FoldableComment" />
307 </comments>
308 </general>
309 </language>
310 <!-- kate: replace-tabs on; tab-width 2; indent-width 2; -->