-
Notifications
You must be signed in to change notification settings - Fork 0
/
j.lang
239 lines (210 loc) · 7.45 KB
/
j.lang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of GtkSourceView
Authors: Jsoftware, Ric Sherlock
Copyright (C) 2011 Ric Sherlock <[email protected]>
GtkSourceView is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
GtkSourceView is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, see <http://www.gnu.org/licenses/>.
-->
<language id="j" name="J" version="2.0" _section="Source">
<metadata>
<property name="globs">*.ijs</property>
<property name="line-comment-start">NB\.</property>
</metadata>
<styles>
<style id="adverb" name="Adverb" map-to="def:identifier" />
<style id="comment" name="Comment" map-to="def:comment" />
<style id="conjunction" name="Conjunction" map-to="def:identifier" />
<style id="control" name="Control" map-to="def:keyword" />
<style id="error" name="Error" map-to="def:error" />
<style id="exparg" name="Explicit Argument" map-to="def:special-char" />
<style id="global" name="Global" map-to="def:type" />
<style id="labtext" name="Lab Text" map-to="def:preprocessor" />
<style id="local" name="Local" map-to="def:type" />
<style id="noun" name="Noun" map-to="def:special-constant" />
<style id="noundef" name="Explicit Noun Definition" map-to="def:string" />
<style id="number" name="Number" map-to="def:decimal" />
<style id="parens" name="Parens" map-to="def:statement" />
<style id="primitive" name="Primitive" map-to="def:identifier" />
<style id="string" name="String" map-to="def:string" />
<style id="verb" name="Verb" map-to="def:identifier" />
</styles>
<definitions>
<!-- Problems/shortcomings
* How to target parens inside expdef
* Matched vs unmatched parens coloring but how to do () and not {} and []
-->
<!-- NB. (Comments) -->
<context id="comment" style-ref="comment" end-at-line-end="true">
<start>\%[NB\.</start>
</context>
<!-- 'abcde' (Strings) -->
<context id="string" style-ref="string" end-at-line-end="true">
<start>L?'</start><end>'</end>
</context>
<!-- Unbalanced single quotes -->
<context id="error" style-ref="error">
<match>'[^']*?$</match>
</context>
<!-- 2.34 (Numbers) -->
<context id="number" style-ref="number">
<match extended="true">\%[[_0-9][_0-9\.a-zA-Z]*\%]</match>
</context>
<!-- Nouns -->
<context id="noun" style-ref="noun">
<match extended="true">
\%[(_\.|a\.|a:)(?![\.\:])
</match>
</context>
<!-- Verbs -->
<context id="verb" style-ref="verb">
<match extended="true">
((_?[0-9]:)|
(\%[p\.\.)|
(\%[[AcCeEiIjLopr]\.)|
(\%[[ipqsux]:)|
({::)|
([<>\+\*\-\%\^\$\~\|\,\#\{\}"\?]\.)|
([<>\_\+\*\-\%\$\~\|\,\;\#\/\\\[\{\}"]:)|
([<>\=\+\*\-\%\^\$\|\,\;\#\!\[\]\{\?]))
(?![\.\:])
</match>
</context>
<!-- Adverbs -->
<context id="adverb" style-ref="adverb">
<match extended="true">
(([\/\\]\.)|
(\%[[bfMt]\.)|
(\%[t:)|
([\~\/\\\}]))
(?![\.\:])
</match>
</context>
<!-- Conjunctions -->
<context id="conjunction" style-ref="conjunction">
<match extended="true">
((\%[[dDHT]\.)|
(\%[[DLS]:)|
(&\.:)|
([\;\!\@&]\.)|
([\^\!\`\@&]:)|
([\"\`\@&])|
(\s[\.\:][\.\:])|
(\s[\.\:]))
(?![\.\:])
</match>
</context>
<!-- () (Parentheses) -->
<context id="parens" style-ref="parens">
<match>[\(\)]</match>
</context>
<!-- Explicit arguments -->
<context id="exparg" style-ref="exparg">
<match extended="true">\%[[nmuvxy](?![\w\.\:])</match>
</context>
<define-regex id="valid-name">[a-zA-Z][a-zA-Z0-9_]*</define-regex>
<define-regex id="close-expdef">^\s*\)\s*$</define-regex>
<!-- if. do. end. (Control words) -->
<context id="control" style-ref="control">
<prefix>\%[</prefix>
<suffix>(?![\.\:])</suffix>
<keyword>assert\.</keyword>
<keyword>break\.</keyword>
<keyword>continue\.</keyword>
<keyword>return\.</keyword>
<keyword>do\.</keyword>
<keyword>if\.</keyword>
<keyword>else\.</keyword>
<keyword>elseif\.</keyword>
<keyword>end\.</keyword>
<keyword>for\.</keyword>
<keyword>select\.</keyword>
<keyword>case\.</keyword>
<keyword>fcase\.</keyword>
<keyword>throw\.</keyword>
<keyword>try\.</keyword>
<keyword>catch\.</keyword>
<keyword>catchd\.</keyword>
<keyword>catcht\.</keyword>
<keyword>while\.</keyword>
<keyword>whilst\.</keyword>
<keyword>for_\%{valid-name}?\.</keyword>
<keyword>goto_\%{valid-name}?\.</keyword>
<keyword>label_\%{valid-name}?\.</keyword>
</context>
<!-- Explicit definition -->
<context id="expdef" style-inside="true">
<start>\%[(([1-4]|13)\s+:\s*0)|((adverb|conjunction|verb|monad|dyad)\s+define)\%]</start>
<end>\%{close-expdef}</end>
<include>
<context ref="comment"/>
<context ref="error"/>
<context ref="exparg"/>
<context ref="global"/>
<context ref="local"/>
<context ref="noun"/>
<context ref="verb"/>
<context ref="adverb"/>
<context ref="conjunction"/>
<context ref="string"/>
<context ref="number"/>
<context ref="control"/>
</include>
</context>
<!-- Explicit noun definition -->
<context id="noundef" style-ref="noundef" style-inside="true">
<start>\%[(0\s+:\s*0|noun\s+define)\%].*$</start>
<end>\%{close-expdef}</end>
</context>
<!-- Lab text definition -->
<context id="labtext" style-ref="labtext">
<start>^\s*[\x{2500}|-]{2,}</start>
<end>\%{close-expdef}</end>
</context>
<!-- Note (Multiline comment) -->
<context id="notes" style-ref="comment" style-inside="true">
<start>^\s*\%[Note\%](?!\s*\=[:.])\s*['\d].*$</start>
<end>\%{close-expdef}</end>
</context>
<!-- Note (to end-of-line comment) -->
<context id="note" style-ref="comment" end-at-line-end="true">
<start>\%[Note\%](?!\s*\=[:.])\s*['\d].*$</start>
</context>
<!-- =: (Global assignment) -->
<context id="global" style-ref="global">
<match>=:</match>
</context>
<!-- =. (Local assignment) -->
<context id="local" style-ref="local">
<match>=\.</match>
</context>
<context id="j">
<include>
<context ref="comment"/>
<context ref="error"/>
<context ref="string"/>
<context ref="global"/>
<context ref="local"/>
<context ref="noun"/>
<context ref="verb"/>
<context ref="adverb"/>
<context ref="conjunction"/>
<context ref="expdef"/>
<context ref="noundef"/>
<context ref="labtext"/>
<context ref="notes"/>
<context ref="note"/>
<context ref="parens"/>
<context ref="number"/>
</include>
</context>
</definitions>
</language>