@exercism/codemirror-lang-r 0.0.0-stage → 1.0.1

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/dist/index.cjs ADDED
@@ -0,0 +1,595 @@
1
+ 'use strict';
2
+
3
+ var lr = require('@lezer/lr');
4
+ var language = require('@codemirror/language');
5
+ var highlight = require('@lezer/highlight');
6
+ var autocomplete = require('@codemirror/autocomplete');
7
+ var common = require('@lezer/common');
8
+
9
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
10
+ const insertSemi = 126,
11
+ DoubleStart = 1,
12
+ DoubleContent = 2,
13
+ DoubleEnd = 3,
14
+ SingleStart = 4,
15
+ SingleContent = 5,
16
+ SingleEnd = 6,
17
+ Escape = 7,
18
+ RawString = 8,
19
+ space = 128,
20
+ newline = 129,
21
+ LineComment = 9,
22
+ DocComment = 10;
23
+
24
+ // ── Line breaks ───────────────────────────────────────────────────────────────
25
+ // Whether a line break stands between the last token that meant anything and
26
+ // the cursor. Whitespace and comments carry the answer forward, because a
27
+ // comment on its own line must not hide the break that follows it; everything
28
+ // else replaces it.
29
+ const trackNewline = new lr.ContextTracker({
30
+ start: false,
31
+ shift(context, term) {
32
+ return term == LineComment || term == DocComment || term == space
33
+ ? context
34
+ : term == newline;
35
+ },
36
+ strict: false
37
+ });
38
+ function isSpace(ch) {
39
+ return (ch == 32 /* Ch.Space */ || ch == 9 /* Ch.Tab */ || ch == 10 /* Ch.Newline */ || ch == 13 /* Ch.Return */ ||
40
+ ch == 11 /* Ch.VTab */ || ch == 12 /* Ch.FormFeed */ || ch == 160 || ch == 0xfeff);
41
+ }
42
+ function isLetter(ch) {
43
+ return (ch >= 97 /* Ch.LowerA */ && ch <= 122 /* Ch.LowerZ */) || (ch >= 65 /* Ch.UpperA */ && ch <= 90 /* Ch.UpperZ */);
44
+ }
45
+ function isNameChar(ch) {
46
+ return (isLetter(ch) ||
47
+ (ch >= 48 /* Ch.Digit0 */ && ch <= 57 /* Ch.Digit9 */) ||
48
+ ch == 95 /* Ch.Underscore */ ||
49
+ ch == 46 ||
50
+ ch >= 161 /* Ch.NonAscii */);
51
+ }
52
+ // The one word in R a line break may stand in front of.
53
+ //
54
+ // if (n > 0)
55
+ // "some"
56
+ // else
57
+ // "none"
58
+ //
59
+ // R itself refuses this at the top of a file and accepts it inside braces,
60
+ // where the rest of the expression is still to come. The distinction is not
61
+ // worth keeping: a highlighter that reads the second `if` of a chain as a
62
+ // statement of its own colours the same words the same way and then loses the
63
+ // tree that folding and indentation are read from.
64
+ function continuesLine(input) {
65
+ if (input.next != 101 /* Ch.LowerE */)
66
+ return false;
67
+ const word = [101 /* Ch.LowerE */, 108 /* Ch.LowerL */, 115 /* Ch.LowerS */, 101 /* Ch.LowerE */];
68
+ for (let i = 0; i < word.length; i++)
69
+ if (input.peek(i) != word[i])
70
+ return false;
71
+ return !isNameChar(input.peek(word.length));
72
+ }
73
+ // The line break that finished an expression, as a token of no width.
74
+ //
75
+ // R's own parser is handed every line break and decides what to do with it by
76
+ // the state it is in, and `canShift` is the same question asked from the other
77
+ // side: it is true exactly where an expression may end, which is nowhere inside
78
+ // a bracket and nowhere after an operator that is still waiting for its right
79
+ // hand side. That is the whole rule. R never continues an expression that could
80
+ // have stood on its own, which is why `x <- 1` and a following line holding
81
+ // `-2` are two expressions rather than a subtraction.
82
+ const insertSemicolon = new lr.ExternalTokenizer((input, stack) => {
83
+ const next = input.next;
84
+ // Whitespace and comments are skipped by the grammar. Both carry the line
85
+ // break forward, so the decision is only postponed to the token they precede.
86
+ if (isSpace(next) || next == 35 /* Ch.Hash */)
87
+ return;
88
+ if (!stack.canShift(insertSemi))
89
+ return;
90
+ // A brace closes whatever the last expression in it was, and so does the end
91
+ // of the file, whether or not a line break came first.
92
+ if (next == 125 /* Ch.BraceR */ || next == -1 /* Ch.EOF */)
93
+ return input.acceptToken(insertSemi);
94
+ if (!stack.context)
95
+ return;
96
+ if (continuesLine(input))
97
+ return;
98
+ input.acceptToken(insertSemi);
99
+ }, { contextual: true });
100
+ // ── Strings ───────────────────────────────────────────────────────────────────
101
+ // A string is handed over in pieces so that the escapes inside it can be
102
+ // coloured apart from the text around them. The two quote characters have a set
103
+ // of tokens each, which is what tells the tokenizer which quote it is looking
104
+ // for: asking the parser whether it could shift the content of a double quoted
105
+ // string answers it without any state being kept here.
106
+ //
107
+ // R's strings may hold a line break, and plenty of the messages in its own
108
+ // standard library do.
109
+ const strings = new lr.ExternalTokenizer((input, stack) => {
110
+ if (stack.canShift(DoubleContent))
111
+ return readQuoted(input, 34 /* Ch.Quote */, DoubleContent, DoubleEnd);
112
+ if (stack.canShift(SingleContent))
113
+ return readQuoted(input, 39 /* Ch.Apostrophe */, SingleContent, SingleEnd);
114
+ if (input.next == 114 /* Ch.LowerR */ || input.next == 82 /* Ch.UpperR */)
115
+ return readRaw(input);
116
+ if (input.next == 34 /* Ch.Quote */) {
117
+ input.advance();
118
+ return input.acceptToken(DoubleStart);
119
+ }
120
+ if (input.next == 39 /* Ch.Apostrophe */) {
121
+ input.advance();
122
+ return input.acceptToken(SingleStart);
123
+ }
124
+ });
125
+ function readQuoted(input, quote, content, end) {
126
+ if (input.next == quote) {
127
+ input.advance();
128
+ return input.acceptToken(end);
129
+ }
130
+ if (input.next == 92 /* Ch.Backslash */)
131
+ return readEscape(input);
132
+ let length = 0;
133
+ for (;;) {
134
+ const ch = input.peek(length);
135
+ if (ch == -1 /* Ch.EOF */ || ch == quote || ch == 92 /* Ch.Backslash */)
136
+ break;
137
+ length++;
138
+ }
139
+ if (!length)
140
+ return;
141
+ input.advance(length);
142
+ input.acceptToken(content);
143
+ }
144
+ /**
145
+ The escapes R's parser accepts, which are C's with two spellings of a code
146
+ point added: `é`, `\u{e9}` and their eight digit twins.
147
+ */
148
+ function readEscape(input) {
149
+ let length = 1;
150
+ const marker = input.peek(1);
151
+ if (marker == 120 /* Ch.LowerX */) {
152
+ length = 2;
153
+ while (length < 4 && isHex(input.peek(length)))
154
+ length++;
155
+ }
156
+ else if (marker == 117 /* Ch.LowerU */ || marker == 85 /* Ch.UpperU */) {
157
+ const limit = marker == 117 /* Ch.LowerU */ ? 4 : 8;
158
+ length = 2;
159
+ if (input.peek(2) == 123 /* Ch.BraceL */) {
160
+ length = 3;
161
+ while (isHex(input.peek(length)))
162
+ length++;
163
+ if (input.peek(length) == 125 /* Ch.BraceR */)
164
+ length++;
165
+ }
166
+ else {
167
+ while (length < 2 + limit && isHex(input.peek(length)))
168
+ length++;
169
+ }
170
+ }
171
+ else if (marker >= 48 /* Ch.Digit0 */ && marker <= 55 /* Ch.Digit7 */) {
172
+ length = 2;
173
+ while (length < 4 && input.peek(length) >= 48 /* Ch.Digit0 */ && input.peek(length) <= 55 /* Ch.Digit7 */)
174
+ length++;
175
+ }
176
+ else if (marker == -1 /* Ch.EOF */) {
177
+ return;
178
+ }
179
+ else {
180
+ length = 2;
181
+ }
182
+ input.advance(length);
183
+ input.acceptToken(Escape);
184
+ }
185
+ function isHex(ch) {
186
+ return ((ch >= 48 /* Ch.Digit0 */ && ch <= 57 /* Ch.Digit9 */) ||
187
+ (ch >= 97 /* Ch.LowerA */ && ch <= 97 /* Ch.LowerA */ + 5) ||
188
+ (ch >= 65 /* Ch.UpperA */ && ch <= 65 /* Ch.UpperA */ + 5));
189
+ }
190
+ /**
191
+ The bracket that closes the one a raw string opened with.
192
+ */
193
+ function closingBracket(ch) {
194
+ return ch == 40 /* Ch.ParenL */ ? 41 /* Ch.ParenR */ : ch == 91 /* Ch.BracketL */ ? 93 /* Ch.BracketR */ : ch == 123 /* Ch.BraceL */ ? 125 /* Ch.BraceR */ : 0;
195
+ }
196
+ // `r"(...)"` holds whatever is between its brackets, backslashes included,
197
+ // which is what makes it the way a regular expression is written in R since
198
+ // 4.0. The dashes are there for text that holds the closing bracket itself:
199
+ // `r"---(a)"b)---"` ends at the three dashes it opened with and nowhere else,
200
+ // so the opener has to be counted and matched.
201
+ function readRaw(input) {
202
+ const quote = input.peek(1);
203
+ if (quote != 34 /* Ch.Quote */ && quote != 39 /* Ch.Apostrophe */)
204
+ return;
205
+ let dashes = 0;
206
+ while (input.peek(2 + dashes) == 45 /* Ch.Dash */)
207
+ dashes++;
208
+ const open = input.peek(2 + dashes);
209
+ const close = closingBracket(open);
210
+ if (!close)
211
+ return;
212
+ let length = 3 + dashes;
213
+ for (;;) {
214
+ const ch = input.peek(length);
215
+ if (ch == -1 /* Ch.EOF */)
216
+ break;
217
+ if (ch == close) {
218
+ let after = length + 1, seen = 0;
219
+ while (seen < dashes && input.peek(after) == 45 /* Ch.Dash */) {
220
+ after++;
221
+ seen++;
222
+ }
223
+ if (seen == dashes && input.peek(after) == quote) {
224
+ length = after + 1;
225
+ break;
226
+ }
227
+ }
228
+ length++;
229
+ }
230
+ input.advance(length);
231
+ input.acceptToken(RawString);
232
+ }
233
+
234
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
235
+ const spec_Identifier = {__proto__:null,"...":266, TRUE:268, FALSE:270, NULL:272, NA:274, NA_integer_:276, NA_real_:278, NA_character_:280, NA_complex_:282, Inf:284, NaN:286, function:64, if:84, else:86, for:90, in:92, while:96, repeat:100, break:104, next:108};
236
+ const parser = lr.LRParser.deserialize({
237
+ version: 14,
238
+ states: "6nQ#rQUOOO#yQUO'#CpO$UQUO'#CpO$aQUO'#CwO$hQUO'#CzOOQO'#C}'#C}O&wQSO'#C{O(sQTO'#FTO+dQTO'#DpO+tQSO'#DoOOQQ'#Dz'#DzOOQQ'#D}'#D}OOQQ'#EP'#EPO$hQUO'#DyO$hQUO'#DyO$hQUO'#DyOOQQ'#Ek'#EkO$hQUO'#EjO+|QSO'#ElOOQP'#FU'#FUOOQP'#FT'#FTO,[QTO'#FSOOQQ'#FS'#FSOOQQ'#Ex'#ExQ`QUOOQ`QUOOOOQP'#Cj'#CjOOQP'#Cq'#CqOOQP'#Cr'#CrOOQP'#Cs'#CsOOQP'#Ct'#CtO,dQSO'#DVO,iQSO'#DYO,nQSO'#D]O$hQUO'#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!|#w#|#}$VR#o!kT!tb!og!kV!r#^#m#n#q#s#u$X$]$ekdORShir{!O!v$U$W$h$iR!vbShOiQ{RT!yh{QvPR#OvQyQR#QyQ#y#WR$Z#yQ$O#_Q$Q#`Q$S#aV$_$O$Q$SZgORhi{YeORhi{Q|SQ!}rQ#X!OQ#r!vQ$d$UQ$f$WQ$j$hR$k$ijVORShir{!O!v$U$W$h$iQ!n]Q!p^Q!q_Q!raW#^!P!R!S#}Q#d!`Q#e!aQ#f!bQ#g!cQ#h!dQ#i!eQ#j!fQ#k!gQ#l!hQ#m!iQ#n!kQ#q!tQ#s!zQ#u!|Q$X#wQ$]#|R$e$VQ#_!PQ#`!RQ#a!SR$^#}R!xe",
241
+ nodeNames: "⚠ DoubleStart DoubleContent DoubleEnd SingleStart SingleContent SingleEnd Escape RawString LineComment DocComment Program Shebang Identifier Dots BacktickName Placeholder Number Integer Complex String Boolean Null NA Special } { Block ) ( ParenExpression FunctionDefinition function Lambda \\ ParamList Param ParamName DefaultOp = , IfExpression if else ForExpression for in WhileExpression while RepeatExpression repeat BreakExpression break NextExpression next CallExpression ArgList NamedArg ArgName ArgOp ] SubsetExpression [ Subset2Expression [[ NamespaceExpression PackageName NamespaceOp :: ::: DollarExpression DollarOp $ @ PropertyName UnaryExpression ArithOp + - LogicOp ! FormulaOp ~ BinaryExpression ArithOp ^ ** RangeOp : PipeBindOp => SpecialOp PipeOp |> ArithOp * / ArithOp CompareOp LogicOp & && LogicOp | || FormulaOp HelpExpression HelpOp Assignment AssignTarget LeftAssignOp <- <<- := RightAssignOp -> ->> Assignment EqAssignOp ;",
242
+ maxTerm: 146,
243
+ context: trackNewline,
244
+ nodeProps: [
245
+ ["isolate", 9,""],
246
+ ["openedBy", 25,"{",28,"("],
247
+ ["closedBy", 26,"}",29,")"]
248
+ ],
249
+ skippedNodes: [0,9,10],
250
+ repeatNodeCount: 5,
251
+ tokenData: "9e~R!RXY$[YZ$sZ[$[[]$[]^$spq$[qr$xst%Vtu'auv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
+ specialized: [{term: 13, get: (value) => spec_Identifier[value] || -1}],
255
+ tokenPrec: 2192
256
+ });
257
+
258
+ /**
259
+ Snippets for the constructs people write most often in R.
260
+ */
261
+ const snippets = [
262
+ autocomplete.snippetCompletion("${name} <- function(${params}) {\n\t${}\n}", {
263
+ label: "function",
264
+ detail: "definition",
265
+ type: "keyword"
266
+ }),
267
+ autocomplete.snippetCompletion("\\(${x}) ${}", {
268
+ label: "\\",
269
+ detail: "lambda",
270
+ type: "keyword"
271
+ }),
272
+ autocomplete.snippetCompletion("if (${condition}) {\n\t${}\n}", {
273
+ label: "if",
274
+ detail: "block",
275
+ type: "keyword"
276
+ }),
277
+ autocomplete.snippetCompletion("if (${condition}) {\n\t${}\n} else {\n\t\n}", {
278
+ label: "if",
279
+ detail: "/ else block",
280
+ type: "keyword"
281
+ }),
282
+ autocomplete.snippetCompletion("for (${i} in ${seq_along(x)}) {\n\t${}\n}", {
283
+ label: "for",
284
+ detail: "loop",
285
+ type: "keyword"
286
+ }),
287
+ autocomplete.snippetCompletion("while (${condition}) {\n\t${}\n}", {
288
+ label: "while",
289
+ detail: "loop",
290
+ type: "keyword"
291
+ }),
292
+ autocomplete.snippetCompletion("repeat {\n\t${}\n\tif (${condition}) break\n}", {
293
+ label: "repeat",
294
+ detail: "loop",
295
+ type: "keyword"
296
+ }),
297
+ autocomplete.snippetCompletion("switch(${x},\n\t${name} = ${value},\n\t${default}\n)", {
298
+ label: "switch",
299
+ detail: "by value",
300
+ type: "keyword"
301
+ }),
302
+ autocomplete.snippetCompletion("tryCatch({\n\t${}\n}, error = function(e) {\n\t\n})", {
303
+ label: "tryCatch",
304
+ detail: "handle errors",
305
+ type: "keyword"
306
+ })
307
+ ];
308
+ // R scopes names by function. A name assigned anywhere in a function body,
309
+ // inside an `if` or a loop as well, can be read anywhere in that body. A name
310
+ // assigned at the top of the file can be read everywhere.
311
+ const ScopeNodes = new Set(["Program", "FunctionDefinition"]);
312
+ const nameNodes = new Set(["Identifier", "BacktickName", "Dots"]);
313
+ // The name an assignment gives a value is the whole of its target. A target
314
+ // such as `names(x)`, `x[1]` or `x$a` changes a value that already has a name,
315
+ // so it declares nothing.
316
+ function assignedName(assignment) {
317
+ const target = assignment.getChild("AssignTarget");
318
+ const name = target === null || target === void 0 ? void 0 : target.firstChild;
319
+ if (!name || name.nextSibling)
320
+ return null;
321
+ return nameNodes.has(name.name) || name.name == "String" ? name : null;
322
+ }
323
+ function isSuperAssign(assignment, doc) {
324
+ const op = assignment.getChild("LeftAssignOp");
325
+ return op ? doc.sliceString(op.from, op.to) == "<<-" : false;
326
+ }
327
+ function isFunctionValue(assignment) {
328
+ const target = assignment.getChild("AssignTarget");
329
+ for (let ch = assignment.firstChild; ch; ch = ch.nextSibling)
330
+ if (ch != target && ch.name == "FunctionDefinition")
331
+ return true;
332
+ return false;
333
+ }
334
+ function walk(node, doc, def, mode) {
335
+ for (let ch = node.firstChild; ch; ch = ch.nextSibling) {
336
+ if (ch.name == "ParamList")
337
+ continue;
338
+ if (ch.name == "Assignment") {
339
+ const name = assignedName(ch);
340
+ const counts = isSuperAssign(ch, doc) ? mode != "function" : mode != "super";
341
+ if (name && counts)
342
+ def(name, isFunctionValue(ch) ? "function" : "variable");
343
+ }
344
+ else if (ch.name == "ForExpression" && mode != "super") {
345
+ const variable = ch.getChild("Identifier") || ch.getChild("BacktickName");
346
+ if (variable)
347
+ def(variable, "variable");
348
+ }
349
+ if (ch.name == "FunctionDefinition") {
350
+ if (mode != "function")
351
+ walk(ch, doc, def, "super");
352
+ }
353
+ else {
354
+ walk(ch, doc, def, mode);
355
+ }
356
+ }
357
+ }
358
+ function functionScope(node, doc, def) {
359
+ var _a;
360
+ const params = node.getChild("ParamList");
361
+ if (params)
362
+ for (const param of params.getChildren("Param")) {
363
+ const name = (_a = param.getChild("ParamName")) === null || _a === void 0 ? void 0 : _a.firstChild;
364
+ if (name)
365
+ def(name, "variable");
366
+ }
367
+ walk(node, doc, def, "function");
368
+ }
369
+ const cache = new common.NodeWeakMap();
370
+ function nameText(node, doc) {
371
+ const text = doc.sliceString(node.from, node.to);
372
+ return node.name == "String" ? text.slice(1, -1) : text;
373
+ }
374
+ function scopeNames(node, doc) {
375
+ const cached = cache.get(node);
376
+ if (cached)
377
+ return cached;
378
+ const options = [];
379
+ const seen = new Set();
380
+ const def = (name, type) => {
381
+ const label = nameText(name, doc);
382
+ if (!label || seen.has(label))
383
+ return;
384
+ seen.add(label);
385
+ options.push({ label, type });
386
+ };
387
+ if (node.name == "Program") {
388
+ walk(node, doc, def, "file");
389
+ }
390
+ else {
391
+ functionScope(node, doc, def);
392
+ }
393
+ cache.set(node, options);
394
+ return options;
395
+ }
396
+ // Completion makes no sense inside these, so neither source offers anything
397
+ // there.
398
+ const dontComplete = ["String", "RawString", "LineComment", "DocComment"];
399
+ // After `df$`, `obj@` or `pkg::` the name belongs to a column, a slot or a
400
+ // package, which this file cannot know. This reads the text, because the tree
401
+ // of a half typed `pkg::na` is not always a namespace yet.
402
+ const afterAccessor = /(::|\$|@)[\p{L}\w.]*$/u;
403
+ /**
404
+ Wraps a completion source so that it offers nothing inside strings,
405
+ comments, or after `$`, `@` and `::`.
406
+ */
407
+ function outsideLiterals(source) {
408
+ const inner = autocomplete.ifNotIn(dontComplete, source);
409
+ return context => (context.matchBefore(afterAccessor) ? null : inner(context));
410
+ }
411
+ const identifier = /^[\p{L}\w.]*$/u;
412
+ /**
413
+ Completes the names assigned in the file and the parameters of the
414
+ functions around the cursor.
415
+ */
416
+ const localCompletionSource = outsideLiterals((context) => {
417
+ const word = context.matchBefore(/[\p{L}\w.]+$/u);
418
+ if (!word && !context.explicit)
419
+ return null;
420
+ const inner = language.syntaxTree(context.state).resolveInner(context.pos, -1);
421
+ const options = [];
422
+ const seen = new Set();
423
+ for (let pos = inner; pos; pos = pos.parent) {
424
+ if (!ScopeNodes.has(pos.name))
425
+ continue;
426
+ for (const option of scopeNames(pos, context.state.doc)) {
427
+ if (seen.has(option.label))
428
+ continue;
429
+ seen.add(option.label);
430
+ options.push(option);
431
+ }
432
+ }
433
+ return {
434
+ from: word ? word.from : context.pos,
435
+ options,
436
+ validFor: identifier
437
+ };
438
+ });
439
+
440
+ const bracketed = "ArgList ParamList ParenExpression";
441
+ const subscripted = "SubsetExpression Subset2Expression";
442
+ const rLanguage = language.LRLanguage.define({
443
+ name: "r",
444
+ parser: parser.configure({
445
+ props: [
446
+ language.indentNodeProp.add({
447
+ Block: language.delimitedIndent({ closing: "}" }),
448
+ [bracketed]: language.delimitedIndent({ closing: ")" }),
449
+ [subscripted]: language.delimitedIndent({ closing: "]" }),
450
+ // A body written without braces is one line of its own, and the line
451
+ // after it belongs to whatever held the body rather than to the body.
452
+ "IfExpression ForExpression WhileExpression RepeatExpression": language.continuedIndent({ except: /^\s*(else\b|\})/ }),
453
+ FunctionDefinition: language.continuedIndent({ except: /^\s*\}/ })
454
+ }),
455
+ language.foldNodeProp.add({
456
+ Block: language.foldInside,
457
+ [bracketed]: language.foldInside,
458
+ [subscripted]: language.foldInside
459
+ }),
460
+ highlight.styleTags({
461
+ "if else for while repeat break next": highlight.tags.controlKeyword,
462
+ function: highlight.tags.definitionKeyword,
463
+ "Lambda/...": highlight.tags.definitionKeyword,
464
+ in: highlight.tags.operatorKeyword,
465
+ Boolean: highlight.tags.bool,
466
+ Null: highlight.tags.null,
467
+ "NA Special": highlight.tags.atom,
468
+ Number: highlight.tags.number,
469
+ Integer: highlight.tags.integer,
470
+ Complex: highlight.tags.number,
471
+ "String RawString": highlight.tags.string,
472
+ "DoubleStart DoubleContent DoubleEnd": highlight.tags.string,
473
+ "SingleStart SingleContent SingleEnd": highlight.tags.string,
474
+ Escape: highlight.tags.escape,
475
+ Shebang: highlight.tags.processingInstruction,
476
+ LineComment: highlight.tags.lineComment,
477
+ DocComment: highlight.tags.docComment,
478
+ Dots: highlight.tags.special(highlight.tags.variableName),
479
+ Placeholder: highlight.tags.special(highlight.tags.variableName),
480
+ // The name a function is given, which in R is the name a value is given
481
+ // and nothing else. `AssignTarget` is the one place a name is being
482
+ // written rather than read.
483
+ "AssignTarget/Identifier AssignTarget/BacktickName": highlight.tags.definition(highlight.tags.variableName),
484
+ "AssignTarget/String": highlight.tags.definition(highlight.tags.string),
485
+ "ParamName/Identifier": highlight.tags.definition(highlight.tags.variableName),
486
+ "ParamName/Dots": highlight.tags.definition(highlight.tags.special(highlight.tags.variableName)),
487
+ "CallExpression/Identifier CallExpression/BacktickName": highlight.tags.function(highlight.tags.variableName),
488
+ "CallExpression/NamespaceExpression/Identifier": highlight.tags.function(highlight.tags.variableName),
489
+ "CallExpression/DollarExpression/PropertyName/Identifier": highlight.tags.function(highlight.tags.propertyName),
490
+ "PackageName/Identifier PackageName/String": highlight.tags.namespace,
491
+ "PropertyName/Identifier PropertyName/BacktickName PropertyName/String": highlight.tags.propertyName,
492
+ "ArgName/Identifier ArgName/String ArgName/BacktickName": highlight.tags.labelName,
493
+ "Identifier BacktickName": highlight.tags.variableName,
494
+ // An operator node holds the characters it is made of as a child, and a
495
+ // tag on the parent is covered by an untagged child standing over the
496
+ // same text. The `/...` selector is the one that reaches through.
497
+ // `CompareOp` and `SpecialOp` are tokens and have nothing to reach.
498
+ "ArithOp/...": highlight.tags.arithmeticOperator,
499
+ "LogicOp/...": highlight.tags.logicOperator,
500
+ CompareOp: highlight.tags.compareOperator,
501
+ SpecialOp: highlight.tags.operator,
502
+ "PipeOp/... PipeBindOp/...": highlight.tags.controlOperator,
503
+ "FormulaOp/... RangeOp/...": highlight.tags.operator,
504
+ HelpOp: highlight.tags.operator,
505
+ "LeftAssignOp/... RightAssignOp/... EqAssignOp/...": highlight.tags.definitionOperator,
506
+ "ArgOp/... DefaultOp/...": highlight.tags.definitionOperator,
507
+ "DollarOp/... NamespaceOp/...": highlight.tags.derefOperator,
508
+ "( )": highlight.tags.paren,
509
+ "[ [[ ]": highlight.tags.squareBracket,
510
+ "{ }": highlight.tags.brace,
511
+ ", ;": highlight.tags.separator
512
+ })
513
+ ]
514
+ }),
515
+ languageData: {
516
+ commentTokens: { line: "#" },
517
+ closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
518
+ indentOnInput: /^\s*[}\])]$/
519
+ }
520
+ });
521
+ const keywords = ("if else for while repeat function break next in TRUE FALSE NULL NA Inf NaN " +
522
+ "NA_integer_ NA_real_ NA_character_ NA_complex_")
523
+ .split(" ")
524
+ .map(label => ({ label, type: "keyword" }));
525
+ // The corner of base R somebody reaches for without looking it up. Anything a
526
+ // package brings with it is left out: `library` proposes it and this list
527
+ // cannot know what was loaded.
528
+ const functions = [
529
+ "c", "vector", "list", "length", "names", "rev", "sort", "order", "unique",
530
+ "seq", "seq_len", "seq_along", "rep", "head", "tail", "which", "which.max",
531
+ "which.min", "match", "setdiff", "union", "intersect", "any", "all", "is.na",
532
+ "is.null", "is.numeric", "is.character", "is.logical", "is.function",
533
+ "as.numeric", "as.integer", "as.character", "as.logical", "as.factor",
534
+ "factor", "levels", "nchar", "substr", "substring", "strsplit", "paste",
535
+ "paste0", "sprintf", "format", "formatC", "trimws", "toupper", "tolower",
536
+ "gsub", "sub", "grepl", "grep", "regmatches", "startsWith", "endsWith",
537
+ "sum", "mean", "median", "var", "sd", "min", "max", "range", "abs", "round",
538
+ "signif", "floor", "ceiling", "sqrt", "exp", "log", "log2", "log10",
539
+ "cumsum", "prod", "diff", "table", "tabulate", "quantile", "scale",
540
+ "matrix", "array", "dim", "nrow", "ncol", "rownames", "colnames", "t",
541
+ "cbind", "rbind", "apply", "lapply", "sapply", "vapply", "mapply", "Map",
542
+ "Reduce", "Filter", "do.call", "outer", "aggregate", "split", "by",
543
+ "data.frame", "merge", "subset", "transform", "with", "within", "str",
544
+ "summary", "print", "cat", "message", "warning", "stop", "stopifnot",
545
+ "tryCatch", "try", "on.exit", "invisible", "identical", "all.equal",
546
+ "inherits", "class", "attr", "attributes", "structure", "unlist", "setNames",
547
+ "readline", "readLines", "writeLines", "readRDS", "saveRDS", "read.csv",
548
+ "write.csv", "file", "nchar", "Sys.time", "Sys.Date", "set.seed", "sample",
549
+ "runif", "rnorm", "library", "require", "requireNamespace", "source",
550
+ "suppressWarnings", "suppressMessages", "Recall", "missing", "nargs",
551
+ "environment", "new.env", "get", "exists", "assign", "rm", "ls",
552
+ "UseMethod", "NextMethod", "setClass", "setGeneric", "setMethod", "new",
553
+ "R6Class", "switch", "ifelse", "nlevels", "rapply", "return", "numeric",
554
+ "character", "logical", "integer", "double", "append", "unname", "strrep",
555
+ "utf8ToInt", "intToUtf8", "chartr", "casefold", "charToRaw", "rawToChar",
556
+ "strtoi", "bitwAnd", "bitwOr", "bitwXor", "bitwNot", "bitwShiftL",
557
+ "bitwShiftR", "intToBits", "as.hexmode", "as.roman", "choose", "factorial",
558
+ "trunc", "sign", "pmin", "pmax", "cumprod", "cummax", "cummin", "rank",
559
+ "duplicated", "anyDuplicated", "is.element", "isTRUE", "isFALSE", "xor",
560
+ "nchar", "typeof", "mode", "is.list", "is.vector", "is.integer",
561
+ "is.double", "as.list", "as.vector", "as.double", "row.names", "rowSums",
562
+ "colSums", "rowMeans", "colMeans", "diag", "Re", "Im", "Mod", "Conj",
563
+ "regexpr", "gregexpr", "regexec", "sprintf", "toString", "Negate", "Find",
564
+ "Position", "identity", "Vectorize", "local", "vapply", "mapply",
565
+ "conditionMessage", "simpleError", "warningCondition", "errorCondition",
566
+ "as.Date", "as.POSIXct", "as.POSIXlt", "difftime", "strftime", "strptime",
567
+ "weekdays", "months", "ISOdate", "ISOdatetime", "nchar", "max", "min",
568
+ "emptyenv", "globalenv", "sys.function", "match.arg", "is.environment"
569
+ ].filter((label, i, all) => all.indexOf(label) == i).map(label => ({ label, type: "function" }));
570
+ const constants = [
571
+ "T", "F", "pi", "letters", "LETTERS", "month.name", "month.abb"
572
+ ].map(label => ({ label, type: "constant" }));
573
+ /**
574
+ Autocompletion for R's reserved words, the snippets, and the part of base R
575
+ that is reached for often enough to be worth proposing. It offers nothing
576
+ inside strings and comments.
577
+ */
578
+ const rCompletion = outsideLiterals(autocomplete.completeFromList([...snippets, ...keywords, ...functions, ...constants]));
579
+ /**
580
+ R language support, with completion for the reserved words, snippets, base R
581
+ and the names assigned in the file.
582
+ */
583
+ function r() {
584
+ return new language.LanguageSupport(rLanguage, [
585
+ rLanguage.data.of({ autocomplete: rCompletion }),
586
+ rLanguage.data.of({ autocomplete: localCompletionSource })
587
+ ]);
588
+ }
589
+
590
+ exports.localCompletionSource = localCompletionSource;
591
+ exports.parser = parser;
592
+ exports.r = r;
593
+ exports.rCompletion = rCompletion;
594
+ exports.rLanguage = rLanguage;
595
+ exports.snippets = snippets;