forked from pombreda/JSyntax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ.sublime-syntax
161 lines (143 loc) · 4.63 KB
/
J.sublime-syntax
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
%YAML 1.2
---
name: J
file_extensions: [ijs, ijt]
scope: source.j
variables:
validname: '[A-Za-z][A-Za-z_0-9]*'
closeexpdef: '^\s*\)\s*$'
noinflect: '(?![.:])'
contexts:
main:
- include: comments
- include: strings
- include: expdef
- include: noundef
- include: notes
- include: note
- include: numbers
- include: nouns
- include: verbs
- include: adverbs
- include: conjunctions
- include: globals
- include: locals
- include: trailingws
# multi-line explicit verb/adverb/conjunction definition
expdef:
- match: '\b([1-4]|13|adverb|conjunction|verb|monad|dyad)\s+(:\s*0|define)\b'
scope: punctuation.definition.explicit.block.begin.j
push:
- meta_content_scope: definition.explicit.block.j
- include: comments
- include: strings
- include: numbers
- include: nouns
- include: verbs
- include: adverbs
- include: conjunctions
- include: globals
- include: locals
- include: controls
- include: expargs
- include: trailingws
- match: '{{closeexpdef}}'
scope: punctuation.definition.explicit.block.end.j
pop: true
comments:
- match: '\bNB\..*$'
scope: comment.line.j
strings:
- match: "'"
captures:
0: punctuation.definition.string.begin.j
push:
- meta_scope: string.quoted.j
- match: "(')|(\n)"
captures:
1: punctuation.definition.string.end.j
2: invalid.illegal.unclosed-string.j
pop: true
trailingws:
- match: '(\s)+\n'
scope: invalid.deprecated.trailing-whitespace
numbers:
- match: '\b[_0-9][_0-9\.a-zA-Z]*\b{{noinflect}}'
scope: constant.numeric.j
nouns:
- match: '\b(_\.|a\.|a:){{noinflect}}'
scope: keyword.other.noun.j
verbs:
# numbers with inflection and double inflections
- match: '((_?[1-9]:)|(\b0:)|({::)){{noinflect}}'
scope: keyword.operator.verb.j
# letters with inflection
- match: '\b((p\.\.)|([AcCeEiIjLopr]\.)|([ipqsux]:)){{noinflect}}'
scope: keyword.operator.verb.j
# symbols with . inflection
- match: '([<>+*\-%$|,#{}^~"?]\.){{noinflect}}'
scope: keyword.operator.verb.j
# symbols with : inflection
- match: '([<>+*\-%$|,#{};~"_/\\\[]:){{noinflect}}'
scope: keyword.operator.verb.j
# symbols with no inflection
- match: '([<>+*\-%$|,#{!;^=?\[\]]){{noinflect}}'
scope: keyword.operator.verb.j
adverbs:
# letters with inflection
- match: '\b(([bfMt]\.)|(t:)){{noinflect}}'
scope: keyword.operator.adverb.j
# symbols with and without . inflection
- match: '(([/\\]\.)|([~/\\}])){{noinflect}}'
scope: keyword.operator.adverb.j
conjunctions:
# letters with inflection
- match: '\b(([dDHT]\.)|([DLS]:)){{noinflect}}'
scope: keyword.operator.conjunction.j
# symbols with double inflection, . or : inflection or no inflection
- match: '((&\.:)|([&@!;]\.)|([&@!`^]:)|([&@`"])){{noinflect}}'
scope: keyword.operator.conjunction.j
# . or : with or without inflection (need leading whitespace)
- match: '\s(([.:][.:])|([.:])){{noinflect}}'
scope: keyword.operator.conjunction.j
controls:
- match: '\b(if|do|else|elseif|end|for|select|case|fcase)\.{{noinflect}}'
scope: keyword.control.j
- match: '\b(assert|break|continue|return|while|whilst)\.{{noinflect}}'
scope: keyword.control.j
- match: '\b(throw|try|catch|catchd|catcht)\.{{noinflect}}'
scope: keyword.control.j
- match: '\b(for_{{validname}}|goto_{{validname}}|label_{{validname}})\.{{noinflect}}'
scope: keyword.control.j
globals:
- match: '=:'
scope: copula.global.j
locals:
- match: '=\.'
scope: copula.local.j
# argument identifiers within explicit definition blocks
expargs:
- match: '\b[nmuvxy](?![\w.:])'
scope: variable.parameter.j
# multi-line noun definition
noundef:
- match: '\b(0|noun)\s+(:\s*0|define)\b'
scope: punctuation.definition.string.block.begin.j
push:
- meta_content_scope: string.noun.j
- match: '{{closeexpdef}}'
scope: punctuation.definition.string.block.end.j
pop: true
# multi-line note
notes:
- match: ^\s*\bNote\b(?!\s*\=[:.])\s*[\'\d].*$
scope: punctuation.definition.comment.block.begin.j
push:
- meta_scope: comment.block.j
- match: '{{closeexpdef}}'
scope: punctuation.definition.comment.block.end.j
pop: true
# single-line note
note:
- match: \bNote\b(?!\s*\=[:.])\s*[\'\d].*$
scope: comment.line.j