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.
Files changed (266) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +12 -0
  3. package/README.md +255 -0
  4. package/dist/core/ast/annotations.d.ts +56 -0
  5. package/dist/core/ast/annotations.d.ts.map +1 -0
  6. package/dist/core/ast/annotations.js +27 -0
  7. package/dist/core/ast/annotations.js.map +1 -0
  8. package/dist/core/ast/build.d.ts +25 -0
  9. package/dist/core/ast/build.d.ts.map +1 -0
  10. package/dist/core/ast/build.js +26 -0
  11. package/dist/core/ast/build.js.map +1 -0
  12. package/dist/core/ast/children.d.ts +15 -0
  13. package/dist/core/ast/children.d.ts.map +1 -0
  14. package/dist/core/ast/children.js +103 -0
  15. package/dist/core/ast/children.js.map +1 -0
  16. package/dist/core/ast/expressions.d.ts +178 -0
  17. package/dist/core/ast/expressions.d.ts.map +1 -0
  18. package/dist/core/ast/expressions.js +50 -0
  19. package/dist/core/ast/expressions.js.map +1 -0
  20. package/dist/core/ast/header.d.ts +50 -0
  21. package/dist/core/ast/header.d.ts.map +1 -0
  22. package/dist/core/ast/header.js +2 -0
  23. package/dist/core/ast/header.js.map +1 -0
  24. package/dist/core/ast/index.d.ts +30 -0
  25. package/dist/core/ast/index.d.ts.map +1 -0
  26. package/dist/core/ast/index.js +21 -0
  27. package/dist/core/ast/index.js.map +1 -0
  28. package/dist/core/ast/name.d.ts +24 -0
  29. package/dist/core/ast/name.d.ts.map +1 -0
  30. package/dist/core/ast/name.js +2 -0
  31. package/dist/core/ast/name.js.map +1 -0
  32. package/dist/core/ast/node.d.ts +34 -0
  33. package/dist/core/ast/node.d.ts.map +1 -0
  34. package/dist/core/ast/node.js +70 -0
  35. package/dist/core/ast/node.js.map +1 -0
  36. package/dist/core/ast/script.d.ts +57 -0
  37. package/dist/core/ast/script.d.ts.map +1 -0
  38. package/dist/core/ast/script.js +2 -0
  39. package/dist/core/ast/script.js.map +1 -0
  40. package/dist/core/ast/statements.d.ts +161 -0
  41. package/dist/core/ast/statements.d.ts.map +1 -0
  42. package/dist/core/ast/statements.js +10 -0
  43. package/dist/core/ast/statements.js.map +1 -0
  44. package/dist/core/ast/walk.d.ts +39 -0
  45. package/dist/core/ast/walk.d.ts.map +1 -0
  46. package/dist/core/ast/walk.js +54 -0
  47. package/dist/core/ast/walk.js.map +1 -0
  48. package/dist/core/catalogue/catalogue.generated.d.ts +1590 -0
  49. package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -0
  50. package/dist/core/catalogue/catalogue.generated.js +162 -0
  51. package/dist/core/catalogue/catalogue.generated.js.map +1 -0
  52. package/dist/core/catalogue/index.d.ts +15 -0
  53. package/dist/core/catalogue/index.d.ts.map +1 -0
  54. package/dist/core/catalogue/index.js +4 -0
  55. package/dist/core/catalogue/index.js.map +1 -0
  56. package/dist/core/catalogue/lookup.d.ts +14 -0
  57. package/dist/core/catalogue/lookup.d.ts.map +1 -0
  58. package/dist/core/catalogue/lookup.js +19 -0
  59. package/dist/core/catalogue/lookup.js.map +1 -0
  60. package/dist/core/catalogue/template.d.ts +15 -0
  61. package/dist/core/catalogue/template.d.ts.map +1 -0
  62. package/dist/core/catalogue/template.js +33 -0
  63. package/dist/core/catalogue/template.js.map +1 -0
  64. package/dist/core/catalogue/types.d.ts +34 -0
  65. package/dist/core/catalogue/types.d.ts.map +1 -0
  66. package/dist/core/catalogue/types.js +6 -0
  67. package/dist/core/catalogue/types.js.map +1 -0
  68. package/dist/core/catalogue/values.generated.d.ts +565 -0
  69. package/dist/core/catalogue/values.generated.d.ts.map +1 -0
  70. package/dist/core/catalogue/values.generated.js +6 -0
  71. package/dist/core/catalogue/values.generated.js.map +1 -0
  72. package/dist/core/diagnostics/collector.d.ts +46 -0
  73. package/dist/core/diagnostics/collector.d.ts.map +1 -0
  74. package/dist/core/diagnostics/collector.js +55 -0
  75. package/dist/core/diagnostics/collector.js.map +1 -0
  76. package/dist/core/diagnostics/diagnostic.d.ts +40 -0
  77. package/dist/core/diagnostics/diagnostic.d.ts.map +1 -0
  78. package/dist/core/diagnostics/diagnostic.js +29 -0
  79. package/dist/core/diagnostics/diagnostic.js.map +1 -0
  80. package/dist/core/diagnostics/index.d.ts +12 -0
  81. package/dist/core/diagnostics/index.d.ts.map +1 -0
  82. package/dist/core/diagnostics/index.js +3 -0
  83. package/dist/core/diagnostics/index.js.map +1 -0
  84. package/dist/core/index.d.ts +28 -0
  85. package/dist/core/index.d.ts.map +1 -0
  86. package/dist/core/index.js +22 -0
  87. package/dist/core/index.js.map +1 -0
  88. package/dist/core/lex/blocks.d.ts +51 -0
  89. package/dist/core/lex/blocks.d.ts.map +1 -0
  90. package/dist/core/lex/blocks.js +56 -0
  91. package/dist/core/lex/blocks.js.map +1 -0
  92. package/dist/core/lex/characters.d.ts +38 -0
  93. package/dist/core/lex/characters.d.ts.map +1 -0
  94. package/dist/core/lex/characters.js +50 -0
  95. package/dist/core/lex/characters.js.map +1 -0
  96. package/dist/core/lex/comments.d.ts +50 -0
  97. package/dist/core/lex/comments.d.ts.map +1 -0
  98. package/dist/core/lex/comments.js +64 -0
  99. package/dist/core/lex/comments.js.map +1 -0
  100. package/dist/core/lex/index.d.ts +12 -0
  101. package/dist/core/lex/index.d.ts.map +1 -0
  102. package/dist/core/lex/index.js +12 -0
  103. package/dist/core/lex/index.js.map +1 -0
  104. package/dist/core/lex/layout.d.ts +40 -0
  105. package/dist/core/lex/layout.d.ts.map +1 -0
  106. package/dist/core/lex/layout.js +143 -0
  107. package/dist/core/lex/layout.js.map +1 -0
  108. package/dist/core/lex/lexer.d.ts +13 -0
  109. package/dist/core/lex/lexer.d.ts.map +1 -0
  110. package/dist/core/lex/lexer.js +419 -0
  111. package/dist/core/lex/lexer.js.map +1 -0
  112. package/dist/core/lex/numbers.d.ts +22 -0
  113. package/dist/core/lex/numbers.d.ts.map +1 -0
  114. package/dist/core/lex/numbers.js +58 -0
  115. package/dist/core/lex/numbers.js.map +1 -0
  116. package/dist/core/lex/statements.d.ts +24 -0
  117. package/dist/core/lex/statements.d.ts.map +1 -0
  118. package/dist/core/lex/statements.js +90 -0
  119. package/dist/core/lex/statements.js.map +1 -0
  120. package/dist/core/lex/strings.d.ts +27 -0
  121. package/dist/core/lex/strings.d.ts.map +1 -0
  122. package/dist/core/lex/strings.js +92 -0
  123. package/dist/core/lex/strings.js.map +1 -0
  124. package/dist/core/lex/unexpected.d.ts +31 -0
  125. package/dist/core/lex/unexpected.d.ts.map +1 -0
  126. package/dist/core/lex/unexpected.js +114 -0
  127. package/dist/core/lex/unexpected.js.map +1 -0
  128. package/dist/core/parse/annotations.d.ts +4 -0
  129. package/dist/core/parse/annotations.d.ts.map +1 -0
  130. package/dist/core/parse/annotations.js +49 -0
  131. package/dist/core/parse/annotations.js.map +1 -0
  132. package/dist/core/parse/blocks.d.ts +18 -0
  133. package/dist/core/parse/blocks.d.ts.map +1 -0
  134. package/dist/core/parse/blocks.js +47 -0
  135. package/dist/core/parse/blocks.js.map +1 -0
  136. package/dist/core/parse/branches.d.ts +17 -0
  137. package/dist/core/parse/branches.d.ts.map +1 -0
  138. package/dist/core/parse/branches.js +66 -0
  139. package/dist/core/parse/branches.js.map +1 -0
  140. package/dist/core/parse/cursor.d.ts +119 -0
  141. package/dist/core/parse/cursor.d.ts.map +1 -0
  142. package/dist/core/parse/cursor.js +305 -0
  143. package/dist/core/parse/cursor.js.map +1 -0
  144. package/dist/core/parse/expressions.d.ts +57 -0
  145. package/dist/core/parse/expressions.d.ts.map +1 -0
  146. package/dist/core/parse/expressions.js +373 -0
  147. package/dist/core/parse/expressions.js.map +1 -0
  148. package/dist/core/parse/functions.d.ts +16 -0
  149. package/dist/core/parse/functions.d.ts.map +1 -0
  150. package/dist/core/parse/functions.js +92 -0
  151. package/dist/core/parse/functions.js.map +1 -0
  152. package/dist/core/parse/index.d.ts +13 -0
  153. package/dist/core/parse/index.d.ts.map +1 -0
  154. package/dist/core/parse/index.js +13 -0
  155. package/dist/core/parse/index.js.map +1 -0
  156. package/dist/core/parse/loops.d.ts +13 -0
  157. package/dist/core/parse/loops.d.ts.map +1 -0
  158. package/dist/core/parse/loops.js +78 -0
  159. package/dist/core/parse/loops.js.map +1 -0
  160. package/dist/core/parse/names.d.ts +34 -0
  161. package/dist/core/parse/names.d.ts.map +1 -0
  162. package/dist/core/parse/names.js +122 -0
  163. package/dist/core/parse/names.js.map +1 -0
  164. package/dist/core/parse/script.d.ts +23 -0
  165. package/dist/core/parse/script.d.ts.map +1 -0
  166. package/dist/core/parse/script.js +55 -0
  167. package/dist/core/parse/script.js.map +1 -0
  168. package/dist/core/parse/statements.d.ts +14 -0
  169. package/dist/core/parse/statements.d.ts.map +1 -0
  170. package/dist/core/parse/statements.js +292 -0
  171. package/dist/core/parse/statements.js.map +1 -0
  172. package/dist/core/parse/switches.d.ts +16 -0
  173. package/dist/core/parse/switches.d.ts.map +1 -0
  174. package/dist/core/parse/switches.js +98 -0
  175. package/dist/core/parse/switches.js.map +1 -0
  176. package/dist/core/render/index.d.ts +10 -0
  177. package/dist/core/render/index.d.ts.map +1 -0
  178. package/dist/core/render/index.js +10 -0
  179. package/dist/core/render/index.js.map +1 -0
  180. package/dist/core/render/terminal.d.ts +11 -0
  181. package/dist/core/render/terminal.d.ts.map +1 -0
  182. package/dist/core/render/terminal.js +51 -0
  183. package/dist/core/render/terminal.js.map +1 -0
  184. package/dist/core/source/index.d.ts +7 -0
  185. package/dist/core/source/index.d.ts.map +1 -0
  186. package/dist/core/source/index.js +2 -0
  187. package/dist/core/source/index.js.map +1 -0
  188. package/dist/core/source/source.d.ts +41 -0
  189. package/dist/core/source/source.d.ts.map +1 -0
  190. package/dist/core/source/source.js +67 -0
  191. package/dist/core/source/source.js.map +1 -0
  192. package/dist/core/span/index.d.ts +3 -0
  193. package/dist/core/span/index.d.ts.map +1 -0
  194. package/dist/core/span/index.js +2 -0
  195. package/dist/core/span/index.js.map +1 -0
  196. package/dist/core/span/span.d.ts +67 -0
  197. package/dist/core/span/span.d.ts.map +1 -0
  198. package/dist/core/span/span.js +27 -0
  199. package/dist/core/span/span.js.map +1 -0
  200. package/dist/core/tokens/index.d.ts +8 -0
  201. package/dist/core/tokens/index.d.ts.map +1 -0
  202. package/dist/core/tokens/index.js +2 -0
  203. package/dist/core/tokens/index.js.map +1 -0
  204. package/dist/core/tokens/kind.d.ts +53 -0
  205. package/dist/core/tokens/kind.d.ts.map +1 -0
  206. package/dist/core/tokens/kind.js +94 -0
  207. package/dist/core/tokens/kind.js.map +1 -0
  208. package/dist/core/tokens/token.d.ts +36 -0
  209. package/dist/core/tokens/token.d.ts.map +1 -0
  210. package/dist/core/tokens/token.js +2 -0
  211. package/dist/core/tokens/token.js.map +1 -0
  212. package/package.json +52 -0
  213. package/spec/README.md +48 -0
  214. package/spec/errors.json +3204 -0
  215. package/src/core/ast/annotations.ts +68 -0
  216. package/src/core/ast/build.ts +35 -0
  217. package/src/core/ast/children.ts +110 -0
  218. package/src/core/ast/expressions.ts +254 -0
  219. package/src/core/ast/header.ts +53 -0
  220. package/src/core/ast/index.ts +102 -0
  221. package/src/core/ast/name.ts +24 -0
  222. package/src/core/ast/node.ts +120 -0
  223. package/src/core/ast/script.ts +60 -0
  224. package/src/core/ast/statements.ts +193 -0
  225. package/src/core/ast/walk.ts +67 -0
  226. package/src/core/catalogue/catalogue.generated.ts +171 -0
  227. package/src/core/catalogue/index.ts +20 -0
  228. package/src/core/catalogue/lookup.ts +23 -0
  229. package/src/core/catalogue/template.ts +38 -0
  230. package/src/core/catalogue/types.ts +37 -0
  231. package/src/core/catalogue/values.generated.ts +160 -0
  232. package/src/core/diagnostics/collector.ts +87 -0
  233. package/src/core/diagnostics/diagnostic.ts +72 -0
  234. package/src/core/diagnostics/index.ts +12 -0
  235. package/src/core/index.ts +146 -0
  236. package/src/core/lex/blocks.ts +92 -0
  237. package/src/core/lex/characters.ts +56 -0
  238. package/src/core/lex/comments.ts +75 -0
  239. package/src/core/lex/index.ts +11 -0
  240. package/src/core/lex/layout.ts +188 -0
  241. package/src/core/lex/lexer.ts +486 -0
  242. package/src/core/lex/numbers.ts +77 -0
  243. package/src/core/lex/statements.ts +94 -0
  244. package/src/core/lex/strings.ts +119 -0
  245. package/src/core/lex/unexpected.ts +125 -0
  246. package/src/core/parse/annotations.ts +60 -0
  247. package/src/core/parse/blocks.ts +52 -0
  248. package/src/core/parse/branches.ts +77 -0
  249. package/src/core/parse/cursor.ts +348 -0
  250. package/src/core/parse/expressions.ts +441 -0
  251. package/src/core/parse/functions.ts +109 -0
  252. package/src/core/parse/index.ts +12 -0
  253. package/src/core/parse/loops.ts +97 -0
  254. package/src/core/parse/names.ts +135 -0
  255. package/src/core/parse/script.ts +64 -0
  256. package/src/core/parse/statements.ts +329 -0
  257. package/src/core/parse/switches.ts +105 -0
  258. package/src/core/render/index.ts +9 -0
  259. package/src/core/render/terminal.ts +62 -0
  260. package/src/core/source/index.ts +6 -0
  261. package/src/core/source/source.ts +102 -0
  262. package/src/core/span/index.ts +2 -0
  263. package/src/core/span/span.ts +84 -0
  264. package/src/core/tokens/index.ts +15 -0
  265. package/src/core/tokens/kind.ts +123 -0
  266. package/src/core/tokens/token.ts +39 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Every kind of token language.md section 3 describes. Types and the two tables
3
+ * they are derived from, and no scanning: the lexer is the next stage.
4
+ *
5
+ * A keyword's kind is the word, and a punctuation token's kind is the symbol,
6
+ * so a parser reads as `token.kind === 'if'` and `token.kind === '('` rather
7
+ * than through a second vocabulary that has to be learned and kept in step.
8
+ */
9
+ /**
10
+ * The reserved words of language.md 3.4, which cannot be used as names.
11
+ *
12
+ * `import`, `map`, `matrix`, `type` and `as` are reserved and unused in version
13
+ * 1. They are here so that adding them later cannot break a script that used
14
+ * one as a variable name.
15
+ *
16
+ * Two words the grammar treats as keywords are deliberately absent, because 3.4
17
+ * does not reserve them: `version` and `limits` are recognised by position in
18
+ * the parser and are ordinary identifiers to the lexer.
19
+ */
20
+ export const RESERVED_WORDS = [
21
+ 'and',
22
+ 'array',
23
+ 'as',
24
+ 'bool',
25
+ 'break',
26
+ 'case',
27
+ 'color',
28
+ 'continue',
29
+ 'default',
30
+ 'else',
31
+ 'false',
32
+ 'fn',
33
+ 'for',
34
+ 'if',
35
+ 'import',
36
+ 'in',
37
+ 'is',
38
+ 'live',
39
+ 'map',
40
+ 'matrix',
41
+ 'none',
42
+ 'not',
43
+ 'number',
44
+ 'or',
45
+ 'return',
46
+ 'series',
47
+ 'step',
48
+ 'string',
49
+ 'strategy',
50
+ 'study',
51
+ 'switch',
52
+ 'to',
53
+ 'true',
54
+ 'type',
55
+ 'var',
56
+ 'while',
57
+ ];
58
+ /**
59
+ * The operator and punctuation tokens of language.md 3.12, longest first so a
60
+ * lexer taking them in order takes the longest match.
61
+ *
62
+ * `!` is not in the list and is not an operator on its own: it exists only as
63
+ * the first half of `!=`, and a lone one is OS1001 with the fix to write `not`.
64
+ * There are no bitwise, increment or exponent operators for the same reason
65
+ * they are missing from the specification, so there is nothing here to add.
66
+ */
67
+ export const PUNCTUATORS = [
68
+ '==',
69
+ '!=',
70
+ '<=',
71
+ '>=',
72
+ '+=',
73
+ '-=',
74
+ '*=',
75
+ '/=',
76
+ '%=',
77
+ '+',
78
+ '-',
79
+ '*',
80
+ '/',
81
+ '%',
82
+ '<',
83
+ '>',
84
+ '=',
85
+ '(',
86
+ ')',
87
+ '[',
88
+ ']',
89
+ ',',
90
+ '.',
91
+ '?',
92
+ ':',
93
+ ];
94
+ //# sourceMappingURL=kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.js","sourceRoot":"","sources":["../../../src/core/tokens/kind.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,KAAK;IACL,OAAO;IACP,IAAI;IACJ,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,UAAU;IACV,SAAS;IACT,MAAM;IACN,OAAO;IACP,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,KAAK;IACL,QAAQ;IACR,MAAM;IACN,KAAK;IACL,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,UAAU;IACV,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK;IACL,OAAO;CACC,CAAC;AAIX;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;CACK,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Span } from '../span/index.js';
2
+ import type { TokenKind } from './kind.js';
3
+ interface TokenFields {
4
+ readonly kind: TokenKind;
5
+ readonly span: Span;
6
+ /**
7
+ * The source text the token was read from, exactly as written.
8
+ *
9
+ * An indent token's text is the leading spaces of the line it opens, which is
10
+ * what OS1003 counts when it says how deeply a line was indented. A dedent, a
11
+ * newline and the end of the file carry no text.
12
+ */
13
+ readonly text: string;
14
+ }
15
+ /**
16
+ * A number literal and the value it denotes.
17
+ *
18
+ * The value is carried rather than re-read later because the literal forms of
19
+ * 3.5 include digit group underscores and a hexadecimal form, and a second
20
+ * reader of the text would be a second place that has to agree about them.
21
+ */
22
+ export interface NumberToken extends TokenFields {
23
+ readonly kind: 'numberLiteral';
24
+ readonly value: number;
25
+ }
26
+ /** A string literal with its escape sequences already resolved. */
27
+ export interface StringToken extends TokenFields {
28
+ readonly kind: 'stringLiteral';
29
+ readonly value: string;
30
+ }
31
+ export interface SimpleToken extends TokenFields {
32
+ readonly kind: Exclude<TokenKind, 'numberLiteral' | 'stringLiteral'>;
33
+ }
34
+ export type Token = NumberToken | StringToken | SimpleToken;
35
+ export {};
36
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/core/tokens/token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,UAAU,WAAW;IACnB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,mEAAmE;AACnE,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,eAAe,GAAG,eAAe,CAAC,CAAC;CACtE;AAED,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../../../src/core/tokens/token.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "openalgo-script",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "An open trading language. Write a study or a strategy once, plot it, backtest it, trade it.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/core/index.d.ts",
11
+ "import": "./dist/core/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "src",
17
+ "spec/errors.json",
18
+ "LICENSE",
19
+ "NOTICE",
20
+ "README.md"
21
+ ],
22
+ "scripts": {
23
+ "check:names": "node scripts/check-names.mjs",
24
+ "check:examples": "node scripts/check-examples.mjs",
25
+ "check:errors": "node scripts/check-error-codes.mjs",
26
+ "test": "node scripts/check-duplication.mjs && node scripts/check-error-codes.mjs && node scripts/check-examples.mjs && node scripts/check-layering.mjs && node scripts/check-modularity.mjs && node scripts/check-names.mjs && npm run build && npm run test:unit",
27
+ "test:unit": "npm run generate:errors && tsc -p tsconfig.test.json && node --test \"dist-test/tests/**/*.test.js\"",
28
+ "check:layering": "node scripts/check-layering.mjs",
29
+ "check:duplication": "node scripts/check-duplication.mjs",
30
+ "check:modularity": "node scripts/check-modularity.mjs",
31
+ "generate:errors": "node scripts/generate-error-catalogue.mjs",
32
+ "typecheck": "npm run generate:errors && tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
33
+ "build": "npm run generate:errors && tsc -p tsconfig.json",
34
+ "prepack": "npm run build"
35
+ },
36
+ "keywords": [
37
+ "trading",
38
+ "language",
39
+ "compiler",
40
+ "indicators",
41
+ "backtesting",
42
+ "technical-analysis"
43
+ ],
44
+ "engines": {
45
+ "node": ">=20"
46
+ },
47
+ "dependencies": {},
48
+ "devDependencies": {
49
+ "@types/node": "^24.0.0",
50
+ "typescript": "^5.9.0"
51
+ }
52
+ }
package/spec/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Specification
2
+
3
+ These are the documents that make up the specification. All of them are being
4
+ written now, and the implementation follows them rather than the other way
5
+ round.
6
+
7
+ | Document | Holds |
8
+ |---|---|
9
+ | [`language.md`](./language.md) | Syntax, types, scope, the per-bar execution model, the shape of the library |
10
+ | [`stdlib.md`](./stdlib.md) | The library catalogue: every name a script can call, its signature, its warmup, where it lands in the chart contract |
11
+ | [`compiled-program.md`](./compiled-program.md) | The versioned schema and machine every engine reads. The contract that lets a second implementation exist |
12
+ | [`errors.md`](./errors.md) | The error catalogue: code, cause, fix, example, for every error a compiler or an engine can emit |
13
+ | [`host-interface.md`](./host-interface.md) | Everything a platform supplies so an engine can run, and everything the engine hands back: the boundary |
14
+ | [`conformance.md`](./conformance.md) | How the suite is run, and what a passing result entitles an implementation to claim |
15
+
16
+ Six documents, and the list above is the whole of it. Two more files sit beside
17
+ them and are not the specification:
18
+
19
+ | File | Holds |
20
+ |---|---|
21
+ | [`decisions.md`](./decisions.md) | The minutes of every settled cross-document question, and the home register that says which document owns each fact |
22
+ | [`feature-matrix.md`](./feature-matrix.md) | One row per feature: whether it is specified, implemented or planned, the section that defines it, and the test that proves it |
23
+
24
+ `errors.json` is `errors.md` in machine form, generated from the same entries.
25
+ It is not a document of its own, and a change to one is the same change to the
26
+ other.
27
+
28
+ ## Which document wins
29
+
30
+ Two documents that disagree are a defect, and until it is fixed a reader still
31
+ needs an answer. These are the answers.
32
+
33
+ | The disagreement is about | The document that wins |
34
+ |---|---|
35
+ | The text of a code: its message, its cause, its fix | `errors.md` |
36
+ | A rule of the language | `language.md` |
37
+ | A function: its arguments, its result, its warmup | `stdlib.md` |
38
+ | A representation: a field name, a wire value, an encoding | `compiled-program.md` |
39
+ | The boundary: what a host supplies and what it is handed | `host-interface.md` |
40
+ | The suite: a case, a runner, a profile, a claim | `conformance.md` |
41
+
42
+ Where none of those settles it, the home register in `decisions.md` names the
43
+ document that owns the fact, and every other document cites that one rather than
44
+ restating it.
45
+
46
+ Values: `"alpha"`, `"beta"`, `"gamma"`.
47
+
48
+ One of `"alpha"`, `"beta"`, `"gamma"`.