1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 | return new (P || (P = Promise))(function (resolve, reject) {
|
5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 | });
|
10 | };
|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
12 | exports.lint = void 0;
|
13 | const collect_nodes_1 = require("./collect-nodes");
|
14 | const collect_grammar_diagnostics_1 = require("./collect-grammar-diagnostics");
|
15 | const collect_spelling_diagnostics_1 = require("./collect-spelling-diagnostics");
|
16 | const collect_algorithm_diagnostics_1 = require("./collect-algorithm-diagnostics");
|
17 | const collect_header_diagnostics_1 = require("./collect-header-diagnostics");
|
18 | const collect_tag_diagnostics_1 = require("./collect-tag-diagnostics");
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | function lint(report, sourceText, spec, document) {
|
32 | return __awaiter(this, void 0, void 0, function* () {
|
33 | collect_spelling_diagnostics_1.collectSpellingDiagnostics(report, sourceText, spec.imports);
|
34 | collect_tag_diagnostics_1.collectTagDiagnostics(report, spec, document);
|
35 | const collection = collect_nodes_1.collectNodes(report, sourceText, spec, document);
|
36 | if (!collection.success) {
|
37 | return;
|
38 | }
|
39 | const { mainGrammar, headers, sdos, earlyErrors, algorithms } = collection;
|
40 | const { grammar, oneOffGrammars } = yield collect_grammar_diagnostics_1.collectGrammarDiagnostics(report, spec, sourceText, mainGrammar, sdos, earlyErrors);
|
41 | collect_algorithm_diagnostics_1.collectAlgorithmDiagnostics(report, spec, sourceText, algorithms);
|
42 | collect_header_diagnostics_1.collectHeaderDiagnostics(report, headers);
|
43 |
|
44 |
|
45 | yield grammar.emit(undefined, (file, source) => {
|
46 | const name = +file.split('.')[0];
|
47 | const node = mainGrammar[name].element;
|
48 | if ('grammarkdownOut' in node) {
|
49 | throw new Error('unexpectedly regenerating grammarkdown output for node ' + name);
|
50 | }
|
51 |
|
52 | node.grammarkdownOut = source;
|
53 | });
|
54 | for (const { grammarEle, grammar } of oneOffGrammars) {
|
55 | yield grammar.emit(undefined, (file, source) => {
|
56 | if ('grammarkdownOut' in grammarEle) {
|
57 | throw new Error('unexpectedly regenerating grammarkdown output');
|
58 | }
|
59 |
|
60 | grammarEle.grammarkdownOut = source;
|
61 | });
|
62 | }
|
63 | for (const pair of algorithms) {
|
64 | if ('tree' in pair) {
|
65 |
|
66 | pair.element.ecmarkdownTree = pair.tree;
|
67 | }
|
68 | }
|
69 | });
|
70 | }
|
71 | exports.lint = lint;
|