@plurnk/plurnk-mimetypes-text-clojure 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/TextClojure.d.ts +7 -0
- package/dist/TextClojure.d.ts.map +1 -0
- package/dist/TextClojure.js +205 -0
- package/dist/TextClojure.js.map +1 -0
- package/dist/generated/ClojureLexer.d.ts +58 -0
- package/dist/generated/ClojureLexer.d.ts.map +1 -0
- package/dist/generated/ClojureLexer.js +227 -0
- package/dist/generated/ClojureLexer.js.map +1 -0
- package/dist/generated/ClojureParser.d.ts +418 -0
- package/dist/generated/ClojureParser.d.ts.map +1 -0
- package/dist/generated/ClojureParser.js +2475 -0
- package/dist/generated/ClojureParser.js.map +1 -0
- package/dist/generated/ClojureVisitor.d.ts +291 -0
- package/dist/generated/ClojureVisitor.d.ts.map +1 -0
- package/dist/generated/ClojureVisitor.js +251 -0
- package/dist/generated/ClojureVisitor.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/grammar/Clojure.g4 +357 -0
- package/package.json +58 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { AbstractParseTreeVisitor } from "antlr4ng";
|
|
2
|
+
/**
|
|
3
|
+
* This interface defines a complete generic visitor for a parse tree produced
|
|
4
|
+
* by `ClojureParser`.
|
|
5
|
+
*
|
|
6
|
+
* @param <Result> The return type of the visit operation. Use `void` for
|
|
7
|
+
* operations with no return type.
|
|
8
|
+
*/
|
|
9
|
+
export class ClojureVisitor extends AbstractParseTreeVisitor {
|
|
10
|
+
/**
|
|
11
|
+
* Visit a parse tree produced by `ClojureParser.file_`.
|
|
12
|
+
* @param ctx the parse tree
|
|
13
|
+
* @return the visitor result
|
|
14
|
+
*/
|
|
15
|
+
visitFile_;
|
|
16
|
+
/**
|
|
17
|
+
* Visit a parse tree produced by `ClojureParser.form`.
|
|
18
|
+
* @param ctx the parse tree
|
|
19
|
+
* @return the visitor result
|
|
20
|
+
*/
|
|
21
|
+
visitForm;
|
|
22
|
+
/**
|
|
23
|
+
* Visit a parse tree produced by `ClojureParser.forms`.
|
|
24
|
+
* @param ctx the parse tree
|
|
25
|
+
* @return the visitor result
|
|
26
|
+
*/
|
|
27
|
+
visitForms;
|
|
28
|
+
/**
|
|
29
|
+
* Visit a parse tree produced by `ClojureParser.list_`.
|
|
30
|
+
* @param ctx the parse tree
|
|
31
|
+
* @return the visitor result
|
|
32
|
+
*/
|
|
33
|
+
visitList_;
|
|
34
|
+
/**
|
|
35
|
+
* Visit a parse tree produced by `ClojureParser.vector`.
|
|
36
|
+
* @param ctx the parse tree
|
|
37
|
+
* @return the visitor result
|
|
38
|
+
*/
|
|
39
|
+
visitVector;
|
|
40
|
+
/**
|
|
41
|
+
* Visit a parse tree produced by `ClojureParser.map_`.
|
|
42
|
+
* @param ctx the parse tree
|
|
43
|
+
* @return the visitor result
|
|
44
|
+
*/
|
|
45
|
+
visitMap_;
|
|
46
|
+
/**
|
|
47
|
+
* Visit a parse tree produced by `ClojureParser.set_`.
|
|
48
|
+
* @param ctx the parse tree
|
|
49
|
+
* @return the visitor result
|
|
50
|
+
*/
|
|
51
|
+
visitSet_;
|
|
52
|
+
/**
|
|
53
|
+
* Visit a parse tree produced by `ClojureParser.reader_macro`.
|
|
54
|
+
* @param ctx the parse tree
|
|
55
|
+
* @return the visitor result
|
|
56
|
+
*/
|
|
57
|
+
visitReader_macro;
|
|
58
|
+
/**
|
|
59
|
+
* Visit a parse tree produced by `ClojureParser.quote`.
|
|
60
|
+
* @param ctx the parse tree
|
|
61
|
+
* @return the visitor result
|
|
62
|
+
*/
|
|
63
|
+
visitQuote;
|
|
64
|
+
/**
|
|
65
|
+
* Visit a parse tree produced by `ClojureParser.backtick`.
|
|
66
|
+
* @param ctx the parse tree
|
|
67
|
+
* @return the visitor result
|
|
68
|
+
*/
|
|
69
|
+
visitBacktick;
|
|
70
|
+
/**
|
|
71
|
+
* Visit a parse tree produced by `ClojureParser.unquote`.
|
|
72
|
+
* @param ctx the parse tree
|
|
73
|
+
* @return the visitor result
|
|
74
|
+
*/
|
|
75
|
+
visitUnquote;
|
|
76
|
+
/**
|
|
77
|
+
* Visit a parse tree produced by `ClojureParser.unquote_splicing`.
|
|
78
|
+
* @param ctx the parse tree
|
|
79
|
+
* @return the visitor result
|
|
80
|
+
*/
|
|
81
|
+
visitUnquote_splicing;
|
|
82
|
+
/**
|
|
83
|
+
* Visit a parse tree produced by `ClojureParser.tag`.
|
|
84
|
+
* @param ctx the parse tree
|
|
85
|
+
* @return the visitor result
|
|
86
|
+
*/
|
|
87
|
+
visitTag;
|
|
88
|
+
/**
|
|
89
|
+
* Visit a parse tree produced by `ClojureParser.deref`.
|
|
90
|
+
* @param ctx the parse tree
|
|
91
|
+
* @return the visitor result
|
|
92
|
+
*/
|
|
93
|
+
visitDeref;
|
|
94
|
+
/**
|
|
95
|
+
* Visit a parse tree produced by `ClojureParser.gensym`.
|
|
96
|
+
* @param ctx the parse tree
|
|
97
|
+
* @return the visitor result
|
|
98
|
+
*/
|
|
99
|
+
visitGensym;
|
|
100
|
+
/**
|
|
101
|
+
* Visit a parse tree produced by `ClojureParser.lambda_`.
|
|
102
|
+
* @param ctx the parse tree
|
|
103
|
+
* @return the visitor result
|
|
104
|
+
*/
|
|
105
|
+
visitLambda_;
|
|
106
|
+
/**
|
|
107
|
+
* Visit a parse tree produced by `ClojureParser.meta_data`.
|
|
108
|
+
* @param ctx the parse tree
|
|
109
|
+
* @return the visitor result
|
|
110
|
+
*/
|
|
111
|
+
visitMeta_data;
|
|
112
|
+
/**
|
|
113
|
+
* Visit a parse tree produced by `ClojureParser.var_quote`.
|
|
114
|
+
* @param ctx the parse tree
|
|
115
|
+
* @return the visitor result
|
|
116
|
+
*/
|
|
117
|
+
visitVar_quote;
|
|
118
|
+
/**
|
|
119
|
+
* Visit a parse tree produced by `ClojureParser.host_expr`.
|
|
120
|
+
* @param ctx the parse tree
|
|
121
|
+
* @return the visitor result
|
|
122
|
+
*/
|
|
123
|
+
visitHost_expr;
|
|
124
|
+
/**
|
|
125
|
+
* Visit a parse tree produced by `ClojureParser.discard`.
|
|
126
|
+
* @param ctx the parse tree
|
|
127
|
+
* @return the visitor result
|
|
128
|
+
*/
|
|
129
|
+
visitDiscard;
|
|
130
|
+
/**
|
|
131
|
+
* Visit a parse tree produced by `ClojureParser.dispatch`.
|
|
132
|
+
* @param ctx the parse tree
|
|
133
|
+
* @return the visitor result
|
|
134
|
+
*/
|
|
135
|
+
visitDispatch;
|
|
136
|
+
/**
|
|
137
|
+
* Visit a parse tree produced by `ClojureParser.regex`.
|
|
138
|
+
* @param ctx the parse tree
|
|
139
|
+
* @return the visitor result
|
|
140
|
+
*/
|
|
141
|
+
visitRegex;
|
|
142
|
+
/**
|
|
143
|
+
* Visit a parse tree produced by `ClojureParser.literal`.
|
|
144
|
+
* @param ctx the parse tree
|
|
145
|
+
* @return the visitor result
|
|
146
|
+
*/
|
|
147
|
+
visitLiteral;
|
|
148
|
+
/**
|
|
149
|
+
* Visit a parse tree produced by `ClojureParser.string_`.
|
|
150
|
+
* @param ctx the parse tree
|
|
151
|
+
* @return the visitor result
|
|
152
|
+
*/
|
|
153
|
+
visitString_;
|
|
154
|
+
/**
|
|
155
|
+
* Visit a parse tree produced by `ClojureParser.hex_`.
|
|
156
|
+
* @param ctx the parse tree
|
|
157
|
+
* @return the visitor result
|
|
158
|
+
*/
|
|
159
|
+
visitHex_;
|
|
160
|
+
/**
|
|
161
|
+
* Visit a parse tree produced by `ClojureParser.bin_`.
|
|
162
|
+
* @param ctx the parse tree
|
|
163
|
+
* @return the visitor result
|
|
164
|
+
*/
|
|
165
|
+
visitBin_;
|
|
166
|
+
/**
|
|
167
|
+
* Visit a parse tree produced by `ClojureParser.bign`.
|
|
168
|
+
* @param ctx the parse tree
|
|
169
|
+
* @return the visitor result
|
|
170
|
+
*/
|
|
171
|
+
visitBign;
|
|
172
|
+
/**
|
|
173
|
+
* Visit a parse tree produced by `ClojureParser.number`.
|
|
174
|
+
* @param ctx the parse tree
|
|
175
|
+
* @return the visitor result
|
|
176
|
+
*/
|
|
177
|
+
visitNumber;
|
|
178
|
+
/**
|
|
179
|
+
* Visit a parse tree produced by `ClojureParser.character`.
|
|
180
|
+
* @param ctx the parse tree
|
|
181
|
+
* @return the visitor result
|
|
182
|
+
*/
|
|
183
|
+
visitCharacter;
|
|
184
|
+
/**
|
|
185
|
+
* Visit a parse tree produced by `ClojureParser.named_char`.
|
|
186
|
+
* @param ctx the parse tree
|
|
187
|
+
* @return the visitor result
|
|
188
|
+
*/
|
|
189
|
+
visitNamed_char;
|
|
190
|
+
/**
|
|
191
|
+
* Visit a parse tree produced by `ClojureParser.any_char`.
|
|
192
|
+
* @param ctx the parse tree
|
|
193
|
+
* @return the visitor result
|
|
194
|
+
*/
|
|
195
|
+
visitAny_char;
|
|
196
|
+
/**
|
|
197
|
+
* Visit a parse tree produced by `ClojureParser.u_hex_quad`.
|
|
198
|
+
* @param ctx the parse tree
|
|
199
|
+
* @return the visitor result
|
|
200
|
+
*/
|
|
201
|
+
visitU_hex_quad;
|
|
202
|
+
/**
|
|
203
|
+
* Visit a parse tree produced by `ClojureParser.nil_`.
|
|
204
|
+
* @param ctx the parse tree
|
|
205
|
+
* @return the visitor result
|
|
206
|
+
*/
|
|
207
|
+
visitNil_;
|
|
208
|
+
/**
|
|
209
|
+
* Visit a parse tree produced by `ClojureParser.keyword`.
|
|
210
|
+
* @param ctx the parse tree
|
|
211
|
+
* @return the visitor result
|
|
212
|
+
*/
|
|
213
|
+
visitKeyword;
|
|
214
|
+
/**
|
|
215
|
+
* Visit a parse tree produced by `ClojureParser.simple_keyword`.
|
|
216
|
+
* @param ctx the parse tree
|
|
217
|
+
* @return the visitor result
|
|
218
|
+
*/
|
|
219
|
+
visitSimple_keyword;
|
|
220
|
+
/**
|
|
221
|
+
* Visit a parse tree produced by `ClojureParser.macro_keyword`.
|
|
222
|
+
* @param ctx the parse tree
|
|
223
|
+
* @return the visitor result
|
|
224
|
+
*/
|
|
225
|
+
visitMacro_keyword;
|
|
226
|
+
/**
|
|
227
|
+
* Visit a parse tree produced by `ClojureParser.symbol`.
|
|
228
|
+
* @param ctx the parse tree
|
|
229
|
+
* @return the visitor result
|
|
230
|
+
*/
|
|
231
|
+
visitSymbol;
|
|
232
|
+
/**
|
|
233
|
+
* Visit a parse tree produced by `ClojureParser.simple_sym`.
|
|
234
|
+
* @param ctx the parse tree
|
|
235
|
+
* @return the visitor result
|
|
236
|
+
*/
|
|
237
|
+
visitSimple_sym;
|
|
238
|
+
/**
|
|
239
|
+
* Visit a parse tree produced by `ClojureParser.ns_symbol`.
|
|
240
|
+
* @param ctx the parse tree
|
|
241
|
+
* @return the visitor result
|
|
242
|
+
*/
|
|
243
|
+
visitNs_symbol;
|
|
244
|
+
/**
|
|
245
|
+
* Visit a parse tree produced by `ClojureParser.param_name`.
|
|
246
|
+
* @param ctx the parse tree
|
|
247
|
+
* @return the visitor result
|
|
248
|
+
*/
|
|
249
|
+
visitParam_name;
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=ClojureVisitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClojureVisitor.js","sourceRoot":"","sources":["../../src/generated/ClojureVisitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AA6CpD;;;;;;GAMG;AACH,MAAM,OAAO,cAAuB,SAAQ,wBAAgC;IACxE;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,iBAAiB,CAAwC;IACzD;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,aAAa,CAAoC;IACjD;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,qBAAqB,CAA4C;IACjE;;;;OAIG;IACH,QAAQ,CAA+B;IACvC;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,aAAa,CAAoC;IACjD;;;;OAIG;IACH,UAAU,CAAiC;IAC3C;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,eAAe,CAAsC;IACrD;;;;OAIG;IACH,aAAa,CAAoC;IACjD;;;;OAIG;IACH,eAAe,CAAsC;IACrD;;;;OAIG;IACH,SAAS,CAAgC;IACzC;;;;OAIG;IACH,YAAY,CAAmC;IAC/C;;;;OAIG;IACH,mBAAmB,CAA0C;IAC7D;;;;OAIG;IACH,kBAAkB,CAAyC;IAC3D;;;;OAIG;IACH,WAAW,CAAkC;IAC7C;;;;OAIG;IACH,eAAe,CAAsC;IACrD;;;;OAIG;IACH,cAAc,CAAqC;IACnD;;;;OAIG;IACH,eAAe,CAAsC;CACxD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/* Reworked for grammar specificity by Reid Mckenzie. Did a bunch of
|
|
2
|
+
work so that rather than reading "a bunch of crap in parens" some
|
|
3
|
+
syntactic information is preserved and recovered. Dec. 14 2014.
|
|
4
|
+
|
|
5
|
+
Converted to ANTLR 4 by Terence Parr. Unsure of provenance. I see
|
|
6
|
+
it commited by matthias.koester for clojure-eclipse project on
|
|
7
|
+
Oct 5, 2009:
|
|
8
|
+
|
|
9
|
+
code.google.com/p/clojure-eclipse/
|
|
10
|
+
|
|
11
|
+
Seems to me Laurent Petit had a version of this. I also see
|
|
12
|
+
Jingguo Yao submitting a link to a now-dead github project on
|
|
13
|
+
Jan 1, 2011.
|
|
14
|
+
|
|
15
|
+
github.com/laurentpetit/ccw/tree/master/clojure-antlr-grammar
|
|
16
|
+
|
|
17
|
+
Regardless, there are some issues perhaps related to "sugar";
|
|
18
|
+
I've tried to fix them.
|
|
19
|
+
|
|
20
|
+
This parses https://github.com/weavejester/compojure project.
|
|
21
|
+
|
|
22
|
+
I also note this is hardly a grammar; more like "match a bunch of
|
|
23
|
+
crap in parens" but I guess that is LISP for you ;)
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false
|
|
27
|
+
// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging
|
|
28
|
+
|
|
29
|
+
grammar Clojure;
|
|
30
|
+
|
|
31
|
+
file_
|
|
32
|
+
: form* EOF
|
|
33
|
+
;
|
|
34
|
+
|
|
35
|
+
form
|
|
36
|
+
: literal
|
|
37
|
+
| list_
|
|
38
|
+
| vector
|
|
39
|
+
| map_
|
|
40
|
+
| reader_macro
|
|
41
|
+
;
|
|
42
|
+
|
|
43
|
+
forms
|
|
44
|
+
: form*
|
|
45
|
+
;
|
|
46
|
+
|
|
47
|
+
list_
|
|
48
|
+
: '(' forms ')'
|
|
49
|
+
;
|
|
50
|
+
|
|
51
|
+
vector
|
|
52
|
+
: '[' forms ']'
|
|
53
|
+
;
|
|
54
|
+
|
|
55
|
+
map_
|
|
56
|
+
: '{' (form form)* '}'
|
|
57
|
+
;
|
|
58
|
+
|
|
59
|
+
set_
|
|
60
|
+
: '#{' forms '}'
|
|
61
|
+
;
|
|
62
|
+
|
|
63
|
+
reader_macro
|
|
64
|
+
: lambda_
|
|
65
|
+
| meta_data
|
|
66
|
+
| regex
|
|
67
|
+
| var_quote
|
|
68
|
+
| host_expr
|
|
69
|
+
| set_
|
|
70
|
+
| tag
|
|
71
|
+
| discard
|
|
72
|
+
| dispatch
|
|
73
|
+
| deref
|
|
74
|
+
| quote
|
|
75
|
+
| backtick
|
|
76
|
+
| unquote
|
|
77
|
+
| unquote_splicing
|
|
78
|
+
| gensym
|
|
79
|
+
;
|
|
80
|
+
|
|
81
|
+
// TJP added '&' (gather a variable number of arguments)
|
|
82
|
+
quote
|
|
83
|
+
: '\'' form
|
|
84
|
+
;
|
|
85
|
+
|
|
86
|
+
backtick
|
|
87
|
+
: '`' form
|
|
88
|
+
;
|
|
89
|
+
|
|
90
|
+
unquote
|
|
91
|
+
: '~' form
|
|
92
|
+
;
|
|
93
|
+
|
|
94
|
+
unquote_splicing
|
|
95
|
+
: '~@' form
|
|
96
|
+
;
|
|
97
|
+
|
|
98
|
+
tag
|
|
99
|
+
: '^' form form
|
|
100
|
+
;
|
|
101
|
+
|
|
102
|
+
deref
|
|
103
|
+
: '@' form
|
|
104
|
+
;
|
|
105
|
+
|
|
106
|
+
gensym
|
|
107
|
+
: SYMBOL '#'
|
|
108
|
+
;
|
|
109
|
+
|
|
110
|
+
lambda_
|
|
111
|
+
: '#(' form* ')'
|
|
112
|
+
;
|
|
113
|
+
|
|
114
|
+
meta_data
|
|
115
|
+
: '#^' (map_ form | form)
|
|
116
|
+
;
|
|
117
|
+
|
|
118
|
+
var_quote
|
|
119
|
+
: '#\'' symbol
|
|
120
|
+
;
|
|
121
|
+
|
|
122
|
+
host_expr
|
|
123
|
+
: '#+' form form
|
|
124
|
+
;
|
|
125
|
+
|
|
126
|
+
discard
|
|
127
|
+
: '#_' form
|
|
128
|
+
;
|
|
129
|
+
|
|
130
|
+
dispatch
|
|
131
|
+
: '#' symbol form
|
|
132
|
+
;
|
|
133
|
+
|
|
134
|
+
regex
|
|
135
|
+
: '#' string_
|
|
136
|
+
;
|
|
137
|
+
|
|
138
|
+
literal
|
|
139
|
+
: string_
|
|
140
|
+
| number
|
|
141
|
+
| character
|
|
142
|
+
| nil_
|
|
143
|
+
| BOOLEAN
|
|
144
|
+
| keyword
|
|
145
|
+
| symbol
|
|
146
|
+
| param_name
|
|
147
|
+
;
|
|
148
|
+
|
|
149
|
+
string_
|
|
150
|
+
: STRING
|
|
151
|
+
;
|
|
152
|
+
|
|
153
|
+
hex_
|
|
154
|
+
: HEX
|
|
155
|
+
;
|
|
156
|
+
|
|
157
|
+
bin_
|
|
158
|
+
: BIN
|
|
159
|
+
;
|
|
160
|
+
|
|
161
|
+
bign
|
|
162
|
+
: BIGN
|
|
163
|
+
;
|
|
164
|
+
|
|
165
|
+
number
|
|
166
|
+
: FLOAT
|
|
167
|
+
| hex_
|
|
168
|
+
| bin_
|
|
169
|
+
| bign
|
|
170
|
+
| LONG
|
|
171
|
+
;
|
|
172
|
+
|
|
173
|
+
character
|
|
174
|
+
: named_char
|
|
175
|
+
| u_hex_quad
|
|
176
|
+
| any_char
|
|
177
|
+
;
|
|
178
|
+
|
|
179
|
+
named_char
|
|
180
|
+
: CHAR_NAMED
|
|
181
|
+
;
|
|
182
|
+
|
|
183
|
+
any_char
|
|
184
|
+
: CHAR_ANY
|
|
185
|
+
;
|
|
186
|
+
|
|
187
|
+
u_hex_quad
|
|
188
|
+
: CHAR_U
|
|
189
|
+
;
|
|
190
|
+
|
|
191
|
+
nil_
|
|
192
|
+
: NIL
|
|
193
|
+
;
|
|
194
|
+
|
|
195
|
+
keyword
|
|
196
|
+
: macro_keyword
|
|
197
|
+
| simple_keyword
|
|
198
|
+
;
|
|
199
|
+
|
|
200
|
+
simple_keyword
|
|
201
|
+
: ':' symbol
|
|
202
|
+
;
|
|
203
|
+
|
|
204
|
+
macro_keyword
|
|
205
|
+
: ':' ':' symbol
|
|
206
|
+
;
|
|
207
|
+
|
|
208
|
+
symbol
|
|
209
|
+
: ns_symbol
|
|
210
|
+
| simple_sym
|
|
211
|
+
;
|
|
212
|
+
|
|
213
|
+
simple_sym
|
|
214
|
+
: SYMBOL
|
|
215
|
+
;
|
|
216
|
+
|
|
217
|
+
ns_symbol
|
|
218
|
+
: NS_SYMBOL
|
|
219
|
+
;
|
|
220
|
+
|
|
221
|
+
param_name
|
|
222
|
+
: PARAM_NAME
|
|
223
|
+
;
|
|
224
|
+
|
|
225
|
+
// Lexers
|
|
226
|
+
//--------------------------------------------------------------------
|
|
227
|
+
|
|
228
|
+
STRING
|
|
229
|
+
: '"' (~'"' | '\\' '"')* '"'
|
|
230
|
+
;
|
|
231
|
+
|
|
232
|
+
// FIXME: Doesn't deal with arbitrary read radixes, BigNums
|
|
233
|
+
FLOAT
|
|
234
|
+
: '-'? [0-9]+ FLOAT_TAIL
|
|
235
|
+
| '-'? 'Infinity'
|
|
236
|
+
| '-'? 'NaN'
|
|
237
|
+
;
|
|
238
|
+
|
|
239
|
+
fragment FLOAT_TAIL
|
|
240
|
+
: FLOAT_DECIMAL FLOAT_EXP
|
|
241
|
+
| FLOAT_DECIMAL
|
|
242
|
+
| FLOAT_EXP
|
|
243
|
+
;
|
|
244
|
+
|
|
245
|
+
fragment FLOAT_DECIMAL
|
|
246
|
+
: '.' [0-9]+
|
|
247
|
+
;
|
|
248
|
+
|
|
249
|
+
fragment FLOAT_EXP
|
|
250
|
+
: [eE] '-'? [0-9]+
|
|
251
|
+
;
|
|
252
|
+
|
|
253
|
+
fragment HEXD
|
|
254
|
+
: [0-9a-fA-F]
|
|
255
|
+
;
|
|
256
|
+
|
|
257
|
+
HEX
|
|
258
|
+
: '0' [xX] HEXD+
|
|
259
|
+
;
|
|
260
|
+
|
|
261
|
+
BIN
|
|
262
|
+
: '0' [bB] [10]+
|
|
263
|
+
;
|
|
264
|
+
|
|
265
|
+
LONG
|
|
266
|
+
: '-'? [0-9]+ [lL]?
|
|
267
|
+
;
|
|
268
|
+
|
|
269
|
+
BIGN
|
|
270
|
+
: '-'? [0-9]+ [nN]
|
|
271
|
+
;
|
|
272
|
+
|
|
273
|
+
CHAR_U
|
|
274
|
+
: '\\' 'u' [0-9D-Fd-f] HEXD HEXD HEXD
|
|
275
|
+
;
|
|
276
|
+
|
|
277
|
+
CHAR_NAMED
|
|
278
|
+
: '\\' ('newline' | 'return' | 'space' | 'tab' | 'formfeed' | 'backspace')
|
|
279
|
+
;
|
|
280
|
+
|
|
281
|
+
CHAR_ANY
|
|
282
|
+
: '\\' .
|
|
283
|
+
;
|
|
284
|
+
|
|
285
|
+
NIL
|
|
286
|
+
: 'nil'
|
|
287
|
+
;
|
|
288
|
+
|
|
289
|
+
BOOLEAN
|
|
290
|
+
: 'true'
|
|
291
|
+
| 'false'
|
|
292
|
+
;
|
|
293
|
+
|
|
294
|
+
SYMBOL
|
|
295
|
+
: '.'
|
|
296
|
+
| '/'
|
|
297
|
+
| NAME
|
|
298
|
+
;
|
|
299
|
+
|
|
300
|
+
NS_SYMBOL
|
|
301
|
+
: NAME '/' SYMBOL
|
|
302
|
+
;
|
|
303
|
+
|
|
304
|
+
PARAM_NAME
|
|
305
|
+
: '%' ('1' ..'9' '0' ..'9'* | '&')?
|
|
306
|
+
;
|
|
307
|
+
|
|
308
|
+
// Fragments
|
|
309
|
+
//--------------------------------------------------------------------
|
|
310
|
+
|
|
311
|
+
fragment NAME
|
|
312
|
+
: SYMBOL_HEAD SYMBOL_REST* (':' SYMBOL_REST+)*
|
|
313
|
+
;
|
|
314
|
+
|
|
315
|
+
fragment SYMBOL_HEAD
|
|
316
|
+
: ~(
|
|
317
|
+
'0' .. '9'
|
|
318
|
+
| '^'
|
|
319
|
+
| '`'
|
|
320
|
+
| '\''
|
|
321
|
+
| '"'
|
|
322
|
+
| '#'
|
|
323
|
+
| '~'
|
|
324
|
+
| '@'
|
|
325
|
+
| ':'
|
|
326
|
+
| '/'
|
|
327
|
+
| '%'
|
|
328
|
+
| '('
|
|
329
|
+
| ')'
|
|
330
|
+
| '['
|
|
331
|
+
| ']'
|
|
332
|
+
| '{'
|
|
333
|
+
| '}' // FIXME: could be one group
|
|
334
|
+
| [ \n\r\t,] // FIXME: could be WS
|
|
335
|
+
)
|
|
336
|
+
;
|
|
337
|
+
|
|
338
|
+
fragment SYMBOL_REST
|
|
339
|
+
: SYMBOL_HEAD
|
|
340
|
+
| '0' ..'9'
|
|
341
|
+
| '.'
|
|
342
|
+
;
|
|
343
|
+
|
|
344
|
+
// Discard
|
|
345
|
+
//--------------------------------------------------------------------
|
|
346
|
+
|
|
347
|
+
fragment WS
|
|
348
|
+
: [ \n\r\t,]
|
|
349
|
+
;
|
|
350
|
+
|
|
351
|
+
fragment COMMENT
|
|
352
|
+
: ';' ~[\r\n]*
|
|
353
|
+
;
|
|
354
|
+
|
|
355
|
+
TRASH
|
|
356
|
+
: (WS | COMMENT) -> channel(HIDDEN)
|
|
357
|
+
;
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plurnk/plurnk-mimetypes-text-clojure",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "text/x-clojure mimetype handler for plurnk-service. ANTLR-backed extraction via grammars-v4.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=25"
|
|
12
|
+
},
|
|
13
|
+
"plurnk": {
|
|
14
|
+
"kind": "mimetype",
|
|
15
|
+
"handlers": [
|
|
16
|
+
{
|
|
17
|
+
"name": "text/x-clojure",
|
|
18
|
+
"glyph": "\ud83c\udf3f",
|
|
19
|
+
"extensions": [
|
|
20
|
+
".clj",
|
|
21
|
+
".cljs",
|
|
22
|
+
".cljc",
|
|
23
|
+
".edn"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist/**/*",
|
|
37
|
+
"grammar/**/*",
|
|
38
|
+
"README.md"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"test:lint": "tsc --noEmit",
|
|
42
|
+
"test:unit": "node --test src/**/*.test.ts",
|
|
43
|
+
"test": "npm run test:lint && npm run test:unit",
|
|
44
|
+
"build:grammar": "plurnk-mimetypes-compile",
|
|
45
|
+
"build:dist": "tsc -p tsconfig.build.json",
|
|
46
|
+
"build": "npm run build:grammar && npm run build:dist",
|
|
47
|
+
"prepare": "npm run build"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@plurnk/plurnk-mimetypes": "0.10.0",
|
|
51
|
+
"antlr4ng": "^3.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^25.8.0",
|
|
55
|
+
"antlr-ng": "^1.0.10",
|
|
56
|
+
"typescript": "^6.0.3"
|
|
57
|
+
}
|
|
58
|
+
}
|