@exercism/codemirror-lang-cobol 0.0.0-stage → 1.0.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 +115 -2
- package/dist/index.cjs +748 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +738 -0
- package/package.json +51 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
import { ExternalTokenizer, LRParser } from '@lezer/lr';
|
|
2
|
+
import { syntaxTree, foldService, LRLanguage, indentNodeProp, flatIndent, continuedIndent, foldNodeProp, LanguageSupport } from '@codemirror/language';
|
|
3
|
+
import { styleTags, tags } from '@lezer/highlight';
|
|
4
|
+
import { snippetCompletion, completeFromList } from '@codemirror/autocomplete';
|
|
5
|
+
|
|
6
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
7
|
+
const SequenceArea = 1,
|
|
8
|
+
FixedComment = 2,
|
|
9
|
+
Identifier = 3,
|
|
10
|
+
Number = 4,
|
|
11
|
+
String = 5,
|
|
12
|
+
PictureString = 6,
|
|
13
|
+
CommentEntry = 7,
|
|
14
|
+
Verb = 8,
|
|
15
|
+
Keyword = 9,
|
|
16
|
+
Figurative = 10,
|
|
17
|
+
ScopeTerminator = 11,
|
|
18
|
+
SectionName = 12,
|
|
19
|
+
SectionKeyword = 13,
|
|
20
|
+
Identification = 14,
|
|
21
|
+
Environment = 15,
|
|
22
|
+
Data = 16,
|
|
23
|
+
Procedure = 17,
|
|
24
|
+
Division = 18,
|
|
25
|
+
Section = 19,
|
|
26
|
+
ProgramId = 20,
|
|
27
|
+
CommentParagraphKeyword = 21,
|
|
28
|
+
EnvParagraphKeyword = 22,
|
|
29
|
+
Select = 23,
|
|
30
|
+
FileDescriptor = 24,
|
|
31
|
+
Filler = 25,
|
|
32
|
+
Pic = 26,
|
|
33
|
+
Indexed = 27,
|
|
34
|
+
By = 28,
|
|
35
|
+
If = 29,
|
|
36
|
+
Then = 30,
|
|
37
|
+
Else = 31,
|
|
38
|
+
EndIf = 32,
|
|
39
|
+
Evaluate = 33,
|
|
40
|
+
When = 34,
|
|
41
|
+
EndEvaluate = 35,
|
|
42
|
+
Perform = 36,
|
|
43
|
+
EndPerform = 37,
|
|
44
|
+
Until = 38,
|
|
45
|
+
Varying = 39,
|
|
46
|
+
With = 40,
|
|
47
|
+
Times = 41,
|
|
48
|
+
Thru = 42,
|
|
49
|
+
Search = 43,
|
|
50
|
+
EndSearch = 44,
|
|
51
|
+
Function = 45,
|
|
52
|
+
EndProgram = 46,
|
|
53
|
+
endOfFile = 111;
|
|
54
|
+
|
|
55
|
+
const newline = 10, carriageReturn = 13, space = 32, tab = 9;
|
|
56
|
+
const doubleQuote = 34, singleQuote = 39, hyphen = 45, underscore = 95, dot = 46;
|
|
57
|
+
const star = 42, slash = 47, comma = 44, semicolon = 59;
|
|
58
|
+
function isEOL(ch) {
|
|
59
|
+
return ch == newline || ch == carriageReturn || ch < 0;
|
|
60
|
+
}
|
|
61
|
+
function isSpace(ch) {
|
|
62
|
+
return ch == space || ch == tab;
|
|
63
|
+
}
|
|
64
|
+
function isAlnum(ch) {
|
|
65
|
+
return (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122);
|
|
66
|
+
}
|
|
67
|
+
function isDigit(ch) {
|
|
68
|
+
return ch >= 48 && ch <= 57;
|
|
69
|
+
}
|
|
70
|
+
function upper(ch) {
|
|
71
|
+
return ch >= 97 && ch <= 122 ? ch - 32 : ch;
|
|
72
|
+
}
|
|
73
|
+
// Fixed format: columns 1 to 6 hold a sequence number, and column 7 is the
|
|
74
|
+
// indicator. A `*` or `/` there makes the whole line a comment. A `-`
|
|
75
|
+
// continues the previous line, and a `D` marks a debugging line, which we
|
|
76
|
+
// treat as normal code.
|
|
77
|
+
const lineStart = new ExternalTokenizer((input) => {
|
|
78
|
+
let prev = input.peek(-1);
|
|
79
|
+
if (prev >= 0 && prev != newline)
|
|
80
|
+
return;
|
|
81
|
+
let len = 0;
|
|
82
|
+
while (len < 7 && !isEOL(input.peek(len)))
|
|
83
|
+
len++;
|
|
84
|
+
if (len == 7) {
|
|
85
|
+
let indicator = input.peek(6);
|
|
86
|
+
if (indicator == star || indicator == slash) {
|
|
87
|
+
while (!isEOL(input.next))
|
|
88
|
+
input.advance();
|
|
89
|
+
input.acceptToken(FixedComment);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
let ind = upper(indicator);
|
|
93
|
+
let marked = indicator == hyphen || (ind == 68 /* D */ && isSpace(input.peek(7)));
|
|
94
|
+
let filled = false;
|
|
95
|
+
for (let i = 0; i < 6; i++)
|
|
96
|
+
if (!isSpace(input.peek(i)))
|
|
97
|
+
filled = true;
|
|
98
|
+
if (marked)
|
|
99
|
+
input.acceptToken(SequenceArea, 7);
|
|
100
|
+
else if (filled)
|
|
101
|
+
input.acceptToken(SequenceArea, 6);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// A short line with something in the sequence area, such as "000100".
|
|
105
|
+
let filled = false;
|
|
106
|
+
for (let i = 0; i < len; i++)
|
|
107
|
+
if (!isSpace(input.peek(i)))
|
|
108
|
+
filled = true;
|
|
109
|
+
if (filled && len == 6)
|
|
110
|
+
input.acceptToken(SequenceArea, 6);
|
|
111
|
+
});
|
|
112
|
+
const verbs$1 = new Set(("ACCEPT ADD ALLOCATE ALTER CALL CANCEL CLOSE COMMIT COMPUTE CONTINUE COPY DELETE DISPLAY " +
|
|
113
|
+
"DIVIDE ENTRY EXIT FREE GENERATE GO GOBACK INITIALIZE INITIATE INSPECT INVOKE MERGE MOVE " +
|
|
114
|
+
"MULTIPLY OPEN RAISE READ RELEASE REPLACE RESUME RETURN REWRITE ROLLBACK SET SORT START STOP " +
|
|
115
|
+
"STRING SUBTRACT SUPPRESS TERMINATE TRANSFORM UNLOCK UNSTRING VALIDATE WRITE").split(" "));
|
|
116
|
+
const scopeTerminators = new Set(("END-ACCEPT END-ADD END-CALL END-COMPUTE END-DELETE END-DISPLAY END-DIVIDE END-MULTIPLY " +
|
|
117
|
+
"END-READ END-RETURN END-REWRITE END-START END-STRING END-SUBTRACT END-UNSTRING END-WRITE " +
|
|
118
|
+
"END-EXEC END-INVOKE").split(" "));
|
|
119
|
+
const figuratives = new Set(("ZERO ZEROS ZEROES SPACE SPACES HIGH-VALUE HIGH-VALUES LOW-VALUE LOW-VALUES QUOTE QUOTES " +
|
|
120
|
+
"NULL NULLS TRUE FALSE").split(" "));
|
|
121
|
+
const keywords$1 = new Set(("ACCESS ADDRESS ADVANCING AFTER ALL ALPHABET ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER " +
|
|
122
|
+
"ALPHANUMERIC ALPHANUMERIC-EDITED ALSO AND ANY ARE AREA AREAS ASCENDING ASSIGN AT BASED " +
|
|
123
|
+
"BEFORE BINARY BINARY-CHAR BINARY-DOUBLE BINARY-LONG BINARY-SHORT BIT BLANK BLOCK BOOLEAN " +
|
|
124
|
+
"BOTTOM CHARACTER CHARACTERS CLASS COLLATING COMMON COMP COMP-1 COMP-2 COMP-3 COMP-4 " +
|
|
125
|
+
"COMP-5 COMP-6 COMP-X COMPUTATIONAL COMPUTATIONAL-1 COMPUTATIONAL-2 COMPUTATIONAL-3 " +
|
|
126
|
+
"COMPUTATIONAL-4 COMPUTATIONAL-5 COMPUTATIONAL-X CONFIGURATION CONSOLE CONTAINS CONTENT " +
|
|
127
|
+
"CONVERTING CORR CORRESPONDING CRT CURRENCY CURSOR CYCLE DEBUGGING DECIMAL-POINT " +
|
|
128
|
+
"DECLARATIVES DEFAULT DELIMITED DELIMITER DEPENDING DESCENDING DOWN DUPLICATES DYNAMIC END " +
|
|
129
|
+
"EQUAL EQUALS ERROR EXCEPTION EXTEND EXTERNAL FILE FLOAT-LONG FLOAT-SHORT FOR FROM " +
|
|
130
|
+
"GIVING GLOBAL GREATER IN INITIAL INPUT INPUT-OUTPUT INTO INTRINSIC INVALID I-O IS JUST " +
|
|
131
|
+
"JUSTIFIED KEY LEADING LEFT LESS LINAGE LINKAGE LOCAL-STORAGE LOCK MODE " +
|
|
132
|
+
"NATIONAL NATIVE NEGATIVE NEXT NO NOT NUMERIC NUMERIC-EDITED OCCURS OF OFF OMITTED ON " +
|
|
133
|
+
"OPTIONAL OR ORGANIZATION OTHER OUTPUT OVERFLOW PACKED-DECIMAL POINTER POSITIVE PROGRAM " +
|
|
134
|
+
"PROGRAM-POINTER RECORD RECORDING RECORDS RECURSIVE REDEFINES REFERENCE RELATIVE REMAINDER " +
|
|
135
|
+
"RENAMES REPLACING REPORT RETURNING REWIND RIGHT ROUNDED RUN SCREEN SENTENCE " +
|
|
136
|
+
"SEPARATE SEQUENTIAL SIGN SIZE STANDARD STATUS SYNC SYNCHRONIZED TALLYING TEST THAN TO " +
|
|
137
|
+
"TRAILING UP UPON USAGE USING VALUE VALUES WORKING-STORAGE").split(" "));
|
|
138
|
+
const specific = {
|
|
139
|
+
IDENTIFICATION: Identification, ID: Identification,
|
|
140
|
+
ENVIRONMENT: Environment, DATA: Data, PROCEDURE: Procedure,
|
|
141
|
+
DIVISION: Division, SECTION: Section,
|
|
142
|
+
"PROGRAM-ID": ProgramId, "FUNCTION-ID": ProgramId,
|
|
143
|
+
AUTHOR: CommentParagraphKeyword, INSTALLATION: CommentParagraphKeyword,
|
|
144
|
+
"DATE-WRITTEN": CommentParagraphKeyword, "DATE-COMPILED": CommentParagraphKeyword,
|
|
145
|
+
SECURITY: CommentParagraphKeyword, REMARKS: CommentParagraphKeyword,
|
|
146
|
+
"SOURCE-COMPUTER": EnvParagraphKeyword, "OBJECT-COMPUTER": EnvParagraphKeyword,
|
|
147
|
+
"SPECIAL-NAMES": EnvParagraphKeyword, REPOSITORY: EnvParagraphKeyword,
|
|
148
|
+
"FILE-CONTROL": EnvParagraphKeyword, "I-O-CONTROL": EnvParagraphKeyword,
|
|
149
|
+
SELECT: Select, FD: FileDescriptor, SD: FileDescriptor, RD: FileDescriptor,
|
|
150
|
+
FILLER: Filler, PIC: Pic, PICTURE: Pic, INDEXED: Indexed, BY: By,
|
|
151
|
+
IF: If, THEN: Then, ELSE: Else, "END-IF": EndIf,
|
|
152
|
+
EVALUATE: Evaluate, WHEN: When, "END-EVALUATE": EndEvaluate,
|
|
153
|
+
PERFORM: Perform, "END-PERFORM": EndPerform,
|
|
154
|
+
UNTIL: Until, VARYING: Varying, WITH: With, TIMES: Times, THRU: Thru, THROUGH: Thru,
|
|
155
|
+
SEARCH: Search, "END-SEARCH": EndSearch, FUNCTION: Function,
|
|
156
|
+
};
|
|
157
|
+
// Words that join the word after them into one token, so that the
|
|
158
|
+
// grammar can tell `EXIT PERFORM` from `EXIT` followed by `PERFORM`, and
|
|
159
|
+
// `END PROGRAM` from the `END` in `AT END`.
|
|
160
|
+
const exitTargets = new Set("PERFORM PARAGRAPH SECTION PROGRAM FUNCTION METHOD".split(" "));
|
|
161
|
+
const endTargets = new Set("PROGRAM FUNCTION DECLARATIVES METHOD CLASS".split(" "));
|
|
162
|
+
function wordAt(input, offset) {
|
|
163
|
+
let end = offset;
|
|
164
|
+
while (true) {
|
|
165
|
+
let ch = input.peek(end);
|
|
166
|
+
if (isAlnum(ch) || ch == underscore)
|
|
167
|
+
end++;
|
|
168
|
+
else if (ch == hyphen && (isAlnum(input.peek(end + 1)) || input.peek(end + 1) == hyphen))
|
|
169
|
+
end++;
|
|
170
|
+
else
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
// A word never ends with a hyphen.
|
|
174
|
+
while (end > offset && input.peek(end - 1) == hyphen)
|
|
175
|
+
end--;
|
|
176
|
+
let text = "";
|
|
177
|
+
for (let i = offset; i < end; i++)
|
|
178
|
+
text += globalThis.String.fromCharCode(upper(input.peek(i)));
|
|
179
|
+
return { end, text };
|
|
180
|
+
}
|
|
181
|
+
function skipSpaces(input, offset) {
|
|
182
|
+
while (isSpace(input.peek(offset)))
|
|
183
|
+
offset++;
|
|
184
|
+
return offset;
|
|
185
|
+
}
|
|
186
|
+
// Reads a quoted literal that starts at `offset`. If the line ends before
|
|
187
|
+
// the closing quote, and the next line has a `-` in column 7, the literal
|
|
188
|
+
// continues after the first quote on that line.
|
|
189
|
+
function stringEnd(input, offset) {
|
|
190
|
+
let quote = input.peek(offset);
|
|
191
|
+
let pos = offset + 1;
|
|
192
|
+
for (;;) {
|
|
193
|
+
let ch = input.peek(pos);
|
|
194
|
+
if (ch == quote) {
|
|
195
|
+
if (input.peek(pos + 1) == quote) {
|
|
196
|
+
pos += 2;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
return pos + 1;
|
|
200
|
+
}
|
|
201
|
+
if (isEOL(ch)) {
|
|
202
|
+
let next = pos;
|
|
203
|
+
if (input.peek(next) == carriageReturn)
|
|
204
|
+
next++;
|
|
205
|
+
if (input.peek(next) != newline)
|
|
206
|
+
return pos;
|
|
207
|
+
next++;
|
|
208
|
+
let len = 0;
|
|
209
|
+
while (len < 7 && !isEOL(input.peek(next + len)))
|
|
210
|
+
len++;
|
|
211
|
+
if (len < 7 || input.peek(next + 6) != hyphen)
|
|
212
|
+
return pos;
|
|
213
|
+
let q = skipSpaces(input, next + 7);
|
|
214
|
+
if (input.peek(q) != quote)
|
|
215
|
+
return pos;
|
|
216
|
+
pos = q + 1;
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
pos++;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function pictureEnd(input) {
|
|
223
|
+
let pos = 0;
|
|
224
|
+
for (;;) {
|
|
225
|
+
let ch = input.peek(pos);
|
|
226
|
+
if (isEOL(ch) || isSpace(ch))
|
|
227
|
+
break;
|
|
228
|
+
if (ch == dot || ch == comma || ch == semicolon) {
|
|
229
|
+
let after = input.peek(pos + 1);
|
|
230
|
+
if (isEOL(after) || isSpace(after))
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
pos++;
|
|
234
|
+
}
|
|
235
|
+
return pos;
|
|
236
|
+
}
|
|
237
|
+
// A comment entry is the free text after `AUTHOR.` and similar paragraph
|
|
238
|
+
// names in the IDENTIFICATION DIVISION. A line that starts a new
|
|
239
|
+
// paragraph or division ends it.
|
|
240
|
+
function commentEntryEnd(input) {
|
|
241
|
+
// On the line of `AUTHOR.` itself, the rest of the line is the entry.
|
|
242
|
+
let back = -1;
|
|
243
|
+
while (back > -20 && isSpace(input.peek(back)))
|
|
244
|
+
back--;
|
|
245
|
+
let sameLine = input.peek(back) == dot;
|
|
246
|
+
let { end, text } = wordAt(input, 0);
|
|
247
|
+
if (end > 0 && !sameLine) {
|
|
248
|
+
let after = skipSpaces(input, end);
|
|
249
|
+
if (input.peek(after) == dot)
|
|
250
|
+
return 0;
|
|
251
|
+
let { text: next } = wordAt(input, after);
|
|
252
|
+
if (next == "DIVISION" || next == "SECTION")
|
|
253
|
+
return 0;
|
|
254
|
+
if (text in specific && specific[text] == CommentParagraphKeyword)
|
|
255
|
+
return 0;
|
|
256
|
+
}
|
|
257
|
+
let pos = 0;
|
|
258
|
+
while (!isEOL(input.peek(pos)))
|
|
259
|
+
pos++;
|
|
260
|
+
return pos;
|
|
261
|
+
}
|
|
262
|
+
const words = new ExternalTokenizer((input, stack) => {
|
|
263
|
+
let ch = input.next;
|
|
264
|
+
// GnuCOBOL accepts a missing period at the end of the file, so the
|
|
265
|
+
// grammar can end a sentence with this empty token.
|
|
266
|
+
if (ch < 0) {
|
|
267
|
+
if (stack.canShift(endOfFile))
|
|
268
|
+
input.acceptToken(endOfFile);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (isEOL(ch) || isSpace(ch))
|
|
272
|
+
return;
|
|
273
|
+
if (stack.canShift(CommentEntry)) {
|
|
274
|
+
let end = commentEntryEnd(input);
|
|
275
|
+
if (end > 0) {
|
|
276
|
+
input.acceptToken(CommentEntry, end);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (stack.canShift(PictureString) && ch != doubleQuote && ch != singleQuote) {
|
|
281
|
+
let { end, text } = wordAt(input, 0);
|
|
282
|
+
if (!(text == "IS" && isSpace(input.peek(end)))) {
|
|
283
|
+
let pend = pictureEnd(input);
|
|
284
|
+
if (pend > 0) {
|
|
285
|
+
input.acceptToken(PictureString, pend);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (ch == doubleQuote || ch == singleQuote) {
|
|
291
|
+
input.acceptToken(String, stringEnd(input, 0));
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (!isAlnum(ch))
|
|
295
|
+
return;
|
|
296
|
+
// Hexadecimal, national and boolean literals, such as X"0A".
|
|
297
|
+
let u = upper(ch);
|
|
298
|
+
let next = input.peek(1);
|
|
299
|
+
if ((u == 88 || u == 90 || u == 78 || u == 66 || u == 72) && (next == doubleQuote || next == singleQuote)) {
|
|
300
|
+
input.acceptToken(String, stringEnd(input, 1));
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
let { end, text } = wordAt(input, 0);
|
|
304
|
+
if (end == 0)
|
|
305
|
+
return;
|
|
306
|
+
if (/^[0-9]+$/.test(text)) {
|
|
307
|
+
if (input.peek(end) == dot && isDigit(input.peek(end + 1))) {
|
|
308
|
+
end += 2;
|
|
309
|
+
while (isDigit(input.peek(end)))
|
|
310
|
+
end++;
|
|
311
|
+
}
|
|
312
|
+
input.acceptToken(Number, end);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
let after = skipSpaces(input, end);
|
|
316
|
+
let { end: nextEnd, text: nextWord } = wordAt(input, after);
|
|
317
|
+
if (text == "EXIT" && exitTargets.has(nextWord)) {
|
|
318
|
+
input.acceptToken(Verb, nextEnd);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (text == "NEXT" && nextWord == "SENTENCE") {
|
|
322
|
+
input.acceptToken(Verb, nextEnd);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (text == "END" && endTargets.has(nextWord)) {
|
|
326
|
+
input.acceptToken(EndProgram, nextEnd);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (nextWord == "SECTION") {
|
|
330
|
+
input.acceptToken(keywords$1.has(text) ? SectionKeyword : SectionName, end);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
let token = Identifier;
|
|
334
|
+
if (text in specific)
|
|
335
|
+
token = specific[text];
|
|
336
|
+
else if (verbs$1.has(text))
|
|
337
|
+
token = Verb;
|
|
338
|
+
else if (scopeTerminators.has(text))
|
|
339
|
+
token = ScopeTerminator;
|
|
340
|
+
else if (figuratives.has(text))
|
|
341
|
+
token = Figurative;
|
|
342
|
+
else if (keywords$1.has(text))
|
|
343
|
+
token = Keyword;
|
|
344
|
+
input.acceptToken(token, end);
|
|
345
|
+
}, { contextual: true });
|
|
346
|
+
|
|
347
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
348
|
+
const parser = LRParser.deserialize({
|
|
349
|
+
version: 14,
|
|
350
|
+
states: "=QQiQVOOO!QQTO'#DbO!VQTO'#DdOOQR'#Et'#EtO![QVO'#D`O!aQVO'#DeO!fQVO'#DsO!kQVO'#EOO!pQVO'#E[OOQR'#E]'#E]QiQVOOO!{QVO,59|O#WQVO,5:OO#uQTO,59zO#zQTO,5:PO$PQTO,5:_O%YQVO,5:jOOQR,5:v,5:vO%aQTO,5:vOOQR-E8Z-E8ZOOQR'#Dc'#DcO%fQVO1G/hOOQR'#E`'#E`O&^QVO1G/jO&{QVO1G/fO'gQVO1G/kO(XQVO1G/yO(yQVO'#DoOOQR'#Ey'#EyOOQR'#Ex'#ExOOQR'#Ew'#EwOOQR'#Ed'#EdO)RQVO1G0UO)YQVO'#DnOOQR'#Ev'#EvO*RQVO1G0UOOQR1G0b1G0bOOQR'#Eu'#EuOOQR'#E_'#E_O*oQVO7+%SOOQR7+%S7+%SOOQR-E8^-E8^OOQR'#E^'#E^O+gQVO7+%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%^$nQp`f!Vp!X#T#U#Z#g$]$d%U%V%lQ!XqQ#T!ZQ#U![Q#Z!]Q#g!_Q$]#[Q$d#fQ%U$aQ%V$cR%l%fQ!SjR!}!SQ!{!QR$Q!{Q$O!xQ$t#yQ$v#{V$x$O$t$vQ!esQ#P!WW#k!e#P#n$iQ#n!jR$i#l`!bs!W!e!j#P#l#n$iR#i!bp#W![!^!_#U#Y#[#f#g$V$Y$]$c$d$}%V%eR$W#WQ#^!]Q$Z#ZW$_#^$Z$g%YQ$g#hR%Y$fQ!isS#Q!W!eY#m!i#Q#o$S$jQ#o!jQ$S#PR$j#nQ!lsU#R!W!e!iW#p!l#R$T${S$T#P#QR${$SSXOYTzh{Tvew!bl`pq!X!Z![!]!_!v!x#T#U#Z#[#c#f#g#y#{$O$]$a$c$d$t$v$z%T%U%V%f%lT$m#s$n}o`pq!X!Z![!]!_#T#U#Z#[#f#g$]$a$c$d%U%V%f%l|n`pq!X!Z![!]!_#T#U#Z#[#f#g$]$a$c$d%U%V%f%lQ$a#cR%f%T!Qm`pq!X!Z![!]!_#T#U#Z#[#c#f#g$]$a$c$d%T%U%V%f%la#x!v!x#y#{$O$t$v$zT!z!Q!{Q#z!vR%b$z]#}!x#y#{$O$t$vS#y!v$z]#|!x#y#{$O$t$vb!as!W!b!e!j#P#l#n$is#V![!^!_#U#W#Y#[#f#g$V$Y$]$c$d$}%V%eQ#X![Q#d!^Q#h!_S$U#U#YQ$^#[Q$e#fQ$f#gQ%O$VQ%P$YQ%R$]S%W$c$dQ%c$}Q%g%VR%k%eR#e!^R#f!^",
|
|
353
|
+
nodeNames: "⚠ SequenceArea FixedComment Identifier Number String PictureString CommentEntry Verb Keyword Figurative ScopeTerminator SectionName SectionKeyword Identification Environment Data Procedure Division Section ProgramId CommentParagraphKeyword EnvParagraphKeyword Select FileDescriptor Filler Pic Indexed By If Then Else EndIf Evaluate When EndEvaluate Perform EndPerform Until Varying With Times Thru Search EndSearch Function EndProgram LineComment Directive Program IdentificationDivision . ProgramIdParagraph ProgramName CommentParagraph EnvironmentDivision EnvSection SectionHeader EnvParagraph ArithOp CompareOp : ) ( ParenGroup FunctionCall FunctionName FileControlEntry FileName DataDivision DataSection DataEntry LevelNumber DataName PictureClause IndexedBy IndexName FileDescription CopyDirective DataEntry ProcedureDivision Sentence Statement IfStatement EvaluateStatement WhenClause PerformStatement ProcedureName SearchStatement Paragraph ParagraphName ProcedureSection EndProgramHeader",
|
|
354
|
+
maxTerm: 129,
|
|
355
|
+
nodeProps: [
|
|
356
|
+
["openedBy", 62,"("],
|
|
357
|
+
["closedBy", 63,")"]
|
|
358
|
+
],
|
|
359
|
+
skippedNodes: [0,1,2,47,48],
|
|
360
|
+
repeatNodeCount: 17,
|
|
361
|
+
tokenData: "%U~RbXY!ZYZ!i]^!Zpq!Zvw!nxy!syz!xz{!}{|!n|}#q}!O!n!O!P#v!P!Q!n![!]#{!]!^#q!^!_$Q!_!`$]!`!a$b~!`R#e~XY!Z]^!Zpq!Z~!nO#f~~!sO!]~~!xO!a~~!}O!`~~#SQ!]~z{!n!`!a#Y~#_S!P~OY#YZ;'S#Y;'S;=`#k<%lO#Y~#nP;=`<%l#Y~#vO#g~~#{O!T~~$QO!_~~$VQ!^~!_!`$]!`!a$]~$bO!^~~$gQ!^~!_!`$]!`!a$m~$rS!Q~OY$mZ;'S$m;'S;=`%O<%lO$m~%RP;=`<%l$m",
|
|
362
|
+
tokenizers: [lineStart, words, 0],
|
|
363
|
+
topRules: {"Program":[0,49]},
|
|
364
|
+
tokenPrec: 3336
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
/// The verbs that start a statement, such as `MOVE` and `PERFORM`.
|
|
368
|
+
const verbs = ("ACCEPT ADD CALL CANCEL CLOSE COMPUTE CONTINUE COPY DELETE DISPLAY DIVIDE EVALUATE " +
|
|
369
|
+
"EXIT GO GOBACK IF INITIALIZE INSPECT MERGE MOVE MULTIPLY OPEN PERFORM READ RELEASE " +
|
|
370
|
+
"RETURN REWRITE SEARCH SET SORT START STOP STRING SUBTRACT UNSTRING WRITE").split(" ");
|
|
371
|
+
/// The other reserved words, such as `TO`, `GIVING` and `END-IF`.
|
|
372
|
+
const keywords = ("IDENTIFICATION ENVIRONMENT DATA PROCEDURE DIVISION SECTION PROGRAM-ID AUTHOR " +
|
|
373
|
+
"CONFIGURATION REPOSITORY INPUT-OUTPUT FILE-CONTROL SELECT ASSIGN ORGANIZATION " +
|
|
374
|
+
"WORKING-STORAGE LOCAL-STORAGE LINKAGE FILE FD PIC PICTURE VALUE VALUES OCCURS " +
|
|
375
|
+
"INDEXED DEPENDING REDEFINES RENAMES USAGE COMP COMP-3 COMP-5 BINARY PACKED-DECIMAL " +
|
|
376
|
+
"FILLER SIGN LEADING TRAILING SEPARATE JUSTIFIED " +
|
|
377
|
+
"TO FROM BY INTO GIVING REMAINDER ROUNDED USING RETURNING " +
|
|
378
|
+
"THEN ELSE END-IF WHEN OTHER ALSO END-EVALUATE UNTIL VARYING AFTER BEFORE WITH TEST " +
|
|
379
|
+
"TIMES THRU THROUGH END-PERFORM END-SEARCH END-STRING END-UNSTRING END-COMPUTE " +
|
|
380
|
+
"END-ADD END-SUBTRACT END-MULTIPLY END-DIVIDE END-READ END-WRITE END-CALL " +
|
|
381
|
+
"AND OR NOT IS EQUAL GREATER LESS THAN NUMERIC ALPHABETIC POSITIVE NEGATIVE " +
|
|
382
|
+
"DELIMITED SIZE POINTER TALLYING REPLACING CONVERTING CHARACTERS ALL LEADING FIRST " +
|
|
383
|
+
"INITIAL FOR AT END ON ERROR OVERFLOW EXCEPTION INVALID KEY NO ADVANCING UPON " +
|
|
384
|
+
"RUN PROGRAM PARAGRAPH CYCLE FUNCTION INTRINSIC ASCENDING DESCENDING INPUT OUTPUT " +
|
|
385
|
+
"EXTEND OF IN COUNT UP DOWN ADDRESS LENGTH").split(" ");
|
|
386
|
+
/// The figurative constants, such as `ZERO` and `SPACES`.
|
|
387
|
+
const constants = ("ZERO ZEROS ZEROES SPACE SPACES HIGH-VALUE HIGH-VALUES LOW-VALUE LOW-VALUES QUOTE QUOTES " +
|
|
388
|
+
"NULL TRUE FALSE").split(" ");
|
|
389
|
+
/// The intrinsic functions, called as `FUNCTION name(args)`.
|
|
390
|
+
const functions = ("ABS ACOS ANNUITY ASIN ATAN BYTE-LENGTH CHAR COMBINED-DATETIME CONCATENATE COS " +
|
|
391
|
+
"CURRENT-DATE DATE-OF-INTEGER DATE-TO-YYYYMMDD DAY-OF-INTEGER DAY-TO-YYYYDDD E EXP EXP10 " +
|
|
392
|
+
"FACTORIAL FRACTION-PART HEX-OF INTEGER INTEGER-OF-DATE INTEGER-OF-DAY INTEGER-PART " +
|
|
393
|
+
"LENGTH LOG LOG10 LOWER-CASE MAX MEAN MEDIAN MIDRANGE MIN MOD NUMVAL NUMVAL-C ORD " +
|
|
394
|
+
"ORD-MAX ORD-MIN PI PRESENT-VALUE RANDOM RANGE REM REVERSE SECONDS-PAST-MIDNIGHT SIGN " +
|
|
395
|
+
"SIN SQRT STANDARD-DEVIATION SUBSTITUTE SUM TAN TRIM UPPER-CASE VARIANCE WHEN-COMPILED").split(" ");
|
|
396
|
+
const snippetTemplates = [
|
|
397
|
+
{
|
|
398
|
+
label: "IDENTIFICATION DIVISION",
|
|
399
|
+
detail: "with PROGRAM-ID",
|
|
400
|
+
template: "IDENTIFICATION DIVISION.\nPROGRAM-ID. ${name}.\n${}",
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
label: "ENVIRONMENT DIVISION",
|
|
404
|
+
detail: "with intrinsic functions",
|
|
405
|
+
template: "ENVIRONMENT DIVISION.\nCONFIGURATION SECTION.\nREPOSITORY. FUNCTION ALL INTRINSIC.\n${}",
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
label: "DATA DIVISION",
|
|
409
|
+
detail: "with WORKING-STORAGE",
|
|
410
|
+
template: "DATA DIVISION.\nWORKING-STORAGE SECTION.\n01 ${name} PIC ${X(10)}.\n${}",
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
label: "PROCEDURE DIVISION",
|
|
414
|
+
detail: "with a paragraph",
|
|
415
|
+
template: "PROCEDURE DIVISION.\n${MAIN-PARAGRAPH}.\n\t${}\n\tGOBACK.",
|
|
416
|
+
},
|
|
417
|
+
{ label: "PIC", detail: "data item", template: "01 ${name} PIC ${X(10)}." },
|
|
418
|
+
{ label: "OCCURS", detail: "table", template: "01 ${table}.\n\t05 ${entry} OCCURS ${10} TIMES PIC ${X}." },
|
|
419
|
+
{
|
|
420
|
+
label: "PERFORM VARYING",
|
|
421
|
+
detail: "loop",
|
|
422
|
+
template: "PERFORM VARYING ${I} FROM 1 BY 1 UNTIL ${I} > ${N}\n\t${}\nEND-PERFORM",
|
|
423
|
+
},
|
|
424
|
+
{ label: "PERFORM UNTIL", detail: "loop", template: "PERFORM UNTIL ${condition}\n\t${}\nEND-PERFORM" },
|
|
425
|
+
{ label: "PERFORM TIMES", detail: "loop", template: "PERFORM ${N} TIMES\n\t${}\nEND-PERFORM" },
|
|
426
|
+
{ label: "IF", detail: "block", template: "IF ${condition}\n\t${}\nEND-IF" },
|
|
427
|
+
{ label: "IF", detail: "/ ELSE block", template: "IF ${condition}\n\t${}\nELSE\n\t${}\nEND-IF" },
|
|
428
|
+
{
|
|
429
|
+
label: "EVALUATE",
|
|
430
|
+
detail: "block",
|
|
431
|
+
template: "EVALUATE ${subject}\n\tWHEN ${value}\n\t\t${}\n\tWHEN OTHER\n\t\t${}\nEND-EVALUATE",
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
label: "EVALUATE TRUE",
|
|
435
|
+
detail: "block",
|
|
436
|
+
template: "EVALUATE TRUE\n\tWHEN ${condition}\n\t\t${}\n\tWHEN OTHER\n\t\t${}\nEND-EVALUATE",
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
label: "STRING",
|
|
440
|
+
detail: "concatenation",
|
|
441
|
+
template: "STRING ${a} DELIMITED BY SIZE\n\t${b} DELIMITED BY SIZE\n\tINTO ${result}\nEND-STRING",
|
|
442
|
+
},
|
|
443
|
+
];
|
|
444
|
+
// Keywords are offered in the case the student is typing in, so that
|
|
445
|
+
// someone who writes `move` gets `to` and not `TO`.
|
|
446
|
+
function caseOf(context) {
|
|
447
|
+
let word = context.matchBefore(/[A-Za-z][\w-]*$/);
|
|
448
|
+
return word && /[a-z]/.test(word.text) && !/[A-Z]/.test(word.text) ? "lower" : "upper";
|
|
449
|
+
}
|
|
450
|
+
function buildCompletions(lower) {
|
|
451
|
+
let c = (label) => (lower ? label.toLowerCase() : label);
|
|
452
|
+
return [
|
|
453
|
+
...verbs.map((label) => ({ label: c(label), type: "keyword" })),
|
|
454
|
+
...keywords.filter((k) => verbs.indexOf(k) < 0).map((label) => ({ label: c(label), type: "keyword" })),
|
|
455
|
+
...constants.map((label) => ({ label: c(label), type: "constant" })),
|
|
456
|
+
...functions.map((label) => ({ label: c(label), type: "function", detail: "intrinsic" })),
|
|
457
|
+
...snippetTemplates.map((s) => snippetCompletion(lower ? lowerTemplate(s.template) : s.template, {
|
|
458
|
+
label: c(s.label),
|
|
459
|
+
detail: s.detail,
|
|
460
|
+
type: "keyword",
|
|
461
|
+
})),
|
|
462
|
+
];
|
|
463
|
+
}
|
|
464
|
+
// Lowercases a snippet's code and leaves its placeholders as they are.
|
|
465
|
+
function lowerTemplate(template) {
|
|
466
|
+
return template.split(/(\$\{[^}]*\})/).map((part, i) => (i % 2 ? part : part.toLowerCase())).join("");
|
|
467
|
+
}
|
|
468
|
+
const upperCompletions = buildCompletions(false);
|
|
469
|
+
const lowerCompletions = buildCompletions(true);
|
|
470
|
+
/// Snippets for the four divisions, data items, loops, IF and EVALUATE.
|
|
471
|
+
const snippets = snippetTemplates.map((s) => snippetCompletion(s.template, { label: s.label, detail: s.detail, type: "keyword" }));
|
|
472
|
+
const dontComplete = [
|
|
473
|
+
"String", "PictureString", "LineComment", "FixedComment", "CommentEntry", "SequenceArea", "Directive",
|
|
474
|
+
];
|
|
475
|
+
const upperSource = completeFromList(upperCompletions);
|
|
476
|
+
const lowerSource = completeFromList(lowerCompletions);
|
|
477
|
+
/// Completes verbs, keywords, figurative constants, intrinsic functions
|
|
478
|
+
/// and snippets, everywhere except in strings, pictures and comments.
|
|
479
|
+
const keywordCompletionSource = (context) => {
|
|
480
|
+
if (inTextOrComment(context))
|
|
481
|
+
return null;
|
|
482
|
+
return caseOf(context) == "lower" ? lowerSource(context) : upperSource(context);
|
|
483
|
+
};
|
|
484
|
+
// Lezer sometimes stores a comment that sits on its own line inside the
|
|
485
|
+
// node before it, such as the name in `PERFORM A-PARA`, where the tree's
|
|
486
|
+
// position lookup can't find it. So comments are also found from the
|
|
487
|
+
// text of the line.
|
|
488
|
+
function inTextOrComment(context) {
|
|
489
|
+
let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
|
|
490
|
+
if (dontComplete.indexOf(inner.name) > -1)
|
|
491
|
+
return true;
|
|
492
|
+
let line = context.state.doc.lineAt(context.pos);
|
|
493
|
+
let before = line.text.slice(0, context.pos - line.from);
|
|
494
|
+
if (before.length >= 7 && (before[6] == "*" || before[6] == "/"))
|
|
495
|
+
return true;
|
|
496
|
+
let quote = "";
|
|
497
|
+
for (let i = 0; i < before.length; i++) {
|
|
498
|
+
let ch = before[i];
|
|
499
|
+
if (quote) {
|
|
500
|
+
if (ch == quote)
|
|
501
|
+
quote = "";
|
|
502
|
+
}
|
|
503
|
+
else if (ch == '"' || ch == "'")
|
|
504
|
+
quote = ch;
|
|
505
|
+
else if (ch == "*" && before[i + 1] == ">")
|
|
506
|
+
return true;
|
|
507
|
+
}
|
|
508
|
+
return false;
|
|
509
|
+
}
|
|
510
|
+
const definitionTypes = {
|
|
511
|
+
DataName: "variable",
|
|
512
|
+
IndexName: "variable",
|
|
513
|
+
FileName: "variable",
|
|
514
|
+
ParagraphName: "function",
|
|
515
|
+
SectionName: "function",
|
|
516
|
+
};
|
|
517
|
+
const unitCache = new WeakMap();
|
|
518
|
+
// A file can hold several programs, one after another. Each program
|
|
519
|
+
// starts at its IDENTIFICATION DIVISION or PROGRAM-ID and ends at its
|
|
520
|
+
// END PROGRAM, and its names are visible everywhere in it.
|
|
521
|
+
function programUnits(state, tree) {
|
|
522
|
+
let cached = unitCache.get(tree);
|
|
523
|
+
if (cached)
|
|
524
|
+
return cached;
|
|
525
|
+
let units = [];
|
|
526
|
+
let current = null;
|
|
527
|
+
let hasBody = false;
|
|
528
|
+
for (let child = tree.topNode.firstChild; child; child = child.nextSibling) {
|
|
529
|
+
let starts = child.name == "IdentificationDivision" || child.name == "ProgramIdParagraph";
|
|
530
|
+
if (!current || (starts && hasBody)) {
|
|
531
|
+
current = { from: child.from, to: child.to, names: [] };
|
|
532
|
+
units.push(current);
|
|
533
|
+
hasBody = false;
|
|
534
|
+
}
|
|
535
|
+
current.to = child.to;
|
|
536
|
+
if (child.name != "IdentificationDivision" && child.name != "ProgramIdParagraph" &&
|
|
537
|
+
child.name != "CommentParagraph")
|
|
538
|
+
hasBody = true;
|
|
539
|
+
collect(state, child, current.names);
|
|
540
|
+
if (child.name == "EndProgramHeader")
|
|
541
|
+
current = null;
|
|
542
|
+
}
|
|
543
|
+
unitCache.set(tree, units);
|
|
544
|
+
return units;
|
|
545
|
+
}
|
|
546
|
+
function collect(state, node, out) {
|
|
547
|
+
let cursor = node.cursor();
|
|
548
|
+
do {
|
|
549
|
+
let type = definitionTypes[cursor.name];
|
|
550
|
+
if (!type)
|
|
551
|
+
continue;
|
|
552
|
+
let name = state.sliceDoc(cursor.from, cursor.to);
|
|
553
|
+
let detail;
|
|
554
|
+
if (cursor.name == "DataName") {
|
|
555
|
+
let level = cursor.node.prevSibling;
|
|
556
|
+
let levelText = (level === null || level === void 0 ? void 0 : level.name) == "LevelNumber" ? state.sliceDoc(level.from, level.to) : "";
|
|
557
|
+
if (levelText == "88") {
|
|
558
|
+
type = "constant";
|
|
559
|
+
detail = "condition";
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
else if (cursor.name == "SectionName") {
|
|
563
|
+
detail = "section";
|
|
564
|
+
}
|
|
565
|
+
else if (cursor.name == "ParagraphName") {
|
|
566
|
+
detail = "paragraph";
|
|
567
|
+
}
|
|
568
|
+
else if (cursor.name == "FileName") {
|
|
569
|
+
detail = "file";
|
|
570
|
+
}
|
|
571
|
+
out.push({ name, from: cursor.from, to: cursor.to, completion: { label: name, type, detail } });
|
|
572
|
+
} while (cursor.next() && cursor.from < node.to);
|
|
573
|
+
}
|
|
574
|
+
/// Completes the names declared in the current program: data items,
|
|
575
|
+
/// condition names, indexes, files, paragraphs and sections.
|
|
576
|
+
const localCompletionSource = (context) => {
|
|
577
|
+
var _a;
|
|
578
|
+
let tree = syntaxTree(context.state);
|
|
579
|
+
if (inTextOrComment(context))
|
|
580
|
+
return null;
|
|
581
|
+
// Match the text, because the tree reads a word that is still being
|
|
582
|
+
// typed, such as `WS-`, as a name followed by a minus sign.
|
|
583
|
+
let typed = context.matchBefore(/[A-Za-z0-9][\w-]*$/);
|
|
584
|
+
if (!typed && !context.explicit)
|
|
585
|
+
return null;
|
|
586
|
+
let unit = (_a = programUnits(context.state, tree).find((u) => context.pos >= u.from && context.pos <= u.to)) !== null && _a !== void 0 ? _a : programUnits(context.state, tree).slice(-1)[0];
|
|
587
|
+
if (!unit)
|
|
588
|
+
return null;
|
|
589
|
+
let seen = new Set();
|
|
590
|
+
let options = [];
|
|
591
|
+
for (let d of unit.names) {
|
|
592
|
+
// Skip the name being typed, and names declared twice.
|
|
593
|
+
if (d.from <= context.pos && d.to >= context.pos)
|
|
594
|
+
continue;
|
|
595
|
+
let key = d.name.toUpperCase();
|
|
596
|
+
if (seen.has(key))
|
|
597
|
+
continue;
|
|
598
|
+
seen.add(key);
|
|
599
|
+
options.push(d.completion);
|
|
600
|
+
}
|
|
601
|
+
return { options, from: typed ? typed.from : context.pos, validFor: /^[\w-]*$/ };
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
// Indents the lines inside a block by one unit, and puts the words that
|
|
605
|
+
// close or split the block (such as ELSE and END-IF) back at its start.
|
|
606
|
+
function blockIndent(closing) {
|
|
607
|
+
return (cx) => cx.baseIndent + (closing.test(cx.textAfter) ? 0 : cx.unit);
|
|
608
|
+
}
|
|
609
|
+
// Folds a block from the end of its first line. If the block ends with a
|
|
610
|
+
// terminator such as END-IF, the terminator stays visible.
|
|
611
|
+
function foldBlock(node, state) {
|
|
612
|
+
let from = state.doc.lineAt(node.from).to;
|
|
613
|
+
let last = node.lastChild;
|
|
614
|
+
let to = node.to;
|
|
615
|
+
if (last && /^End/.test(last.name) && last.name != "EndProgramHeader") {
|
|
616
|
+
to = state.doc.lineAt(last.from).from - 1;
|
|
617
|
+
}
|
|
618
|
+
return to > from ? { from, to } : null;
|
|
619
|
+
}
|
|
620
|
+
// After a finished paragraph, section or division, a new line belongs to
|
|
621
|
+
// the last one of them, so its statements and entries line up.
|
|
622
|
+
function programIndent(cx) {
|
|
623
|
+
let node = cx.node.childBefore(cx.pos);
|
|
624
|
+
if (!node)
|
|
625
|
+
return 7;
|
|
626
|
+
for (let last = node.lastChild; last && /Division|Section|Paragraph/.test(last.name) && last.to <= cx.pos; last = last.lastChild)
|
|
627
|
+
node = last;
|
|
628
|
+
let indent = cx.lineIndent(node.from);
|
|
629
|
+
return /^(Paragraph|ProcedureSection)$/.test(node.name) ? indent + cx.unit : indent;
|
|
630
|
+
}
|
|
631
|
+
function levelOf(state, entry) {
|
|
632
|
+
let level = entry.getChild("LevelNumber");
|
|
633
|
+
return level ? parseInt(state.sliceDoc(level.from, level.to), 10) : 0;
|
|
634
|
+
}
|
|
635
|
+
// A group item folds over the entries below it with a higher level
|
|
636
|
+
// number, such as the 05 items under an 01.
|
|
637
|
+
function foldDataGroup(node, state) {
|
|
638
|
+
let level = levelOf(state, node);
|
|
639
|
+
if (!level || level >= 66)
|
|
640
|
+
return null;
|
|
641
|
+
let end = node;
|
|
642
|
+
for (let next = node.nextSibling; next && next.name == "DataEntry"; next = next.nextSibling) {
|
|
643
|
+
let nextLevel = levelOf(state, next);
|
|
644
|
+
if (nextLevel <= level || nextLevel == 66 || nextLevel == 77)
|
|
645
|
+
break;
|
|
646
|
+
end = next;
|
|
647
|
+
}
|
|
648
|
+
if (end == node)
|
|
649
|
+
return null;
|
|
650
|
+
let from = state.doc.lineAt(node.from).to;
|
|
651
|
+
return end.to > from ? { from, to: end.to } : null;
|
|
652
|
+
}
|
|
653
|
+
// Data entries are siblings in the tree, so a group item can't fold
|
|
654
|
+
// through foldNodeProp, which only folds nodes that run past their line.
|
|
655
|
+
const dataGroupFolding = foldService.of((state, lineFrom, lineTo) => {
|
|
656
|
+
let node = syntaxTree(state).resolveInner(lineFrom, 1);
|
|
657
|
+
while (node && node.name != "DataEntry")
|
|
658
|
+
node = node.parent;
|
|
659
|
+
if (!node) {
|
|
660
|
+
let after = syntaxTree(state).resolveInner(lineTo, -1);
|
|
661
|
+
for (let n = after; n; n = n.parent)
|
|
662
|
+
if (n.name == "DataEntry") {
|
|
663
|
+
node = n;
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
if (!node || node.from < lineFrom || node.from > lineTo)
|
|
668
|
+
return null;
|
|
669
|
+
return foldDataGroup(node, state);
|
|
670
|
+
});
|
|
671
|
+
const cobolLanguage = LRLanguage.define({
|
|
672
|
+
name: "cobol",
|
|
673
|
+
parser: parser.configure({
|
|
674
|
+
props: [
|
|
675
|
+
indentNodeProp.add({
|
|
676
|
+
Program: programIndent,
|
|
677
|
+
"IdentificationDivision EnvironmentDivision DataDivision ProcedureDivision": flatIndent,
|
|
678
|
+
"EnvSection DataSection": flatIndent,
|
|
679
|
+
"Paragraph ProcedureSection EnvParagraph": (cx) => cx.baseIndent + cx.unit,
|
|
680
|
+
"Statement DataEntry FileDescription": continuedIndent(),
|
|
681
|
+
IfStatement: blockIndent(/^\s*(ELSE|END-IF)\b/i),
|
|
682
|
+
PerformStatement: blockIndent(/^\s*END-PERFORM\b/i),
|
|
683
|
+
EvaluateStatement: blockIndent(/^\s*END-EVALUATE\b/i),
|
|
684
|
+
SearchStatement: blockIndent(/^\s*(WHEN|END-SEARCH)\b/i),
|
|
685
|
+
WhenClause: blockIndent(/^\s*(WHEN|END-EVALUATE|END-SEARCH)\b/i),
|
|
686
|
+
}),
|
|
687
|
+
foldNodeProp.add({
|
|
688
|
+
"IdentificationDivision EnvironmentDivision DataDivision ProcedureDivision": foldBlock,
|
|
689
|
+
"EnvSection DataSection ProcedureSection Paragraph": foldBlock,
|
|
690
|
+
"IfStatement EvaluateStatement SearchStatement WhenClause": foldBlock,
|
|
691
|
+
PerformStatement: (node, state) => (node.getChild("EndPerform") ? foldBlock(node, state) : null),
|
|
692
|
+
}),
|
|
693
|
+
styleTags({
|
|
694
|
+
"LineComment FixedComment": tags.lineComment,
|
|
695
|
+
CommentEntry: tags.comment,
|
|
696
|
+
"SequenceArea Directive": tags.meta,
|
|
697
|
+
"Identification Environment Data Procedure Division Section SectionKeyword": tags.definitionKeyword,
|
|
698
|
+
"ProgramId CommentParagraphKeyword EnvParagraphKeyword": tags.definitionKeyword,
|
|
699
|
+
"Select FileDescriptor Filler Pic Indexed By With Function Keyword": tags.keyword,
|
|
700
|
+
Verb: tags.keyword,
|
|
701
|
+
"If Then Else EndIf Evaluate When EndEvaluate Search EndSearch": tags.controlKeyword,
|
|
702
|
+
"Perform EndPerform Until Varying Times Thru ScopeTerminator EndProgram": tags.controlKeyword,
|
|
703
|
+
Figurative: tags.atom,
|
|
704
|
+
Number: tags.number,
|
|
705
|
+
String: tags.string,
|
|
706
|
+
PictureString: tags.typeName,
|
|
707
|
+
Identifier: tags.variableName,
|
|
708
|
+
"DataName/Identifier IndexName/Identifier FileName/Identifier": tags.definition(tags.variableName),
|
|
709
|
+
"ParagraphName/Identifier SectionName": tags.definition(tags.labelName),
|
|
710
|
+
"ProgramName/Identifier ProgramName/Keyword": tags.definition(tags.namespace),
|
|
711
|
+
"ProcedureName/Identifier": tags.labelName,
|
|
712
|
+
"FunctionName/Identifier FunctionName/Keyword": tags.function(tags.variableName),
|
|
713
|
+
"LevelNumber/Number": tags.special(tags.number),
|
|
714
|
+
ArithOp: tags.arithmeticOperator,
|
|
715
|
+
CompareOp: tags.compareOperator,
|
|
716
|
+
"( )": tags.paren,
|
|
717
|
+
".": tags.punctuation,
|
|
718
|
+
":": tags.punctuation,
|
|
719
|
+
}),
|
|
720
|
+
],
|
|
721
|
+
}),
|
|
722
|
+
languageData: {
|
|
723
|
+
commentTokens: { line: "*>" },
|
|
724
|
+
closeBrackets: { brackets: ["(", '"', "'"] },
|
|
725
|
+
indentOnInput: /^\s*(ELSE|END-[A-Z]+|WHEN)$/i,
|
|
726
|
+
},
|
|
727
|
+
});
|
|
728
|
+
/// COBOL support, with completion of keywords, intrinsic functions,
|
|
729
|
+
/// snippets and the names declared in the program.
|
|
730
|
+
function cobol() {
|
|
731
|
+
return new LanguageSupport(cobolLanguage, [
|
|
732
|
+
dataGroupFolding,
|
|
733
|
+
cobolLanguage.data.of({ autocomplete: keywordCompletionSource }),
|
|
734
|
+
cobolLanguage.data.of({ autocomplete: localCompletionSource }),
|
|
735
|
+
]);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
export { cobol, cobolLanguage, constants, functions, keywordCompletionSource, keywords, localCompletionSource, snippets, verbs };
|