ProgrammersPage: repy.lang

File repy.lang, 14.8 KB (added by mkaplan, 6 years ago)

repy.lang

Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3
4 This file is part of GtkSourceView
5
6 Author: Gustavo Giráldez <gustavo.giraldez@gmx.net>
7 Copyright (C) 2003 Gustavo Giráldez <gustavo.giraldez@gmx.net>
8 Copyright (C) 2004 Benoît Dejean <TaZForEver@free.fr>
9 Copyright (C) 2006 Steve Frécinaux <nud@apinc.org>
10 Copyright (C) 2012 Stefano Palazzo <stefano-palazzo@ubuntu.com>
11
12 GtkSourceView is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2.1 of the License, or (at your option) any later version.
16
17 GtkSourceView is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25
26-->
27<language id="repy" _name="Repy" version="2.0" _section="Scripts">
28  <metadata>
29    <property name="mimetypes">text/x-repy;application/x-repy</property>
30    <property name="globs">*.repy</property>
31    <property name="line-comment-start">#</property>
32  </metadata>
33
34  <styles>
35    <style id="module-handler"    _name="Module Handler"        map-to="def:preprocessor"/>
36    <style id="keyword"           _name="Keyword"               map-to="def:keyword"/>
37    <style id="multiline-string"  _name="Multiline string"      map-to="def:string"/>
38    <style id="string"            _name="String"                map-to="def:string"/>
39    <style id="escaped-char"      _name="Escaped Character"     map-to="def:special-char"/>
40    <style id="format"            _name="Format"                map-to="def:character"/>
41    <style id="string-conversion" _name="string-conversion"/>
42    <style id="special-variable"  _name="Special Variable"      map-to="def:identifier"/>
43    <style id="boolean"           _name="Boolean"               map-to="def:boolean"/>
44    <style id="floating-point"    _name="Floating point number" map-to="def:floating-point"/>
45    <style id="decimal"           _name="Decimal number"        map-to="def:decimal"/>
46    <style id="base-n-integer"    _name="Base-N number"         map-to="def:base-n-integer"/>
47    <style id="complex"           _name="Complex number"        map-to="def:complex"/>
48    <style id="builtin-constant"  _name="Builtin Constant"      map-to="def:special-constant"/>
49    <style id="builtin-object"    _name="Builtin Object"        map-to="def:type"/>
50    <style id="builtin-function"  _name="Builtin Function"      map-to="def:builtin"/>
51  </styles>
52
53  <definitions>
54    <define-regex id="identifier">[_a-zA-Z][_a-zA-Z0-9]*</define-regex>
55    <define-regex id="number">[1-9][0-9]*</define-regex>
56
57    <!-- http://docs.python.org/lib/typesseq-strings.html -->
58    <context id="format" style-ref="format" extend-parent="false">
59      <match extended="true">
60        %                       # leading % sign
61        \(\%{identifier}\)?     # mapping key
62        [#0\-\ \+]*             # conversion flags
63        (\-?\%{number}|\*)?     # minimum field width
64        (\.(\-?\%{number}|\*))? # precision
65        (hlL)?                  # lentgh modifier
66        [diouxXeEfFgGcrs%]      # conversion type
67      </match>
68    </context>
69
70    <!-- http://docs.python.org/ref/strings.html -->
71    <context id="escaped-char" style-ref="escaped-char" extend-parent="true">
72      <match extended="true">
73        \\(                 # leading backslash
74        [\\'"abfnrtv]     | # single escaped char
75        N\{[A-Z\ ]+\}     | # named unicode character
76        u[0-9A-Fa-f]{4}   | # xxxx - character with 16-bit hex value xxxx
77        U[0-9A-Fa-f]{8}   | # xxxxxxxx - character with 32-bit hex value xxxxxxxx
78        x[0-9A-Fa-f]{1,2} | # \xhh - character with hex value hh
79        [0-7]{1,3}          # \ooo - character with octal value ooo
80        )
81      </match>
82    </context>
83
84    <define-regex id="string-prefix">(u|U)?</define-regex>
85    <define-regex id="raw-string-prefix">(r|ur|R|UR|Ur|uR)</define-regex>
86
87    <context id="multiline-double-quoted-string" style-ref="multiline-string" class="string" class-disabled="no-spell-check">
88      <start>\%{string-prefix}"""</start>
89      <end>"""</end>
90      <include>
91        <context ref="format"/>
92        <context ref="escaped-char"/>
93      </include>
94    </context>
95
96    <context id="multiline-single-quoted-string" style-ref="multiline-string" class="string" class-disabled="no-spell-check">
97      <start>\%{string-prefix}'''</start>
98      <end>'''</end>
99      <include>
100        <context ref="format"/>
101        <context ref="escaped-char"/>
102      </include>
103    </context>
104
105    <context id="double-quoted-string" style-ref="string" end-at-line-end="true" class="string" class-disabled="no-spell-check">
106      <start>\%{string-prefix}"</start>
107      <end>"</end>
108      <include>
109        <context ref="format"/>
110        <context ref="escaped-char"/>
111        <context ref="def:line-continue"/>
112      </include>
113    </context>
114
115    <context id="single-quoted-string" style-ref="string" end-at-line-end="true" class="string" class-disabled="no-spell-check">
116      <start>\%{string-prefix}'</start>
117      <end>'</end>
118      <include>
119        <context ref="format"/>
120        <context ref="escaped-char"/>
121        <context ref="def:line-continue"/>
122      </include>
123    </context>
124
125    <context id="multiline-double-quoted-raw-string" style-ref="multiline-string" class="string" class-disabled="no-spell-check">
126      <start>\%{raw-string-prefix}"""</start>
127      <end>"""</end>
128      <include>
129        <context ref="format"/>
130      </include>
131    </context>
132
133    <context id="multiline-single-quoted-raw-string" style-ref="multiline-string" class="string" class-disabled="no-spell-check">
134      <start>\%{raw-string-prefix}'''</start>
135      <end>'''</end>
136      <include>
137        <context ref="format"/>
138      </include>
139    </context>
140
141    <context id="double-quoted-raw-string" style-ref="string" end-at-line-end="true" class="string" class-disabled="no-spell-check">
142      <start>\%{raw-string-prefix}"</start>
143      <end>"</end>
144      <include>
145        <context ref="format"/>
146        <context ref="def:line-continue"/>
147      </include>
148    </context>
149
150    <context id="single-quoted-raw-string" style-ref="string" end-at-line-end="true" class="string" class-disabled="no-spell-check">
151      <start>\%{raw-string-prefix}'</start>
152      <end>'</end>
153      <include>
154        <context ref="format"/>
155        <context ref="def:line-continue"/>
156      </include>
157    </context>
158
159    <context id="string-conversion" style-ref="string-conversion" end-at-line-end="true">
160      <start>`</start>
161      <end>`</end>
162      <include>
163        <context ref="repy"/>
164      </include>
165    </context>
166
167    <context id="special-variables" style-ref="special-variable">
168      <prefix>(?&lt;![\w\.])</prefix>
169      <keyword>self</keyword>
170      <keyword>__name__</keyword>
171      <keyword>__debug__</keyword>
172    </context>
173
174    <context id="boolean" style-ref="boolean">
175      <prefix>(?&lt;![\w\.])</prefix>
176      <keyword>False</keyword>
177      <keyword>True</keyword>
178    </context>
179
180    <define-regex id="float" extended="true">
181      ( (\d+)?\.\d+ | \d+\. ) |
182      ( (\d+|(\d+)?\.\d+|\d+\.)[eE][+-]?\d+ )
183    </define-regex>
184
185    <context id="complex" style-ref="complex">
186      <match>(?&lt;![\w\.])(\%{float}|\d+)[jJ]\b</match>
187    </context>
188
189    <context id="float" style-ref="floating-point">
190      <match>(?&lt;![\w\.])\%{float}(?![\w\.])</match>
191    </context>
192
193    <context id="decimal" style-ref="decimal">
194      <match>(?&lt;![\w\.])([1-9][0-9]*|0)[lL]?(?![\w\.])</match>
195    </context>
196
197    <context id="octal" style-ref="base-n-integer">
198      <match>(?&lt;![\w\.])0[0-7]+[lL]?(?![\w\.])</match>
199    </context>
200
201    <context id="hex" style-ref="base-n-integer">
202      <match>(?&lt;![\w\.])0[xX][0-9A-Fa-f]+[lL]?(?![\w\.])</match>
203    </context>
204
205    <context id="module-handler" style-ref="module-handler">
206      <keyword>import</keyword>
207      <keyword>from</keyword>
208      <keyword>as</keyword>
209    </context>
210
211    <context id="keywords" style-ref="keyword">
212      <keyword>and</keyword>
213      <keyword>assert</keyword>
214      <keyword>break</keyword>
215      <keyword>class</keyword>
216      <keyword>continue</keyword>
217      <keyword>def</keyword>
218      <keyword>del</keyword>
219      <keyword>elif</keyword>
220      <keyword>else</keyword>
221      <keyword>except</keyword>
222      <keyword>finally</keyword>
223      <keyword>for</keyword>
224      <keyword>global</keyword>
225      <keyword>if</keyword>
226      <keyword>in</keyword>
227      <keyword>is</keyword>
228      <keyword>lambda</keyword>
229      <keyword>not</keyword>
230      <keyword>or</keyword>
231      <keyword>pass</keyword>
232      <keyword>raise</keyword>
233      <keyword>return</keyword>
234      <keyword>try</keyword>
235      <keyword>while</keyword>
236      <keyword>with</keyword>
237      <keyword>yield</keyword>
238    </context>
239
240    <context id="2x-only-keywords" style-ref="keyword">
241      <keyword>exec</keyword>
242      <keyword>print</keyword>
243    </context>
244
245    <context id="builtin-constants" style-ref="builtin-constant">
246      <prefix>(?&lt;![\w\.])</prefix>
247      <keyword>Ellipsis</keyword>
248      <keyword>None</keyword>
249      <keyword>NotImplemented</keyword>
250    </context>
251
252    <context id="builtin-objects" style-ref="builtin-object">
253      <prefix>(?&lt;![\w\.])</prefix>
254      <keyword>ArithmeticError</keyword>
255      <keyword>AssertionError</keyword>
256      <keyword>AttributeError</keyword>
257      <keyword>EnvironmentError</keyword>
258      <keyword>EOFError</keyword>
259      <keyword>Exception</keyword>
260      <keyword>FloatingPointError</keyword>
261      <keyword>ImportError</keyword>
262      <keyword>IndentationError</keyword>
263      <keyword>IndexError</keyword>
264      <keyword>IOError</keyword>
265      <keyword>KeyboardInterrupt</keyword>
266      <keyword>KeyError</keyword>
267      <keyword>LookupError</keyword>
268      <keyword>MemoryError</keyword>
269      <keyword>NameError</keyword>
270      <keyword>NotImplementedError</keyword>
271      <keyword>OSError</keyword>
272      <keyword>OverflowError</keyword>
273      <keyword>ReferenceError</keyword>
274      <keyword>RuntimeError</keyword>
275      <keyword>StandardError</keyword>
276      <keyword>StopIteration</keyword>
277      <keyword>SyntaxError</keyword>
278      <keyword>SystemError</keyword>
279      <keyword>SystemExit</keyword>
280      <keyword>TabError</keyword>
281      <keyword>TypeError</keyword>
282      <keyword>UnboundLocalError</keyword>
283      <keyword>UnicodeDecodeError</keyword>
284      <keyword>UnicodeEncodeError</keyword>
285      <keyword>UnicodeError</keyword>
286      <keyword>UnicodeTranslateError</keyword>
287      <keyword>ValueError</keyword>
288      <keyword>WindowsError</keyword>
289      <keyword>ZeroDivisionError</keyword>
290      <keyword>Warning</keyword>
291      <keyword>UserWarning</keyword>
292      <keyword>DeprecationWarning</keyword>
293      <keyword>PendingDeprecationWarning</keyword>
294      <keyword>SyntaxWarning</keyword>
295      <keyword>OverflowWarning</keyword>
296      <keyword>RuntimeWarning</keyword>
297      <keyword>FutureWarning</keyword>
298    </context>
299
300    <context id="builtin-functions" style-ref="builtin-function">
301      <prefix>(?&lt;![\w\.])</prefix>
302      <keyword>__import__</keyword>
303      <keyword>abs</keyword>
304      <keyword>all</keyword>
305      <keyword>any</keyword>
306      <keyword>bin</keyword>
307      <keyword>bool</keyword>
308      <keyword>callable</keyword>
309      <keyword>chr</keyword>
310      <keyword>classmethod</keyword>
311      <keyword>compile</keyword>
312      <keyword>complex</keyword>
313      <keyword>delattr</keyword>
314      <keyword>dict</keyword>
315      <keyword>dir</keyword>
316      <keyword>divmod</keyword>
317      <keyword>enumerate</keyword>
318      <keyword>eval</keyword>
319      <keyword>filter</keyword>
320      <keyword>float</keyword>
321      <keyword>format</keyword>
322      <keyword>frozenset</keyword>
323      <keyword>getattr</keyword>
324      <keyword>globals</keyword>
325      <keyword>hasattr</keyword>
326      <keyword>hash</keyword>
327      <keyword>hex</keyword>
328      <keyword>id</keyword>
329      <keyword>input</keyword>
330      <keyword>int</keyword>
331      <keyword>isinstance</keyword>
332      <keyword>issubclass</keyword>
333      <keyword>iter</keyword>
334      <keyword>len</keyword>
335      <keyword>list</keyword>
336      <keyword>locals</keyword>
337      <keyword>map</keyword>
338      <keyword>max</keyword>
339      <keyword>min</keyword>
340      <keyword>object</keyword>
341      <keyword>oct</keyword>
342      <keyword>open</keyword>
343      <keyword>ord</keyword>
344      <keyword>pow</keyword>
345      <keyword>property</keyword>
346      <keyword>range</keyword>
347      <keyword>repr</keyword>
348      <keyword>reversed</keyword>
349      <keyword>round</keyword>
350      <keyword>setattr</keyword>
351      <keyword>set</keyword>
352      <keyword>slice</keyword>
353      <keyword>sorted</keyword>
354      <keyword>staticmethod</keyword>
355      <keyword>str</keyword>
356      <keyword>sum</keyword>
357      <keyword>super</keyword>
358      <keyword>tuple</keyword>
359      <keyword>type</keyword>
360      <keyword>vars</keyword>
361      <keyword>zip</keyword>
362    </context>
363
364    <context id="2x-only-builtin-functions" style-ref="builtin-function">
365      <prefix>(?&lt;![\w\.])</prefix>
366      <keyword>apply</keyword>
367      <keyword>basestring</keyword>
368      <keyword>buffer</keyword>
369      <keyword>cmp</keyword>
370      <keyword>coerce</keyword>
371      <keyword>execfile</keyword>
372      <keyword>file</keyword>
373      <keyword>intern</keyword>
374      <keyword>long</keyword>
375      <keyword>raw_input</keyword>
376      <keyword>reduce</keyword>
377      <keyword>reload</keyword>
378      <keyword>unichr</keyword>
379      <keyword>unicode</keyword>
380      <keyword>xrange</keyword>
381    </context>
382
383    <context id="repy" class="no-spell-check">
384      <include>
385        <context ref="def:shebang"/>
386        <context ref="def:shell-like-comment"/>
387        <context ref="multiline-double-quoted-string"/>
388        <context ref="multiline-single-quoted-string"/>
389        <context ref="double-quoted-string"/>
390        <context ref="single-quoted-string"/>
391        <context ref="multiline-double-quoted-raw-string"/>
392        <context ref="multiline-single-quoted-raw-string"/>
393        <context ref="double-quoted-raw-string"/>
394        <context ref="single-quoted-raw-string"/>
395        <context ref="string-conversion"/>
396        <context ref="special-variables"/>
397        <context ref="boolean"/>
398        <context ref="complex"/>
399        <context ref="float"/>
400        <context ref="decimal"/>
401        <context ref="octal"/>
402        <context ref="hex"/>
403        <context ref="module-handler"/>
404        <context ref="keywords"/>
405        <context ref="2x-only-keywords"/>
406        <context ref="builtin-constants"/>
407        <context ref="builtin-objects"/>
408        <context ref="builtin-functions"/>
409        <context ref="2x-only-builtin-functions"/>
410      </include>
411    </context>
412  </definitions>
413</language>