openalgo-script 0.1.0-alpha.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 +201 -0
- package/NOTICE +12 -0
- package/README.md +255 -0
- package/dist/core/ast/annotations.d.ts +56 -0
- package/dist/core/ast/annotations.d.ts.map +1 -0
- package/dist/core/ast/annotations.js +27 -0
- package/dist/core/ast/annotations.js.map +1 -0
- package/dist/core/ast/build.d.ts +25 -0
- package/dist/core/ast/build.d.ts.map +1 -0
- package/dist/core/ast/build.js +26 -0
- package/dist/core/ast/build.js.map +1 -0
- package/dist/core/ast/children.d.ts +15 -0
- package/dist/core/ast/children.d.ts.map +1 -0
- package/dist/core/ast/children.js +103 -0
- package/dist/core/ast/children.js.map +1 -0
- package/dist/core/ast/expressions.d.ts +178 -0
- package/dist/core/ast/expressions.d.ts.map +1 -0
- package/dist/core/ast/expressions.js +50 -0
- package/dist/core/ast/expressions.js.map +1 -0
- package/dist/core/ast/header.d.ts +50 -0
- package/dist/core/ast/header.d.ts.map +1 -0
- package/dist/core/ast/header.js +2 -0
- package/dist/core/ast/header.js.map +1 -0
- package/dist/core/ast/index.d.ts +30 -0
- package/dist/core/ast/index.d.ts.map +1 -0
- package/dist/core/ast/index.js +21 -0
- package/dist/core/ast/index.js.map +1 -0
- package/dist/core/ast/name.d.ts +24 -0
- package/dist/core/ast/name.d.ts.map +1 -0
- package/dist/core/ast/name.js +2 -0
- package/dist/core/ast/name.js.map +1 -0
- package/dist/core/ast/node.d.ts +34 -0
- package/dist/core/ast/node.d.ts.map +1 -0
- package/dist/core/ast/node.js +70 -0
- package/dist/core/ast/node.js.map +1 -0
- package/dist/core/ast/script.d.ts +57 -0
- package/dist/core/ast/script.d.ts.map +1 -0
- package/dist/core/ast/script.js +2 -0
- package/dist/core/ast/script.js.map +1 -0
- package/dist/core/ast/statements.d.ts +161 -0
- package/dist/core/ast/statements.d.ts.map +1 -0
- package/dist/core/ast/statements.js +10 -0
- package/dist/core/ast/statements.js.map +1 -0
- package/dist/core/ast/walk.d.ts +39 -0
- package/dist/core/ast/walk.d.ts.map +1 -0
- package/dist/core/ast/walk.js +54 -0
- package/dist/core/ast/walk.js.map +1 -0
- package/dist/core/catalogue/catalogue.generated.d.ts +1590 -0
- package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -0
- package/dist/core/catalogue/catalogue.generated.js +162 -0
- package/dist/core/catalogue/catalogue.generated.js.map +1 -0
- package/dist/core/catalogue/index.d.ts +15 -0
- package/dist/core/catalogue/index.d.ts.map +1 -0
- package/dist/core/catalogue/index.js +4 -0
- package/dist/core/catalogue/index.js.map +1 -0
- package/dist/core/catalogue/lookup.d.ts +14 -0
- package/dist/core/catalogue/lookup.d.ts.map +1 -0
- package/dist/core/catalogue/lookup.js +19 -0
- package/dist/core/catalogue/lookup.js.map +1 -0
- package/dist/core/catalogue/template.d.ts +15 -0
- package/dist/core/catalogue/template.d.ts.map +1 -0
- package/dist/core/catalogue/template.js +33 -0
- package/dist/core/catalogue/template.js.map +1 -0
- package/dist/core/catalogue/types.d.ts +34 -0
- package/dist/core/catalogue/types.d.ts.map +1 -0
- package/dist/core/catalogue/types.js +6 -0
- package/dist/core/catalogue/types.js.map +1 -0
- package/dist/core/catalogue/values.generated.d.ts +565 -0
- package/dist/core/catalogue/values.generated.d.ts.map +1 -0
- package/dist/core/catalogue/values.generated.js +6 -0
- package/dist/core/catalogue/values.generated.js.map +1 -0
- package/dist/core/diagnostics/collector.d.ts +46 -0
- package/dist/core/diagnostics/collector.d.ts.map +1 -0
- package/dist/core/diagnostics/collector.js +55 -0
- package/dist/core/diagnostics/collector.js.map +1 -0
- package/dist/core/diagnostics/diagnostic.d.ts +40 -0
- package/dist/core/diagnostics/diagnostic.d.ts.map +1 -0
- package/dist/core/diagnostics/diagnostic.js +29 -0
- package/dist/core/diagnostics/diagnostic.js.map +1 -0
- package/dist/core/diagnostics/index.d.ts +12 -0
- package/dist/core/diagnostics/index.d.ts.map +1 -0
- package/dist/core/diagnostics/index.js +3 -0
- package/dist/core/diagnostics/index.js.map +1 -0
- package/dist/core/index.d.ts +28 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lex/blocks.d.ts +51 -0
- package/dist/core/lex/blocks.d.ts.map +1 -0
- package/dist/core/lex/blocks.js +56 -0
- package/dist/core/lex/blocks.js.map +1 -0
- package/dist/core/lex/characters.d.ts +38 -0
- package/dist/core/lex/characters.d.ts.map +1 -0
- package/dist/core/lex/characters.js +50 -0
- package/dist/core/lex/characters.js.map +1 -0
- package/dist/core/lex/comments.d.ts +50 -0
- package/dist/core/lex/comments.d.ts.map +1 -0
- package/dist/core/lex/comments.js +64 -0
- package/dist/core/lex/comments.js.map +1 -0
- package/dist/core/lex/index.d.ts +12 -0
- package/dist/core/lex/index.d.ts.map +1 -0
- package/dist/core/lex/index.js +12 -0
- package/dist/core/lex/index.js.map +1 -0
- package/dist/core/lex/layout.d.ts +40 -0
- package/dist/core/lex/layout.d.ts.map +1 -0
- package/dist/core/lex/layout.js +143 -0
- package/dist/core/lex/layout.js.map +1 -0
- package/dist/core/lex/lexer.d.ts +13 -0
- package/dist/core/lex/lexer.d.ts.map +1 -0
- package/dist/core/lex/lexer.js +419 -0
- package/dist/core/lex/lexer.js.map +1 -0
- package/dist/core/lex/numbers.d.ts +22 -0
- package/dist/core/lex/numbers.d.ts.map +1 -0
- package/dist/core/lex/numbers.js +58 -0
- package/dist/core/lex/numbers.js.map +1 -0
- package/dist/core/lex/statements.d.ts +24 -0
- package/dist/core/lex/statements.d.ts.map +1 -0
- package/dist/core/lex/statements.js +90 -0
- package/dist/core/lex/statements.js.map +1 -0
- package/dist/core/lex/strings.d.ts +27 -0
- package/dist/core/lex/strings.d.ts.map +1 -0
- package/dist/core/lex/strings.js +92 -0
- package/dist/core/lex/strings.js.map +1 -0
- package/dist/core/lex/unexpected.d.ts +31 -0
- package/dist/core/lex/unexpected.d.ts.map +1 -0
- package/dist/core/lex/unexpected.js +114 -0
- package/dist/core/lex/unexpected.js.map +1 -0
- package/dist/core/parse/annotations.d.ts +4 -0
- package/dist/core/parse/annotations.d.ts.map +1 -0
- package/dist/core/parse/annotations.js +49 -0
- package/dist/core/parse/annotations.js.map +1 -0
- package/dist/core/parse/blocks.d.ts +18 -0
- package/dist/core/parse/blocks.d.ts.map +1 -0
- package/dist/core/parse/blocks.js +47 -0
- package/dist/core/parse/blocks.js.map +1 -0
- package/dist/core/parse/branches.d.ts +17 -0
- package/dist/core/parse/branches.d.ts.map +1 -0
- package/dist/core/parse/branches.js +66 -0
- package/dist/core/parse/branches.js.map +1 -0
- package/dist/core/parse/cursor.d.ts +119 -0
- package/dist/core/parse/cursor.d.ts.map +1 -0
- package/dist/core/parse/cursor.js +305 -0
- package/dist/core/parse/cursor.js.map +1 -0
- package/dist/core/parse/expressions.d.ts +57 -0
- package/dist/core/parse/expressions.d.ts.map +1 -0
- package/dist/core/parse/expressions.js +373 -0
- package/dist/core/parse/expressions.js.map +1 -0
- package/dist/core/parse/functions.d.ts +16 -0
- package/dist/core/parse/functions.d.ts.map +1 -0
- package/dist/core/parse/functions.js +92 -0
- package/dist/core/parse/functions.js.map +1 -0
- package/dist/core/parse/index.d.ts +13 -0
- package/dist/core/parse/index.d.ts.map +1 -0
- package/dist/core/parse/index.js +13 -0
- package/dist/core/parse/index.js.map +1 -0
- package/dist/core/parse/loops.d.ts +13 -0
- package/dist/core/parse/loops.d.ts.map +1 -0
- package/dist/core/parse/loops.js +78 -0
- package/dist/core/parse/loops.js.map +1 -0
- package/dist/core/parse/names.d.ts +34 -0
- package/dist/core/parse/names.d.ts.map +1 -0
- package/dist/core/parse/names.js +122 -0
- package/dist/core/parse/names.js.map +1 -0
- package/dist/core/parse/script.d.ts +23 -0
- package/dist/core/parse/script.d.ts.map +1 -0
- package/dist/core/parse/script.js +55 -0
- package/dist/core/parse/script.js.map +1 -0
- package/dist/core/parse/statements.d.ts +14 -0
- package/dist/core/parse/statements.d.ts.map +1 -0
- package/dist/core/parse/statements.js +292 -0
- package/dist/core/parse/statements.js.map +1 -0
- package/dist/core/parse/switches.d.ts +16 -0
- package/dist/core/parse/switches.d.ts.map +1 -0
- package/dist/core/parse/switches.js +98 -0
- package/dist/core/parse/switches.js.map +1 -0
- package/dist/core/render/index.d.ts +10 -0
- package/dist/core/render/index.d.ts.map +1 -0
- package/dist/core/render/index.js +10 -0
- package/dist/core/render/index.js.map +1 -0
- package/dist/core/render/terminal.d.ts +11 -0
- package/dist/core/render/terminal.d.ts.map +1 -0
- package/dist/core/render/terminal.js +51 -0
- package/dist/core/render/terminal.js.map +1 -0
- package/dist/core/source/index.d.ts +7 -0
- package/dist/core/source/index.d.ts.map +1 -0
- package/dist/core/source/index.js +2 -0
- package/dist/core/source/index.js.map +1 -0
- package/dist/core/source/source.d.ts +41 -0
- package/dist/core/source/source.d.ts.map +1 -0
- package/dist/core/source/source.js +67 -0
- package/dist/core/source/source.js.map +1 -0
- package/dist/core/span/index.d.ts +3 -0
- package/dist/core/span/index.d.ts.map +1 -0
- package/dist/core/span/index.js +2 -0
- package/dist/core/span/index.js.map +1 -0
- package/dist/core/span/span.d.ts +67 -0
- package/dist/core/span/span.d.ts.map +1 -0
- package/dist/core/span/span.js +27 -0
- package/dist/core/span/span.js.map +1 -0
- package/dist/core/tokens/index.d.ts +8 -0
- package/dist/core/tokens/index.d.ts.map +1 -0
- package/dist/core/tokens/index.js +2 -0
- package/dist/core/tokens/index.js.map +1 -0
- package/dist/core/tokens/kind.d.ts +53 -0
- package/dist/core/tokens/kind.d.ts.map +1 -0
- package/dist/core/tokens/kind.js +94 -0
- package/dist/core/tokens/kind.js.map +1 -0
- package/dist/core/tokens/token.d.ts +36 -0
- package/dist/core/tokens/token.d.ts.map +1 -0
- package/dist/core/tokens/token.js +2 -0
- package/dist/core/tokens/token.js.map +1 -0
- package/package.json +52 -0
- package/spec/README.md +48 -0
- package/spec/errors.json +3204 -0
- package/src/core/ast/annotations.ts +68 -0
- package/src/core/ast/build.ts +35 -0
- package/src/core/ast/children.ts +110 -0
- package/src/core/ast/expressions.ts +254 -0
- package/src/core/ast/header.ts +53 -0
- package/src/core/ast/index.ts +102 -0
- package/src/core/ast/name.ts +24 -0
- package/src/core/ast/node.ts +120 -0
- package/src/core/ast/script.ts +60 -0
- package/src/core/ast/statements.ts +193 -0
- package/src/core/ast/walk.ts +67 -0
- package/src/core/catalogue/catalogue.generated.ts +171 -0
- package/src/core/catalogue/index.ts +20 -0
- package/src/core/catalogue/lookup.ts +23 -0
- package/src/core/catalogue/template.ts +38 -0
- package/src/core/catalogue/types.ts +37 -0
- package/src/core/catalogue/values.generated.ts +160 -0
- package/src/core/diagnostics/collector.ts +87 -0
- package/src/core/diagnostics/diagnostic.ts +72 -0
- package/src/core/diagnostics/index.ts +12 -0
- package/src/core/index.ts +146 -0
- package/src/core/lex/blocks.ts +92 -0
- package/src/core/lex/characters.ts +56 -0
- package/src/core/lex/comments.ts +75 -0
- package/src/core/lex/index.ts +11 -0
- package/src/core/lex/layout.ts +188 -0
- package/src/core/lex/lexer.ts +486 -0
- package/src/core/lex/numbers.ts +77 -0
- package/src/core/lex/statements.ts +94 -0
- package/src/core/lex/strings.ts +119 -0
- package/src/core/lex/unexpected.ts +125 -0
- package/src/core/parse/annotations.ts +60 -0
- package/src/core/parse/blocks.ts +52 -0
- package/src/core/parse/branches.ts +77 -0
- package/src/core/parse/cursor.ts +348 -0
- package/src/core/parse/expressions.ts +441 -0
- package/src/core/parse/functions.ts +109 -0
- package/src/core/parse/index.ts +12 -0
- package/src/core/parse/loops.ts +97 -0
- package/src/core/parse/names.ts +135 -0
- package/src/core/parse/script.ts +64 -0
- package/src/core/parse/statements.ts +329 -0
- package/src/core/parse/switches.ts +105 -0
- package/src/core/render/index.ts +9 -0
- package/src/core/render/terminal.ts +62 -0
- package/src/core/source/index.ts +6 -0
- package/src/core/source/source.ts +102 -0
- package/src/core/span/index.ts +2 -0
- package/src/core/span/span.ts +84 -0
- package/src/core/tokens/index.ts +15 -0
- package/src/core/tokens/kind.ts +123 -0
- package/src/core/tokens/token.ts +39 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { diagnosticFor, isError } from './diagnostic.js';
|
|
2
|
+
/**
|
|
3
|
+
* Gathers diagnostics instead of throwing on the first one.
|
|
4
|
+
*
|
|
5
|
+
* A trader who has three syntax errors in a file wants to see three, not one
|
|
6
|
+
* per compile. A compiler that throws makes the second error cost a whole
|
|
7
|
+
* edit-and-run cycle to discover, and it is the same file, so the cost is paid
|
|
8
|
+
* for nothing.
|
|
9
|
+
*
|
|
10
|
+
* The bag refuses an exact repeat: the same code over the same span, which is
|
|
11
|
+
* what a parser that recovers and re-enters the same construct produces. It
|
|
12
|
+
* refuses nothing else, so two different codes on one character both survive
|
|
13
|
+
* and the reader decides which one they believe.
|
|
14
|
+
*/
|
|
15
|
+
export class DiagnosticBag {
|
|
16
|
+
#items = [];
|
|
17
|
+
#seen = new Set();
|
|
18
|
+
report(code, span, values) {
|
|
19
|
+
this.add(diagnosticFor(code, span, values));
|
|
20
|
+
}
|
|
21
|
+
add(diagnostic) {
|
|
22
|
+
const key = `${diagnostic.code}:${diagnostic.span.offset}:${diagnostic.span.length}`;
|
|
23
|
+
if (this.#seen.has(key))
|
|
24
|
+
return;
|
|
25
|
+
this.#seen.add(key);
|
|
26
|
+
this.#items.push(diagnostic);
|
|
27
|
+
}
|
|
28
|
+
/** Everything reported, in the order it was reported. */
|
|
29
|
+
get all() {
|
|
30
|
+
return this.#items;
|
|
31
|
+
}
|
|
32
|
+
get isEmpty() {
|
|
33
|
+
return this.#items.length === 0;
|
|
34
|
+
}
|
|
35
|
+
/** Whether compilation has to stop. A file with only warnings still runs. */
|
|
36
|
+
get hasErrors() {
|
|
37
|
+
return this.#items.some(isError);
|
|
38
|
+
}
|
|
39
|
+
get errors() {
|
|
40
|
+
return this.#items.filter(isError);
|
|
41
|
+
}
|
|
42
|
+
get warnings() {
|
|
43
|
+
return this.#items.filter((item) => !isError(item));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Everything reported, in the order a reader walks the file.
|
|
47
|
+
*
|
|
48
|
+
* Stages report in the order they run, so a checker warning about line 2
|
|
49
|
+
* arrives after a parser error about line 40. A reader reads top to bottom.
|
|
50
|
+
*/
|
|
51
|
+
ordered() {
|
|
52
|
+
return [...this.#items].sort((left, right) => left.span.offset - right.span.offset || left.code.localeCompare(right.code));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../../src/core/diagnostics/collector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAkBzD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IACf,MAAM,GAAiB,EAAE,CAAC;IAC1B,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnC,MAAM,CACJ,IAAU,EACV,IAAU,EACV,MAA8B;QAE9B,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,GAAG,CAAC,UAAsB;QACxB,MAAM,GAAG,GAAG,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACrF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO;QAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAED,yDAAyD;IACzD,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,6EAA6E;IAC7E,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACH,OAAO;QACL,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAC1B,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACd,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAC9E,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DiagnosticCode, DiagnosticValues, PlaceholderValue, Severity, Stage } from '../catalogue/index.js';
|
|
2
|
+
import type { Span } from '../span/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* One thing the compiler has to say about one place in a file.
|
|
5
|
+
*
|
|
6
|
+
* The code and the span come from the stage that raised it. Everything else
|
|
7
|
+
* comes from the catalogue, filled with the values the stage supplied, so no
|
|
8
|
+
* stage anywhere writes a sentence a reader sees.
|
|
9
|
+
*/
|
|
10
|
+
export interface Diagnostic {
|
|
11
|
+
readonly code: DiagnosticCode;
|
|
12
|
+
readonly severity: Severity;
|
|
13
|
+
readonly stage: Stage;
|
|
14
|
+
readonly title: string;
|
|
15
|
+
/** The catalogue message with its slots filled. */
|
|
16
|
+
readonly message: string;
|
|
17
|
+
/** The catalogue fix with its slots filled. What to do, in the imperative. */
|
|
18
|
+
readonly fix: string;
|
|
19
|
+
/** Whether an editor may apply the fix without asking a question. */
|
|
20
|
+
readonly autofix: boolean;
|
|
21
|
+
readonly span: Span;
|
|
22
|
+
/**
|
|
23
|
+
* The values that filled the slots, kept rather than discarded.
|
|
24
|
+
*
|
|
25
|
+
* An editor building a quick fix needs the name that went into the message,
|
|
26
|
+
* not the sentence it was put into, and a host rendering a diagnostic in
|
|
27
|
+
* another language needs every value the template consumed.
|
|
28
|
+
*/
|
|
29
|
+
readonly values: Readonly<Record<string, PlaceholderValue>>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Builds a diagnostic.
|
|
33
|
+
*
|
|
34
|
+
* The values argument is typed per code, so a call site that forgets a slot or
|
|
35
|
+
* misspells one fails to compile. That is the only guard that runs before a
|
|
36
|
+
* trader sees the message, which is why the placeholders are generated as types.
|
|
37
|
+
*/
|
|
38
|
+
export declare function diagnosticFor<Code extends DiagnosticCode>(code: Code, span: Span, values: DiagnosticValues[Code]): Diagnostic;
|
|
39
|
+
export declare function isError(diagnostic: Diagnostic): boolean;
|
|
40
|
+
//# sourceMappingURL=diagnostic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../../../src/core/diagnostics/diagnostic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,KAAK,EACN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;CAC7D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,cAAc,EACvD,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAC7B,UAAU,CAiBZ;AAED,wBAAgB,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAEvD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { entryFor, fillTemplate } from '../catalogue/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Builds a diagnostic.
|
|
4
|
+
*
|
|
5
|
+
* The values argument is typed per code, so a call site that forgets a slot or
|
|
6
|
+
* misspells one fails to compile. That is the only guard that runs before a
|
|
7
|
+
* trader sees the message, which is why the placeholders are generated as types.
|
|
8
|
+
*/
|
|
9
|
+
export function diagnosticFor(code, span, values) {
|
|
10
|
+
const entry = entryFor(code);
|
|
11
|
+
// DiagnosticValues is generated with every property typed PlaceholderValue,
|
|
12
|
+
// so this widening loses the per-code shape and nothing else.
|
|
13
|
+
const supplied = values;
|
|
14
|
+
return {
|
|
15
|
+
code,
|
|
16
|
+
severity: entry.severity,
|
|
17
|
+
stage: entry.stage,
|
|
18
|
+
title: entry.title,
|
|
19
|
+
message: fillTemplate(entry.message, supplied),
|
|
20
|
+
fix: fillTemplate(entry.fix, supplied),
|
|
21
|
+
autofix: entry.autofix,
|
|
22
|
+
span,
|
|
23
|
+
values: supplied,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function isError(diagnostic) {
|
|
27
|
+
return diagnostic.severity === 'error';
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=diagnostic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../../../src/core/diagnostics/diagnostic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAuC/D;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAU,EACV,IAAU,EACV,MAA8B;IAE9B,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,4EAA4E;IAC5E,8DAA8D;IAC9D,MAAM,QAAQ,GAAG,MAA+D,CAAC;IAEjF,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC9C,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC;QACtC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI;QACJ,MAAM,EAAE,QAAQ;KACjB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,UAAsB;IAC5C,OAAO,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the compiler has to say, and where it is put while it says it.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here decides how a diagnostic looks on a screen. That is the render
|
|
5
|
+
* module, because a terminal, an editor gutter and a chart all want a different
|
|
6
|
+
* shape from the same diagnostic.
|
|
7
|
+
*/
|
|
8
|
+
export type { Diagnostic } from './diagnostic.js';
|
|
9
|
+
export { diagnosticFor, isError } from './diagnostic.js';
|
|
10
|
+
export type { DiagnosticSink } from './collector.js';
|
|
11
|
+
export { DiagnosticBag } from './collector.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/diagnostics/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAEzD,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/diagnostics/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenScript, the compiler tier.
|
|
3
|
+
*
|
|
4
|
+
* This is the whole of what a host needs to turn a script into a compiled
|
|
5
|
+
* program, and it knows nothing about a chart, an editor or a broker. It
|
|
6
|
+
* imports no package and touches no browser global, so the same file runs in a
|
|
7
|
+
* worker, on a server and inside somebody else's application under a content
|
|
8
|
+
* security policy that forbids turning text into code.
|
|
9
|
+
*
|
|
10
|
+
* The tiers above it are separate entry points, so a host that wants only this
|
|
11
|
+
* one never loads the editor intelligence or an adapter.
|
|
12
|
+
*/
|
|
13
|
+
export type { Positioned, Span } from './span/index.js';
|
|
14
|
+
export { containsOffset, endOffset, makeSpan, spanning } from './span/index.js';
|
|
15
|
+
export type { SourceFile, SourcePosition } from './source/index.js';
|
|
16
|
+
export { normaliseSource, sourceFile } from './source/index.js';
|
|
17
|
+
export type { CatalogueEntry, DiagnosticCode, DiagnosticValues, PlaceholderValue, Severity, Stage, } from './catalogue/index.js';
|
|
18
|
+
export { CATALOGUE_LANGUAGE_VERSION, CATALOGUE_SCHEMA_VERSION, STAGE_LABELS, allCodes, entryFor, fillTemplate, isDiagnosticCode, } from './catalogue/index.js';
|
|
19
|
+
export type { Diagnostic, DiagnosticSink } from './diagnostics/index.js';
|
|
20
|
+
export { DiagnosticBag, diagnosticFor, isError } from './diagnostics/index.js';
|
|
21
|
+
export { renderDiagnostic, renderDiagnostics } from './render/index.js';
|
|
22
|
+
export type { KeywordKind, LayoutKind, LiteralKind, NameKind, NumberToken, PunctuationKind, SimpleToken, StringToken, Token, TokenKind, } from './tokens/index.js';
|
|
23
|
+
export { PUNCTUATORS, RESERVED_WORDS } from './tokens/index.js';
|
|
24
|
+
export type { Argument, ArithmeticOperator, ArrayLiteral, ArrayType, Assignment, AssignmentOperator, AstNode, Binary, BinaryOperator, Block, BooleanLiteral, BreakStatement, Call, ColorLiteral, ComparisonOperator, ContinueStatement, ElseBranch, EqualityOperator, Expression, ExpressionStatement, ForInStatement, ForRangeStatement, FunctionDeclaration, Grouping, IfBranch, IfStatement, Index, LimitsLine, LogicalOperator, Member, MissingExpression, Name, NameReference, NamedType, NodeFields, NodeKind, NodeOfKind, NoneLiteral, NumberLiteral, ObjectTypeName, Parameter, ReturnStatement, Script, ScriptDeclaration, SeriesType, Statement, StringLiteral, SwitchCase, SwitchDefault, SwitchStatement, Ternary, TopLevelItem, TypeAnnotation, Unary, UnaryOperator, ValueTypeName, VarDeclaration, VersionLine, Visit, Visitor, WhileStatement, } from './ast/index.js';
|
|
25
|
+
export { ARITHMETIC_OPERATORS, ASSIGNMENT_OPERATORS, COMPARISON_OPERATORS, EQUALITY_OPERATORS, LOGICAL_OPERATORS, OBJECT_TYPE_NAMES, UNARY_OPERATORS, VALUE_TYPE_NAMES, binaryPrecedence, childrenOf, isExpression, isObjectTypeName, isStatement, isTypeAnnotation, isValueTypeName, makeNode, nodeAtOffset, pathAtOffset, typeAnnotationText, walk, withoutGrouping, } from './ast/index.js';
|
|
26
|
+
export { lex } from './lex/index.js';
|
|
27
|
+
export { parse, parseTokens } from './parse/index.js';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhF,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEhE,YAAY,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAExE,YAAY,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,WAAW,EACX,eAAe,EACf,WAAW,EACX,WAAW,EACX,KAAK,EACL,SAAS,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEhE,YAAY,EACV,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,MAAM,EACN,cAAc,EACd,KAAK,EACL,cAAc,EACd,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,KAAK,EACL,UAAU,EACV,eAAe,EACf,MAAM,EACN,iBAAiB,EACjB,IAAI,EACJ,aAAa,EACb,SAAS,EACT,UAAU,EACV,QAAQ,EACR,UAAU,EACV,WAAW,EACX,aAAa,EACb,cAAc,EACd,SAAS,EACT,eAAe,EACf,MAAM,EACN,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,aAAa,EACb,UAAU,EACV,aAAa,EACb,eAAe,EACf,OAAO,EACP,YAAY,EACZ,cAAc,EACd,KAAK,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,EACX,KAAK,EACL,OAAO,EACP,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,IAAI,EACJ,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenScript, the compiler tier.
|
|
3
|
+
*
|
|
4
|
+
* This is the whole of what a host needs to turn a script into a compiled
|
|
5
|
+
* program, and it knows nothing about a chart, an editor or a broker. It
|
|
6
|
+
* imports no package and touches no browser global, so the same file runs in a
|
|
7
|
+
* worker, on a server and inside somebody else's application under a content
|
|
8
|
+
* security policy that forbids turning text into code.
|
|
9
|
+
*
|
|
10
|
+
* The tiers above it are separate entry points, so a host that wants only this
|
|
11
|
+
* one never loads the editor intelligence or an adapter.
|
|
12
|
+
*/
|
|
13
|
+
export { containsOffset, endOffset, makeSpan, spanning } from './span/index.js';
|
|
14
|
+
export { normaliseSource, sourceFile } from './source/index.js';
|
|
15
|
+
export { CATALOGUE_LANGUAGE_VERSION, CATALOGUE_SCHEMA_VERSION, STAGE_LABELS, allCodes, entryFor, fillTemplate, isDiagnosticCode, } from './catalogue/index.js';
|
|
16
|
+
export { DiagnosticBag, diagnosticFor, isError } from './diagnostics/index.js';
|
|
17
|
+
export { renderDiagnostic, renderDiagnostics } from './render/index.js';
|
|
18
|
+
export { PUNCTUATORS, RESERVED_WORDS } from './tokens/index.js';
|
|
19
|
+
export { ARITHMETIC_OPERATORS, ASSIGNMENT_OPERATORS, COMPARISON_OPERATORS, EQUALITY_OPERATORS, LOGICAL_OPERATORS, OBJECT_TYPE_NAMES, UNARY_OPERATORS, VALUE_TYPE_NAMES, binaryPrecedence, childrenOf, isExpression, isObjectTypeName, isStatement, isTypeAnnotation, isValueTypeName, makeNode, nodeAtOffset, pathAtOffset, typeAnnotationText, walk, withoutGrouping, } from './ast/index.js';
|
|
20
|
+
export { lex } from './lex/index.js';
|
|
21
|
+
export { parse, parseTokens } from './parse/index.js';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAUhE,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAcxE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAiEhE,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,IAAI,EACJ,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The block structure of language.md 3.10, which is a stack of indentation
|
|
3
|
+
* widths and nothing more.
|
|
4
|
+
*
|
|
5
|
+
* Only a line that carries a token ever reaches this. A blank line and a
|
|
6
|
+
* comment-only line carry no indentation at all: they never open a block, never
|
|
7
|
+
* end one and are never OS1003, and the rule is kept by never asking about
|
|
8
|
+
* them rather than by asking and forgiving.
|
|
9
|
+
*/
|
|
10
|
+
/** What a line's indentation means for the blocks around it. */
|
|
11
|
+
export type IndentEvent =
|
|
12
|
+
/** Another line of the block already open. */
|
|
13
|
+
{
|
|
14
|
+
readonly kind: 'same';
|
|
15
|
+
}
|
|
16
|
+
/** Deeper than the header above it: a block begins. */
|
|
17
|
+
| {
|
|
18
|
+
readonly kind: 'open';
|
|
19
|
+
}
|
|
20
|
+
/** Shallower: this many blocks end here. */
|
|
21
|
+
| {
|
|
22
|
+
readonly kind: 'close';
|
|
23
|
+
readonly count: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Indented to a width no open block has, which is OS1003. The line is kept in
|
|
27
|
+
* the block it landed in, so that one lost space reports one error rather
|
|
28
|
+
* than reshaping every block below it.
|
|
29
|
+
*/
|
|
30
|
+
| {
|
|
31
|
+
readonly kind: 'mismatch';
|
|
32
|
+
readonly count: number;
|
|
33
|
+
readonly expected: number;
|
|
34
|
+
readonly openerLine: number;
|
|
35
|
+
};
|
|
36
|
+
export declare class BlockStack {
|
|
37
|
+
#private;
|
|
38
|
+
get depth(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Takes the next line's indentation.
|
|
41
|
+
*
|
|
42
|
+
* `afterHeader` is whether the statement above this line was one that opens a
|
|
43
|
+
* block. Without it a line that drifted one space to the right would open a
|
|
44
|
+
* block of its own and every sibling below it would be reported instead of
|
|
45
|
+
* the one line that moved.
|
|
46
|
+
*/
|
|
47
|
+
enter(width: number, afterHeader: boolean, openerLine: number): IndentEvent;
|
|
48
|
+
/** Every block still open, which the end of the file closes. */
|
|
49
|
+
closeAll(): number;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../../src/core/lex/blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,gEAAgE;AAChE,MAAM,MAAM,WAAW;AACrB,8CAA8C;AAC5C;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAC3B,uDAAuD;GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAC3B,4CAA4C;GAC1C;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACpD;;;;GAIG;GACD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEN,qBAAa,UAAU;;IAKrB,IAAI,KAAK,IAAI,MAAM,CAElB;IAMD;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW;IAwB3E,gEAAgE;IAChE,QAAQ,IAAI,MAAM;CAKnB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The block structure of language.md 3.10, which is a stack of indentation
|
|
3
|
+
* widths and nothing more.
|
|
4
|
+
*
|
|
5
|
+
* Only a line that carries a token ever reaches this. A blank line and a
|
|
6
|
+
* comment-only line carry no indentation at all: they never open a block, never
|
|
7
|
+
* end one and are never OS1003, and the rule is kept by never asking about
|
|
8
|
+
* them rather than by asking and forgiving.
|
|
9
|
+
*/
|
|
10
|
+
export class BlockStack {
|
|
11
|
+
// The file's own top level, which no header opened. Line 1 is the honest
|
|
12
|
+
// answer to where it began.
|
|
13
|
+
#levels = [{ width: 0, openerLine: 1 }];
|
|
14
|
+
get depth() {
|
|
15
|
+
return this.#levels.length - 1;
|
|
16
|
+
}
|
|
17
|
+
#top() {
|
|
18
|
+
return this.#levels[this.#levels.length - 1] ?? { width: 0, openerLine: 1 };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Takes the next line's indentation.
|
|
22
|
+
*
|
|
23
|
+
* `afterHeader` is whether the statement above this line was one that opens a
|
|
24
|
+
* block. Without it a line that drifted one space to the right would open a
|
|
25
|
+
* block of its own and every sibling below it would be reported instead of
|
|
26
|
+
* the one line that moved.
|
|
27
|
+
*/
|
|
28
|
+
enter(width, afterHeader, openerLine) {
|
|
29
|
+
const top = this.#top();
|
|
30
|
+
if (width > top.width) {
|
|
31
|
+
if (!afterHeader) {
|
|
32
|
+
return { kind: 'mismatch', count: 0, expected: top.width, openerLine: top.openerLine };
|
|
33
|
+
}
|
|
34
|
+
this.#levels.push({ width, openerLine });
|
|
35
|
+
return { kind: 'open' };
|
|
36
|
+
}
|
|
37
|
+
if (width === top.width)
|
|
38
|
+
return { kind: 'same' };
|
|
39
|
+
let count = 0;
|
|
40
|
+
while (this.#levels.length > 1 && width < this.#top().width) {
|
|
41
|
+
this.#levels.pop();
|
|
42
|
+
count++;
|
|
43
|
+
}
|
|
44
|
+
const landed = this.#top();
|
|
45
|
+
if (width === landed.width)
|
|
46
|
+
return { kind: 'close', count };
|
|
47
|
+
return { kind: 'mismatch', count, expected: landed.width, openerLine: landed.openerLine };
|
|
48
|
+
}
|
|
49
|
+
/** Every block still open, which the end of the file closes. */
|
|
50
|
+
closeAll() {
|
|
51
|
+
const count = this.#levels.length - 1;
|
|
52
|
+
this.#levels.length = 1;
|
|
53
|
+
return count;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../../src/core/lex/blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgCH,MAAM,OAAO,UAAU;IACrB,yEAAyE;IACzE,4BAA4B;IACnB,OAAO,GAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;IAE1D,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;IAC9E,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,KAAa,EAAE,WAAoB,EAAE,UAAkB;QAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAExB,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;YACzF,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;YACzC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC;QAED,IAAI,KAAK,KAAK,GAAG,CAAC,KAAK;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAEjD,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;YAC5D,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YACnB,KAAK,EAAE,CAAC;QACV,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3B,IAAI,KAAK,KAAK,MAAM,CAAC,KAAK;YAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC;IAC5F,CAAC;IAED,gEAAgE;IAChE,QAAQ;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a character is, in the alphabet language.md 3.1 allows outside a string
|
|
3
|
+
* literal: ASCII letters, ASCII digits, space, newline and the punctuation of
|
|
4
|
+
* 3.12. Anything else is OS1001, so a classifier that answered questions about
|
|
5
|
+
* a wider alphabet would be answering a question the language never asks.
|
|
6
|
+
*
|
|
7
|
+
* Every predicate takes a code unit rather than a string. The scanner asks
|
|
8
|
+
* about each character of the file in turn, and a one character string per
|
|
9
|
+
* question is an allocation per character of every compile.
|
|
10
|
+
*/
|
|
11
|
+
export declare const LINE_FEED = 10;
|
|
12
|
+
export declare const SPACE = 32;
|
|
13
|
+
export declare const TAB = 9;
|
|
14
|
+
export declare const QUOTE = 34;
|
|
15
|
+
export declare const APOSTROPHE = 39;
|
|
16
|
+
export declare const HASH = 35;
|
|
17
|
+
export declare const DOT = 46;
|
|
18
|
+
export declare const SLASH = 47;
|
|
19
|
+
export declare const ASTERISK = 42;
|
|
20
|
+
export declare const BACKSLASH = 92;
|
|
21
|
+
export declare const SEMICOLON = 59;
|
|
22
|
+
export declare const UNDERSCORE = 95;
|
|
23
|
+
export declare function isDigit(code: number): boolean;
|
|
24
|
+
export declare function isHexDigit(code: number): boolean;
|
|
25
|
+
export declare function isAsciiLetter(code: number): boolean;
|
|
26
|
+
/** An identifier begins with an ASCII letter or an underscore (3.3). */
|
|
27
|
+
export declare function isNameStart(code: number): boolean;
|
|
28
|
+
export declare function isNamePart(code: number): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Horizontal whitespace.
|
|
31
|
+
*
|
|
32
|
+
* A tab is included although the language accepts none: it is recognised here
|
|
33
|
+
* so that it can be reported where it sits, as OS1002 in leading whitespace and
|
|
34
|
+
* as OS1001 anywhere else, rather than ending a token and confusing the next
|
|
35
|
+
* one.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isBlank(code: number): boolean;
|
|
38
|
+
//# sourceMappingURL=characters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characters.d.ts","sourceRoot":"","sources":["../../../src/core/lex/characters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAO,MAAM,SAAS,KAAO,CAAC;AAC9B,eAAO,MAAM,KAAK,KAAO,CAAC;AAC1B,eAAO,MAAM,GAAG,IAAO,CAAC;AACxB,eAAO,MAAM,KAAK,KAAO,CAAC;AAC1B,eAAO,MAAM,UAAU,KAAO,CAAC;AAC/B,eAAO,MAAM,IAAI,KAAO,CAAC;AACzB,eAAO,MAAM,GAAG,KAAO,CAAC;AACxB,eAAO,MAAM,KAAK,KAAO,CAAC;AAC1B,eAAO,MAAM,QAAQ,KAAO,CAAC;AAC7B,eAAO,MAAM,SAAS,KAAO,CAAC;AAC9B,eAAO,MAAM,SAAS,KAAO,CAAC;AAC9B,eAAO,MAAM,UAAU,KAAO,CAAC;AAE/B,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a character is, in the alphabet language.md 3.1 allows outside a string
|
|
3
|
+
* literal: ASCII letters, ASCII digits, space, newline and the punctuation of
|
|
4
|
+
* 3.12. Anything else is OS1001, so a classifier that answered questions about
|
|
5
|
+
* a wider alphabet would be answering a question the language never asks.
|
|
6
|
+
*
|
|
7
|
+
* Every predicate takes a code unit rather than a string. The scanner asks
|
|
8
|
+
* about each character of the file in turn, and a one character string per
|
|
9
|
+
* question is an allocation per character of every compile.
|
|
10
|
+
*/
|
|
11
|
+
export const LINE_FEED = 0x0a;
|
|
12
|
+
export const SPACE = 0x20;
|
|
13
|
+
export const TAB = 0x09;
|
|
14
|
+
export const QUOTE = 0x22;
|
|
15
|
+
export const APOSTROPHE = 0x27;
|
|
16
|
+
export const HASH = 0x23;
|
|
17
|
+
export const DOT = 0x2e;
|
|
18
|
+
export const SLASH = 0x2f;
|
|
19
|
+
export const ASTERISK = 0x2a;
|
|
20
|
+
export const BACKSLASH = 0x5c;
|
|
21
|
+
export const SEMICOLON = 0x3b;
|
|
22
|
+
export const UNDERSCORE = 0x5f;
|
|
23
|
+
export function isDigit(code) {
|
|
24
|
+
return code >= 0x30 && code <= 0x39;
|
|
25
|
+
}
|
|
26
|
+
export function isHexDigit(code) {
|
|
27
|
+
return isDigit(code) || (code >= 0x41 && code <= 0x46) || (code >= 0x61 && code <= 0x66);
|
|
28
|
+
}
|
|
29
|
+
export function isAsciiLetter(code) {
|
|
30
|
+
return (code >= 0x41 && code <= 0x5a) || (code >= 0x61 && code <= 0x7a);
|
|
31
|
+
}
|
|
32
|
+
/** An identifier begins with an ASCII letter or an underscore (3.3). */
|
|
33
|
+
export function isNameStart(code) {
|
|
34
|
+
return isAsciiLetter(code) || code === UNDERSCORE;
|
|
35
|
+
}
|
|
36
|
+
export function isNamePart(code) {
|
|
37
|
+
return isNameStart(code) || isDigit(code);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Horizontal whitespace.
|
|
41
|
+
*
|
|
42
|
+
* A tab is included although the language accepts none: it is recognised here
|
|
43
|
+
* so that it can be reported where it sits, as OS1002 in leading whitespace and
|
|
44
|
+
* as OS1001 anywhere else, rather than ending a token and confusing the next
|
|
45
|
+
* one.
|
|
46
|
+
*/
|
|
47
|
+
export function isBlank(code) {
|
|
48
|
+
return code === SPACE || code === TAB;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=characters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characters.js","sourceRoot":"","sources":["../../../src/core/lex/characters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;AAC9B,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC;AAC1B,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC;AACxB,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC;AAC1B,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC;AACzB,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC;AACxB,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC;AAC1B,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAC7B,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;AAC9B,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;AAC9B,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAE/B,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC;AAC3F,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC;AAC1E,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,UAAU,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,GAAG,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The block comment markers of other languages, which this one does not have
|
|
3
|
+
* (3.2).
|
|
4
|
+
*
|
|
5
|
+
* They are recognised here so that the region a writer meant as a comment can
|
|
6
|
+
* be skipped and reported once, at the marker that opened it. Read as tokens
|
|
7
|
+
* instead, the opener is a divide against a multiply and the prose between the
|
|
8
|
+
* markers is a statement, so a reader is handed several diagnostics that are
|
|
9
|
+
* each true of a program they never wrote and none of which mentions the
|
|
10
|
+
* comment. That is OS1026's whole reason for existing.
|
|
11
|
+
*/
|
|
12
|
+
/** Whether the two characters at `at` open a region: a slash then a star. */
|
|
13
|
+
export declare function opensComment(text: string, at: number): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the two characters at `at` close one: a star then a slash.
|
|
16
|
+
*
|
|
17
|
+
* A star written against the line comment form is a multiply and a comment,
|
|
18
|
+
* never a closer, because the comment form the language does have wins.
|
|
19
|
+
* Without that, a legal line whose multiply touches the comment after it would
|
|
20
|
+
* be read as a marker and reported, and a diagnostic on a correct program is
|
|
21
|
+
* the one mistake a lexer may never make.
|
|
22
|
+
*/
|
|
23
|
+
export declare function closesComment(text: string, at: number): boolean;
|
|
24
|
+
/** What is left of a region after the line it was found on. */
|
|
25
|
+
export interface CommentRegion {
|
|
26
|
+
/** Where reading goes on: one past the closer, or the end of the line. */
|
|
27
|
+
readonly end: number;
|
|
28
|
+
/** Whether the region is still open, so the lines below belong to it too. */
|
|
29
|
+
readonly open: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reads from `from` to the closer, stopping at the end of the line.
|
|
33
|
+
*
|
|
34
|
+
* The scan is per line because the lexer works in lines, and because a region
|
|
35
|
+
* that stays open has to be the caller's decision rather than this one's: a
|
|
36
|
+
* closer on the line it opened on costs the reader nothing else, and a missing
|
|
37
|
+
* one costs them the lines below.
|
|
38
|
+
*/
|
|
39
|
+
export declare function commentRegion(text: string, from: number): CommentRegion;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a closer is written anywhere from `from` on.
|
|
42
|
+
*
|
|
43
|
+
* An opener whose closer was never written is not a region at all: it costs the
|
|
44
|
+
* reader the line it sits on and nothing below it. Reading the rest of the file
|
|
45
|
+
* as a comment would be the silent swallow that language.md 3.2 gives as the
|
|
46
|
+
* reason the form does not exist, and one marker may not cost a reader every
|
|
47
|
+
* other mistake in their file.
|
|
48
|
+
*/
|
|
49
|
+
export declare function hasCloser(text: string, from: number): boolean;
|
|
50
|
+
//# sourceMappingURL=comments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../../src/core/lex/comments.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAM/D;AAED,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAMvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK7D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ASTERISK, LINE_FEED, SLASH } from './characters.js';
|
|
2
|
+
/**
|
|
3
|
+
* The block comment markers of other languages, which this one does not have
|
|
4
|
+
* (3.2).
|
|
5
|
+
*
|
|
6
|
+
* They are recognised here so that the region a writer meant as a comment can
|
|
7
|
+
* be skipped and reported once, at the marker that opened it. Read as tokens
|
|
8
|
+
* instead, the opener is a divide against a multiply and the prose between the
|
|
9
|
+
* markers is a statement, so a reader is handed several diagnostics that are
|
|
10
|
+
* each true of a program they never wrote and none of which mentions the
|
|
11
|
+
* comment. That is OS1026's whole reason for existing.
|
|
12
|
+
*/
|
|
13
|
+
/** Whether the two characters at `at` open a region: a slash then a star. */
|
|
14
|
+
export function opensComment(text, at) {
|
|
15
|
+
return text.charCodeAt(at) === SLASH && text.charCodeAt(at + 1) === ASTERISK;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether the two characters at `at` close one: a star then a slash.
|
|
19
|
+
*
|
|
20
|
+
* A star written against the line comment form is a multiply and a comment,
|
|
21
|
+
* never a closer, because the comment form the language does have wins.
|
|
22
|
+
* Without that, a legal line whose multiply touches the comment after it would
|
|
23
|
+
* be read as a marker and reported, and a diagnostic on a correct program is
|
|
24
|
+
* the one mistake a lexer may never make.
|
|
25
|
+
*/
|
|
26
|
+
export function closesComment(text, at) {
|
|
27
|
+
return (text.charCodeAt(at) === ASTERISK &&
|
|
28
|
+
text.charCodeAt(at + 1) === SLASH &&
|
|
29
|
+
text.charCodeAt(at + 2) !== SLASH);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reads from `from` to the closer, stopping at the end of the line.
|
|
33
|
+
*
|
|
34
|
+
* The scan is per line because the lexer works in lines, and because a region
|
|
35
|
+
* that stays open has to be the caller's decision rather than this one's: a
|
|
36
|
+
* closer on the line it opened on costs the reader nothing else, and a missing
|
|
37
|
+
* one costs them the lines below.
|
|
38
|
+
*/
|
|
39
|
+
export function commentRegion(text, from) {
|
|
40
|
+
for (let i = from; i < text.length; i++) {
|
|
41
|
+
if (text.charCodeAt(i) === LINE_FEED)
|
|
42
|
+
return { end: i, open: true };
|
|
43
|
+
if (closesComment(text, i))
|
|
44
|
+
return { end: i + 2, open: false };
|
|
45
|
+
}
|
|
46
|
+
return { end: text.length, open: true };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether a closer is written anywhere from `from` on.
|
|
50
|
+
*
|
|
51
|
+
* An opener whose closer was never written is not a region at all: it costs the
|
|
52
|
+
* reader the line it sits on and nothing below it. Reading the rest of the file
|
|
53
|
+
* as a comment would be the silent swallow that language.md 3.2 gives as the
|
|
54
|
+
* reason the form does not exist, and one marker may not cost a reader every
|
|
55
|
+
* other mistake in their file.
|
|
56
|
+
*/
|
|
57
|
+
export function hasCloser(text, from) {
|
|
58
|
+
for (let i = from; i < text.length; i++) {
|
|
59
|
+
if (closesComment(text, i))
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../../src/core/lex/comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;;;;;;;;;GAUG;AAEH,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,EAAU;IACnD,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,QAAQ,CAAC;AAC/E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,EAAU;IACpD,OAAO,CACL,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,QAAQ;QAChC,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,KAAK;QACjC,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,KAAK,CAClC,CAAC;AACJ,CAAC;AAUD;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,IAAY;IACtD,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS;YAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACpE,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;YAAE,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,IAAY;IAClD,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lexer: source text to tokens, and a diagnostic for anything it cannot
|
|
3
|
+
* read.
|
|
4
|
+
*
|
|
5
|
+
* The whole of language.md section 3 lives behind this door. What comes out is
|
|
6
|
+
* a flat list of tokens with the layout already decided, so nothing downstream
|
|
7
|
+
* counts a space or wonders whether a line was blank: a newline token ends a
|
|
8
|
+
* statement, an indent and a dedent bracket a block, and a line that carried no
|
|
9
|
+
* token is simply not in the list.
|
|
10
|
+
*/
|
|
11
|
+
export { lex } from './lexer.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/lex/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lexer: source text to tokens, and a diagnostic for anything it cannot
|
|
3
|
+
* read.
|
|
4
|
+
*
|
|
5
|
+
* The whole of language.md section 3 lives behind this door. What comes out is
|
|
6
|
+
* a flat list of tokens with the layout already decided, so nothing downstream
|
|
7
|
+
* counts a space or wonders whether a line was blank: a newline token ends a
|
|
8
|
+
* statement, an indent and a dedent bracket a block, and a line that carried no
|
|
9
|
+
* token is simply not in the list.
|
|
10
|
+
*/
|
|
11
|
+
export { lex } from './lexer.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/lex/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC"}
|