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
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and do
|
|
117
|
+
not modify the License. You may add Your own attribution notices
|
|
118
|
+
within Derivative Works that You distribute, alongside or as an
|
|
119
|
+
addendum to the NOTICE text from the Work, provided that such
|
|
120
|
+
additional attribution notices cannot be construed as modifying
|
|
121
|
+
the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 OpenAlgo
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
OpenScript
|
|
2
|
+
Copyright 2026 OpenScript contributors
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
5
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
6
|
+
License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
OpenScript is an independent open source language. It is not affiliated with,
|
|
11
|
+
sponsored by, or endorsed by any charting or trading platform. Its
|
|
12
|
+
specification, documentation, error text and implementation are original work.
|
package/README.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# OpenScript
|
|
4
|
+
|
|
5
|
+
**An open trading language. Write a study or a strategy once, plot it, backtest it, trade it.**
|
|
6
|
+
|
|
7
|
+
Compiles in the browser in milliseconds with no build step and no `eval`, runs
|
|
8
|
+
the same compiled program on a server, and is specified well enough that anyone
|
|
9
|
+
can write their own engine for it.
|
|
10
|
+
|
|
11
|
+
[](./LICENSE)
|
|
12
|
+
[](./ROADMAP.md)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Status
|
|
19
|
+
|
|
20
|
+
Early development. The specification is being written first, and the
|
|
21
|
+
implementation follows it. Nothing here is stable yet. Watch
|
|
22
|
+
[ROADMAP.md](./ROADMAP.md) for what lands when.
|
|
23
|
+
|
|
24
|
+
## What it looks like
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
study("EMA cross", overlay = true)
|
|
28
|
+
|
|
29
|
+
fast = input(9, "Fast")
|
|
30
|
+
slow = input(21, "Slow")
|
|
31
|
+
|
|
32
|
+
ef = ema(close, fast)
|
|
33
|
+
es = ema(close, slow)
|
|
34
|
+
|
|
35
|
+
plot(ef, "Fast", aqua)
|
|
36
|
+
plot(es, "Slow", orange)
|
|
37
|
+
|
|
38
|
+
if crossUp(ef, es)
|
|
39
|
+
signal("BUY")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The same file becomes a strategy by adding orders:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
strategy("EMA cross", overlay = true)
|
|
46
|
+
|
|
47
|
+
if crossUp(ef, es)
|
|
48
|
+
buy(qty = 1)
|
|
49
|
+
|
|
50
|
+
if crossDown(ef, es)
|
|
51
|
+
close()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
One script. One set of numbers on the chart, in the backtest, and in the market.
|
|
55
|
+
|
|
56
|
+
## Why it exists
|
|
57
|
+
|
|
58
|
+
Chart scripting today is closed. You write in someone's editor, your script runs
|
|
59
|
+
on their servers under their limits, and the only way out is a webhook. The
|
|
60
|
+
numbers you backtest are not the numbers you trade, and you cannot check either.
|
|
61
|
+
|
|
62
|
+
OpenScript is the opposite of that:
|
|
63
|
+
|
|
64
|
+
- **Yours.** Plain text files in a folder. Version control, diffs, your own editor.
|
|
65
|
+
- **Local.** It compiles and runs on your machine. No execution quota, no loop
|
|
66
|
+
timeout, no cap on how many things you may draw.
|
|
67
|
+
- **Honest.** A higher timeframe read has to say whether it repaints. The
|
|
68
|
+
compiler warns when a script would.
|
|
69
|
+
- **Connected.** The same script places real orders through your own broker
|
|
70
|
+
connection, on paper by default.
|
|
71
|
+
- **Open.** Apache-2.0, a written specification, and a conformance suite anyone
|
|
72
|
+
can run against their own implementation.
|
|
73
|
+
|
|
74
|
+
## How it is built
|
|
75
|
+
|
|
76
|
+
The compiler does not emit JavaScript. It emits a **compiled program**: a plain
|
|
77
|
+
data structure of instructions, defined by a versioned schema.
|
|
78
|
+
|
|
79
|
+
That one decision carries the whole project:
|
|
80
|
+
|
|
81
|
+
1. It runs in a browser under a strict content security policy, with no `eval`
|
|
82
|
+
and nothing for a security team to approve.
|
|
83
|
+
2. A server-side engine is a few hundred lines that walk an instruction list,
|
|
84
|
+
not a second implementation of the language.
|
|
85
|
+
3. Anyone can write an engine in any language, and prove it correct by running
|
|
86
|
+
the conformance suite.
|
|
87
|
+
|
|
88
|
+
One compiler. One compiled format. Many small engines, all of which must agree
|
|
89
|
+
to the last decimal.
|
|
90
|
+
|
|
91
|
+
The same decision shapes the editor. This project ships the language
|
|
92
|
+
intelligence as pure functions with no DOM: highlight, complete, diagnose, hover,
|
|
93
|
+
signature, format. Highlighting comes from the real lexer, completions from the
|
|
94
|
+
standard library manifest, and the errors you see while typing are the compiler's
|
|
95
|
+
own, with their fixes taken from the error catalogue. A host supplies the text
|
|
96
|
+
component and the panel around it, and keeps its own design. The editor is not a
|
|
97
|
+
second implementation of the language to be kept in step.
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
source text
|
|
101
|
+
-> tokens
|
|
102
|
+
-> tree
|
|
103
|
+
-> checked tree (errors carry a code, a line and a fix)
|
|
104
|
+
-> compiled program (plain data, versioned schema)
|
|
105
|
+
-> any engine (browser, server, yours)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## The pieces, and which way they point
|
|
109
|
+
|
|
110
|
+
A platform adopting OpenScript usually already has a chart, or an editor, or a
|
|
111
|
+
broker connection, and sometimes all three. So the pieces are separate packages
|
|
112
|
+
and the dependencies only ever point one way.
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
openalgo-script a chart library
|
|
116
|
+
(knows nobody) (knows nobody)
|
|
117
|
+
| \ /
|
|
118
|
+
| \ /
|
|
119
|
+
| .../adapters/charts <- knows both. The only place that does
|
|
120
|
+
|
|
|
121
|
+
.../editor
|
|
122
|
+
|
|
|
123
|
+
.../adapters/codemirror <- knows the editor component. Nothing else does
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The language ships as one package with an entry point per tier, so a consumer who
|
|
127
|
+
wants only the compiler never pays for an adapter. A tier is declared only once it
|
|
128
|
+
exists: an entry point that resolves to nothing fails at a consumer's run time
|
|
129
|
+
rather than honestly at install.
|
|
130
|
+
|
|
131
|
+
| Entry point | Is | Depends on |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| `openalgo-script` | Compiler and engine | Nothing |
|
|
134
|
+
| `openalgo-script/editor` | Highlight, complete, diagnose, hover, signature, format. No DOM | The compiler |
|
|
135
|
+
| `openalgo-script/adapters/charts` | Turns a compiled study into a chart's indicator descriptor | The compiler and a chart |
|
|
136
|
+
| `openalgo-script/adapters/codemirror` | A drop-in editor language package | The editor half and an editor component |
|
|
137
|
+
| The Python engine, on its own index | The same compiled program, run on a server | Nothing |
|
|
138
|
+
|
|
139
|
+
An adapter is the only thing allowed to know two worlds at once, which is what
|
|
140
|
+
makes it the piece a platform replaces rather than the piece they patch. A
|
|
141
|
+
platform with its own chart writes their own chart adapter and keeps everything
|
|
142
|
+
else. A platform with its own editor does the same on that side.
|
|
143
|
+
|
|
144
|
+
This is enforced rather than promised. `scripts/check-layering.mjs` runs in
|
|
145
|
+
continuous integration and fails the build if the compiler imports a chart, if
|
|
146
|
+
anything outside an adapter imports a package, or if the compiler or the editor
|
|
147
|
+
half so much as mentions a browser global.
|
|
148
|
+
|
|
149
|
+
## Taking it, one step at a time
|
|
150
|
+
|
|
151
|
+
Each row is usable on its own. Nobody has to take the next one.
|
|
152
|
+
|
|
153
|
+
| You want | You add | Roughly |
|
|
154
|
+
|---|---|---|
|
|
155
|
+
| Scripts that produce numbers | `openalgo-script`, and the six-item host interface | An afternoon |
|
|
156
|
+
| Those studies on your chart | the charts adapter, plus a chart | Days. Free if the chart is the one this adapter already targets |
|
|
157
|
+
| Traders authoring in your app | `openalgo-script/editor`, and your own text component or the drop-in one | Days |
|
|
158
|
+
| Traders trading from it | Wire the order half of the host interface to your order API | About a week |
|
|
159
|
+
| To run it on your own stack | Implement the compiled program format in your language, then pass the conformance suite | Weeks |
|
|
160
|
+
|
|
161
|
+
The last row is the one that matters for the standard. A platform that will not
|
|
162
|
+
run our code at all reads the compiled program specification, writes its own
|
|
163
|
+
engine, passes the suite, and its traders' scripts are the same scripts as
|
|
164
|
+
everyone else's.
|
|
165
|
+
|
|
166
|
+
## What is guaranteed, and what proves it
|
|
167
|
+
|
|
168
|
+
A platform's engineering review asks two questions about a dependency: what do you
|
|
169
|
+
promise, and how would I know. This table is the answer to the second one. Where a
|
|
170
|
+
row says a check enforces something, that check runs in continuous integration and
|
|
171
|
+
fails the build.
|
|
172
|
+
|
|
173
|
+
| Guarantee | How you can tell | Today |
|
|
174
|
+
|---|---|---|
|
|
175
|
+
| No `eval`, no generated code, runs under a strict content security policy | Grep the source. There is no code construction anywhere, and the compiler emits data | Enforced |
|
|
176
|
+
| Zero runtime dependencies | `dependencies` is empty and stays empty | Enforced |
|
|
177
|
+
| The pieces are separable: take the language without the chart, or the chart without the language | `scripts/check-layering.mjs`. The core may not import a package or touch a browser global | Enforced |
|
|
178
|
+
| Small modules with a stated surface | `scripts/check-modularity.mjs`. A module's index is its only door | Enforced |
|
|
179
|
+
| Every error is documented, with a code, a cause and a fix | `scripts/check-error-codes.mjs`, and the code type is generated from the catalogue so an invented code will not compile | Enforced |
|
|
180
|
+
| No fact is stated in two places | `scripts/check-duplication.mjs` | Enforced, with recorded debt |
|
|
181
|
+
| The compiled program is implementable without reading our code | `spec/compiled-program.md` and `spec/host-interface.md` | Written |
|
|
182
|
+
| Two engines agree to the last decimal | The conformance suite, run against both. A disagreement blocks a release | Phase 6 gate |
|
|
183
|
+
| A runaway script stops | Instruction, memory and wall clock budgets, enforced by the engine that owns the loop | Phase 2 gate |
|
|
184
|
+
| A failing script does not take anything else down | One script's failure is a diagnostic on that script | Phase 2 gate |
|
|
185
|
+
| A saved script never stops working | The language version is declared per file and old front ends are retained | Phase 7, with a test per retained version |
|
|
186
|
+
| Performance | A benchmark with a number, in continuous integration | Phase 2 gate |
|
|
187
|
+
|
|
188
|
+
The rows marked as gates are not promises we intend to keep. They are conditions a
|
|
189
|
+
phase does not finish without, and each one is written into the roadmap beside the
|
|
190
|
+
phase that owes it.
|
|
191
|
+
|
|
192
|
+
### Why a script cannot reach anything
|
|
193
|
+
|
|
194
|
+
This is the row a security review spends its time on, so it is worth stating
|
|
195
|
+
plainly rather than leaving as a property of the architecture.
|
|
196
|
+
|
|
197
|
+
A compiled program is **data**. It is a list of instructions the engine walks. A
|
|
198
|
+
script has no way to name a function the instruction set does not expose, so there
|
|
199
|
+
is no call into the host, no network, no filesystem, no access to the object graph
|
|
200
|
+
of the process it runs in. There is nothing to escape from, because nothing was
|
|
201
|
+
ever handed over.
|
|
202
|
+
|
|
203
|
+
That also makes the budgets real rather than best-effort. The engine owns the
|
|
204
|
+
loop, so an instruction count per bar, a memory ceiling and a wall clock are
|
|
205
|
+
counters in that loop rather than something to hope about. A platform running many
|
|
206
|
+
customers' scripts in one process needs exactly this, and a design that generates
|
|
207
|
+
code and runs it cannot offer it.
|
|
208
|
+
|
|
209
|
+
## The host interface
|
|
210
|
+
|
|
211
|
+
Whatever a platform takes, it supplies six things and nothing more:
|
|
212
|
+
|
|
213
|
+
1. Bars: open, high, low, close, volume, time.
|
|
214
|
+
2. Instrument facts: tick size, lot size, session, timezone.
|
|
215
|
+
3. More bars on request, for another instrument or another timeframe.
|
|
216
|
+
4. Somewhere to draw.
|
|
217
|
+
5. Somewhere to send orders, if scripts are allowed to trade.
|
|
218
|
+
6. Somewhere to save settings.
|
|
219
|
+
|
|
220
|
+
No instrument naming scheme, no exchange rules and no broker concepts appear in
|
|
221
|
+
the language. A symbol is opaque to it: a script names a contract by what the
|
|
222
|
+
contract is, and the platform resolves that to whatever its own symbology calls
|
|
223
|
+
it. A format built around one market's derivatives means nothing on a crypto
|
|
224
|
+
exchange, and portability is the entire objective.
|
|
225
|
+
|
|
226
|
+
## Errors
|
|
227
|
+
|
|
228
|
+
Every error has a stable code, a message, the cause, the fix and an example,
|
|
229
|
+
held in one machine-readable catalogue. The compiler, the editor and the
|
|
230
|
+
documentation all read that same file, so the documentation cannot drift from
|
|
231
|
+
the compiler. The build fails if an error exists without a documented entry, or
|
|
232
|
+
an entry without a test.
|
|
233
|
+
|
|
234
|
+
## Documentation
|
|
235
|
+
|
|
236
|
+
- [ROADMAP.md](./ROADMAP.md) - what is being built, in what order
|
|
237
|
+
- [docs/](./docs) - guides, once there is something to guide
|
|
238
|
+
- [spec/](./spec) - the language specification and the compiled program schema
|
|
239
|
+
- [CONTRIBUTING.md](./CONTRIBUTING.md) - how to work on this
|
|
240
|
+
- [RELEASING.md](./RELEASING.md) - how a release is published, and the one manual step that cannot be automated
|
|
241
|
+
|
|
242
|
+
## Licence
|
|
243
|
+
|
|
244
|
+
Apache-2.0. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
|
245
|
+
|
|
246
|
+
Apache-2.0 was chosen deliberately over a copyleft licence. A trading platform
|
|
247
|
+
that wants to embed OpenScript must be able to do so without publishing its own
|
|
248
|
+
source, or the language cannot become a shared standard.
|
|
249
|
+
|
|
250
|
+
## A note on independence
|
|
251
|
+
|
|
252
|
+
OpenScript is an independent open source language. It is not affiliated with,
|
|
253
|
+
sponsored by, or endorsed by any charting or trading platform, and it is not a
|
|
254
|
+
reimplementation of any existing product. Its specification, its documentation
|
|
255
|
+
and its error text are original work.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Positioned } from '../span/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* A type as a script writes it, on a parameter, a `var` or a function result.
|
|
4
|
+
*
|
|
5
|
+
* The tree keeps the words rather than a resolved type. A resolved type is the
|
|
6
|
+
* checker's, it has no source position, and it exists for expressions that were
|
|
7
|
+
* never annotated at all; an annotation is a piece of syntax with a span that a
|
|
8
|
+
* caret can land on.
|
|
9
|
+
*/
|
|
10
|
+
/** The types a value can have, language.md 5.1. */
|
|
11
|
+
export declare const VALUE_TYPE_NAMES: readonly ["number", "string", "bool", "color"];
|
|
12
|
+
export type ValueTypeName = (typeof VALUE_TYPE_NAMES)[number];
|
|
13
|
+
/**
|
|
14
|
+
* The runtime object types of language.md 5.4.
|
|
15
|
+
*
|
|
16
|
+
* These five are recognised in a type position only and are ordinary global
|
|
17
|
+
* function names everywhere else, which is why they are not reserved words. The
|
|
18
|
+
* declaration handle types `plot`, `fill` and `level` are deliberately missing:
|
|
19
|
+
* a handle can never be a `var`, a parameter, a result or an array element, so
|
|
20
|
+
* it can never be annotated.
|
|
21
|
+
*/
|
|
22
|
+
export declare const OBJECT_TYPE_NAMES: readonly ["line", "label", "box", "polyline", "table"];
|
|
23
|
+
export type ObjectTypeName = (typeof OBJECT_TYPE_NAMES)[number];
|
|
24
|
+
export declare function isValueTypeName(text: string): text is ValueTypeName;
|
|
25
|
+
export declare function isObjectTypeName(text: string): text is ObjectTypeName;
|
|
26
|
+
/**
|
|
27
|
+
* A type written as one word.
|
|
28
|
+
*
|
|
29
|
+
* The word is an arbitrary string rather than one of the two unions above,
|
|
30
|
+
* because "that is not a type" is OS2016 and OS2016 is a check, not a parse
|
|
31
|
+
* error. A parser that could only build a legal annotation would have to report
|
|
32
|
+
* a syntax error at `len: whole`, and the reader would get a caret and no
|
|
33
|
+
* sentence naming the types that do exist.
|
|
34
|
+
*/
|
|
35
|
+
export interface NamedType extends Positioned {
|
|
36
|
+
readonly kind: 'namedType';
|
|
37
|
+
readonly name: string;
|
|
38
|
+
}
|
|
39
|
+
/** `series number`: one value of the element type per bar, language.md 5.2. */
|
|
40
|
+
export interface SeriesType extends Positioned {
|
|
41
|
+
readonly kind: 'seriesType';
|
|
42
|
+
readonly element: TypeAnnotation;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* `array<number>`, language.md 14.1.
|
|
46
|
+
*
|
|
47
|
+
* The element is any annotation and not just a legal element type, for the
|
|
48
|
+
* reason `namedType` holds any word: `array<plot>` has to reach the checker so
|
|
49
|
+
* that OS2019 can name the types an array does hold.
|
|
50
|
+
*/
|
|
51
|
+
export interface ArrayType extends Positioned {
|
|
52
|
+
readonly kind: 'arrayType';
|
|
53
|
+
readonly element: TypeAnnotation;
|
|
54
|
+
}
|
|
55
|
+
export type TypeAnnotation = NamedType | SeriesType | ArrayType;
|
|
56
|
+
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../../src/core/ast/annotations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;GAOG;AAEH,mDAAmD;AACnD,eAAO,MAAM,gBAAgB,gDAAiD,CAAC;AAC/E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,wDAAyD,CAAC;AACxF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,aAAa,CAEnE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,cAAc,CAErE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,+EAA+E;AAC/E,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CAClC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CAClC;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A type as a script writes it, on a parameter, a `var` or a function result.
|
|
3
|
+
*
|
|
4
|
+
* The tree keeps the words rather than a resolved type. A resolved type is the
|
|
5
|
+
* checker's, it has no source position, and it exists for expressions that were
|
|
6
|
+
* never annotated at all; an annotation is a piece of syntax with a span that a
|
|
7
|
+
* caret can land on.
|
|
8
|
+
*/
|
|
9
|
+
/** The types a value can have, language.md 5.1. */
|
|
10
|
+
export const VALUE_TYPE_NAMES = ['number', 'string', 'bool', 'color'];
|
|
11
|
+
/**
|
|
12
|
+
* The runtime object types of language.md 5.4.
|
|
13
|
+
*
|
|
14
|
+
* These five are recognised in a type position only and are ordinary global
|
|
15
|
+
* function names everywhere else, which is why they are not reserved words. The
|
|
16
|
+
* declaration handle types `plot`, `fill` and `level` are deliberately missing:
|
|
17
|
+
* a handle can never be a `var`, a parameter, a result or an array element, so
|
|
18
|
+
* it can never be annotated.
|
|
19
|
+
*/
|
|
20
|
+
export const OBJECT_TYPE_NAMES = ['line', 'label', 'box', 'polyline', 'table'];
|
|
21
|
+
export function isValueTypeName(text) {
|
|
22
|
+
return VALUE_TYPE_NAMES.includes(text);
|
|
23
|
+
}
|
|
24
|
+
export function isObjectTypeName(text) {
|
|
25
|
+
return OBJECT_TYPE_NAMES.includes(text);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=annotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../../src/core/ast/annotations.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,mDAAmD;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAG/E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAGxF,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAQ,gBAAsC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAQ,iBAAuC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Span } from '../span/index.js';
|
|
2
|
+
import type { NodeKind, NodeOfKind } from './node.js';
|
|
3
|
+
/** Everything a node of one kind carries beyond its kind and its span. */
|
|
4
|
+
export type NodeFields<K extends NodeKind> = Omit<NodeOfKind<K>, 'kind' | 'span'>;
|
|
5
|
+
/**
|
|
6
|
+
* Builds any node.
|
|
7
|
+
*
|
|
8
|
+
* One constructor rather than forty two, because forty two would be a second
|
|
9
|
+
* place that has to agree with the interfaces, and the day one of them drifts
|
|
10
|
+
* is the day a field goes missing from a tree that still type checks at every
|
|
11
|
+
* call site. Here the fields are the interface, minus the two parts every node
|
|
12
|
+
* has, so a missing field, a misspelt one and a stray one are each a compile
|
|
13
|
+
* error at the parser's own line.
|
|
14
|
+
*
|
|
15
|
+
* It also reads as what it builds. `makeNode('binary', span, { operator, left,
|
|
16
|
+
* right })` names its three parts, where a positional constructor of the same
|
|
17
|
+
* arity would let a parser swap two of them and compile.
|
|
18
|
+
*
|
|
19
|
+
* No field is optional. A slot a script may leave out, such as a `step` or an
|
|
20
|
+
* `else`, is `undefined` and still has to be passed, because a parser that
|
|
21
|
+
* forgets one should hear about it rather than produce a node that is missing
|
|
22
|
+
* a branch.
|
|
23
|
+
*/
|
|
24
|
+
export declare function makeNode<K extends NodeKind>(kind: K, span: Span, fields: NodeFields<K>): NodeOfKind<K>;
|
|
25
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/core/ast/build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEtD,0EAA0E;AAC1E,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAElF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EACzC,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GACpB,UAAU,CAAC,CAAC,CAAC,CAKf"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds any node.
|
|
3
|
+
*
|
|
4
|
+
* One constructor rather than forty two, because forty two would be a second
|
|
5
|
+
* place that has to agree with the interfaces, and the day one of them drifts
|
|
6
|
+
* is the day a field goes missing from a tree that still type checks at every
|
|
7
|
+
* call site. Here the fields are the interface, minus the two parts every node
|
|
8
|
+
* has, so a missing field, a misspelt one and a stray one are each a compile
|
|
9
|
+
* error at the parser's own line.
|
|
10
|
+
*
|
|
11
|
+
* It also reads as what it builds. `makeNode('binary', span, { operator, left,
|
|
12
|
+
* right })` names its three parts, where a positional constructor of the same
|
|
13
|
+
* arity would let a parser swap two of them and compile.
|
|
14
|
+
*
|
|
15
|
+
* No field is optional. A slot a script may leave out, such as a `step` or an
|
|
16
|
+
* `else`, is `undefined` and still has to be passed, because a parser that
|
|
17
|
+
* forgets one should hear about it rather than produce a node that is missing
|
|
18
|
+
* a branch.
|
|
19
|
+
*/
|
|
20
|
+
export function makeNode(kind, span, fields) {
|
|
21
|
+
// The spread of a generic Omit cannot be proved to reconstruct the node it
|
|
22
|
+
// was taken from, so the one assertion in the module is here, where the
|
|
23
|
+
// signature above has already checked every field of every call.
|
|
24
|
+
return { ...fields, kind, span };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/core/ast/build.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAO,EACP,IAAU,EACV,MAAqB;IAErB,2EAA2E;IAC3E,wEAAwE;IACxE,iEAAiE;IACjE,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,EAA8B,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AstNode } from './node.js';
|
|
2
|
+
/**
|
|
3
|
+
* The children of a node, in source order.
|
|
4
|
+
*
|
|
5
|
+
* This is the only place the shape of the tree is written down twice, and it is
|
|
6
|
+
* deliberately the only one. Everything that walks the tree walks it through
|
|
7
|
+
* here, so a field added to a node is connected once and every pass sees it,
|
|
8
|
+
* rather than being connected in the checker, forgotten in the code generator,
|
|
9
|
+
* and found by a user whose script compiled to something with a hole in it.
|
|
10
|
+
*
|
|
11
|
+
* The switch has no default arm on purpose: a new node kind stops the build
|
|
12
|
+
* here, at the one place that has to know about it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function childrenOf(node: AstNode): readonly AstNode[];
|
|
15
|
+
//# sourceMappingURL=children.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../../../src/core/ast/children.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,OAAO,EAAE,CAwF5D"}
|