@enspirit/elo 0.9.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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +322 -0
  3. package/bin/elo +2 -0
  4. package/bin/eloc +2 -0
  5. package/dist/src/ast.d.ts +309 -0
  6. package/dist/src/ast.d.ts.map +1 -0
  7. package/dist/src/ast.js +173 -0
  8. package/dist/src/ast.js.map +1 -0
  9. package/dist/src/bindings/javascript.d.ts +17 -0
  10. package/dist/src/bindings/javascript.d.ts.map +1 -0
  11. package/dist/src/bindings/javascript.js +350 -0
  12. package/dist/src/bindings/javascript.js.map +1 -0
  13. package/dist/src/bindings/ruby.d.ts +20 -0
  14. package/dist/src/bindings/ruby.d.ts.map +1 -0
  15. package/dist/src/bindings/ruby.js +365 -0
  16. package/dist/src/bindings/ruby.js.map +1 -0
  17. package/dist/src/bindings/sql.d.ts +20 -0
  18. package/dist/src/bindings/sql.d.ts.map +1 -0
  19. package/dist/src/bindings/sql.js +319 -0
  20. package/dist/src/bindings/sql.js.map +1 -0
  21. package/dist/src/cli.d.ts +3 -0
  22. package/dist/src/cli.d.ts.map +1 -0
  23. package/dist/src/cli.js +225 -0
  24. package/dist/src/cli.js.map +1 -0
  25. package/dist/src/compile.d.ts +47 -0
  26. package/dist/src/compile.d.ts.map +1 -0
  27. package/dist/src/compile.js +55 -0
  28. package/dist/src/compile.js.map +1 -0
  29. package/dist/src/compilers/javascript.d.ts +41 -0
  30. package/dist/src/compilers/javascript.d.ts.map +1 -0
  31. package/dist/src/compilers/javascript.js +323 -0
  32. package/dist/src/compilers/javascript.js.map +1 -0
  33. package/dist/src/compilers/ruby.d.ts +40 -0
  34. package/dist/src/compilers/ruby.d.ts.map +1 -0
  35. package/dist/src/compilers/ruby.js +326 -0
  36. package/dist/src/compilers/ruby.js.map +1 -0
  37. package/dist/src/compilers/sql.d.ts +37 -0
  38. package/dist/src/compilers/sql.d.ts.map +1 -0
  39. package/dist/src/compilers/sql.js +164 -0
  40. package/dist/src/compilers/sql.js.map +1 -0
  41. package/dist/src/elo.d.ts +3 -0
  42. package/dist/src/elo.d.ts.map +1 -0
  43. package/dist/src/elo.js +187 -0
  44. package/dist/src/elo.js.map +1 -0
  45. package/dist/src/eloc.d.ts +3 -0
  46. package/dist/src/eloc.d.ts.map +1 -0
  47. package/dist/src/eloc.js +232 -0
  48. package/dist/src/eloc.js.map +1 -0
  49. package/dist/src/eval.d.ts +3 -0
  50. package/dist/src/eval.d.ts.map +1 -0
  51. package/dist/src/eval.js +196 -0
  52. package/dist/src/eval.js.map +1 -0
  53. package/dist/src/index.d.ts +17 -0
  54. package/dist/src/index.d.ts.map +1 -0
  55. package/dist/src/index.js +36 -0
  56. package/dist/src/index.js.map +1 -0
  57. package/dist/src/ir.d.ts +295 -0
  58. package/dist/src/ir.d.ts.map +1 -0
  59. package/dist/src/ir.js +224 -0
  60. package/dist/src/ir.js.map +1 -0
  61. package/dist/src/parser.d.ts +137 -0
  62. package/dist/src/parser.d.ts.map +1 -0
  63. package/dist/src/parser.js +1266 -0
  64. package/dist/src/parser.js.map +1 -0
  65. package/dist/src/preludes/index.d.ts +14 -0
  66. package/dist/src/preludes/index.d.ts.map +1 -0
  67. package/dist/src/preludes/index.js +27 -0
  68. package/dist/src/preludes/index.js.map +1 -0
  69. package/dist/src/runtime.d.ts +23 -0
  70. package/dist/src/runtime.d.ts.map +1 -0
  71. package/dist/src/runtime.js +326 -0
  72. package/dist/src/runtime.js.map +1 -0
  73. package/dist/src/stdlib.d.ts +121 -0
  74. package/dist/src/stdlib.d.ts.map +1 -0
  75. package/dist/src/stdlib.js +237 -0
  76. package/dist/src/stdlib.js.map +1 -0
  77. package/dist/src/transform.d.ts +38 -0
  78. package/dist/src/transform.d.ts.map +1 -0
  79. package/dist/src/transform.js +322 -0
  80. package/dist/src/transform.js.map +1 -0
  81. package/dist/src/typedefs.d.ts +50 -0
  82. package/dist/src/typedefs.d.ts.map +1 -0
  83. package/dist/src/typedefs.js +294 -0
  84. package/dist/src/typedefs.js.map +1 -0
  85. package/dist/src/types.d.ts +54 -0
  86. package/dist/src/types.d.ts.map +1 -0
  87. package/dist/src/types.js +62 -0
  88. package/dist/src/types.js.map +1 -0
  89. package/package.json +66 -0
@@ -0,0 +1,137 @@
1
+ import { Expr } from './ast';
2
+ export interface ParserOptions {
3
+ maxDepth?: number;
4
+ }
5
+ export declare class Parser {
6
+ private lexer;
7
+ private currentToken;
8
+ private depth;
9
+ private maxDepth;
10
+ constructor(input: string, options?: ParserOptions);
11
+ private checkDepth;
12
+ private saveState;
13
+ private restoreState;
14
+ private formatLocation;
15
+ private eat;
16
+ private primary;
17
+ private postfix;
18
+ private unary;
19
+ private power;
20
+ private factor;
21
+ private term;
22
+ private addition;
23
+ private comparison;
24
+ private equality;
25
+ private logical_and;
26
+ /**
27
+ * Parse alternative expressions: a | b | c
28
+ * Returns first non-null value, left-to-right evaluation.
29
+ */
30
+ private alternative;
31
+ private logical_or;
32
+ /**
33
+ * Parse pipe expressions: a |> f(b) |> g(c) or a |> f |> g
34
+ * Desugars to: g(f(a, b), c) or g(f(a))
35
+ * Left-associative, lowest precedence (below logical_or)
36
+ * Parentheses are optional: a |> f is equivalent to a |> f()
37
+ */
38
+ private pipe;
39
+ /**
40
+ * Try to parse range membership: expr in expr..expr or expr in expr...expr
41
+ * Also handles: expr not in expr..expr (when negated is true)
42
+ * Returns null if this is not a range expression (e.g., it's 'in' from 'let...in')
43
+ */
44
+ private tryParseRangeMembership;
45
+ /**
46
+ * Desugar range membership expression.
47
+ * `value in start..end` becomes `value >= start and value <= end`
48
+ * `value in start...end` becomes `value >= start and value < end`
49
+ *
50
+ * For complex expressions, wraps in let to avoid multiple evaluation.
51
+ */
52
+ private desugarRangeMembership;
53
+ private letExpr;
54
+ /**
55
+ * Parse a type definition: let Person = { name: String, age: Int } in body
56
+ * Called after 'let' when we see an UPPER_IDENTIFIER
57
+ * Supports multiple bindings: let Person = {...}, Persons = [Person] in body
58
+ */
59
+ private typeDefExpr;
60
+ /**
61
+ * Parse remaining let bindings after a comma (when mixing type and value bindings)
62
+ * Returns a LetExpr with the remaining bindings
63
+ */
64
+ private parseLetBindingsAfterComma;
65
+ /**
66
+ * Parse a type expression: String, Int|String, Int(i | i > 0), [Int], { prop: TypeExpr, ... }
67
+ * Handles union types: Int|String|Bool
68
+ */
69
+ private typeExpr;
70
+ /**
71
+ * Parse a primary type expression (without union)
72
+ */
73
+ private typeExprPrimary;
74
+ /**
75
+ * Parse a subtype constraint: Int(i | i > 0)
76
+ * Called after the base type has been parsed, when we see '('
77
+ */
78
+ private subtypeConstraintExpr;
79
+ /**
80
+ * Parse a type schema: { name: String, age: Int, nickname :? String, ... } or { name: String, ...: Int }
81
+ * extras:
82
+ * - { x: Int } - closed, no extra attrs allowed
83
+ * - { x: Int, ... } - ignored, extra attrs allowed but not included
84
+ * - { x: Int, ...: String } - typed, extra attrs must match type
85
+ */
86
+ private typeSchemaExpr;
87
+ private ifExprParse;
88
+ /**
89
+ * Parse lambda expression: fn( ~> body ) or fn( x ~> body ) or fn( x, y ~> body )
90
+ */
91
+ private lambdaParse;
92
+ /**
93
+ * Parse object literal: {key: value, key2: value2, ...}
94
+ */
95
+ private objectParse;
96
+ /**
97
+ * Parse array literal: [expr, expr, ...]
98
+ */
99
+ private arrayParse;
100
+ /**
101
+ * Parse datapath literal: .x.y.z or .items.0.name
102
+ * Grammar: '.' pathSegment ('.' pathSegment)*
103
+ * pathSegment: IDENTIFIER | NUMBER
104
+ *
105
+ * Note: The lexer may tokenize "0.1" as a single NUMBER token when parsing
106
+ * consecutive numeric segments. We handle this by splitting such tokens.
107
+ * The lexer also treats ".0" as a NUMBER token (decimal number starting with dot).
108
+ */
109
+ private datapathParse;
110
+ /**
111
+ * Parse additional path segments after the first one
112
+ */
113
+ private parseAdditionalPathSegments;
114
+ /**
115
+ * Check if current token is a NUMBER that starts with a dot (e.g., ".0")
116
+ * This happens when the lexer treats ".0" as a decimal number
117
+ */
118
+ private isDecimalNumberToken;
119
+ /**
120
+ * Parse path segments from a NUMBER token.
121
+ * A NUMBER token like "0.1" in datapath context should become segments [0, 1].
122
+ * Returns the array of integer segments, or null if not a valid NUMBER.
123
+ */
124
+ private parseNumericPathSegments;
125
+ /**
126
+ * Parse a single path segment: IDENTIFIER or integer NUMBER
127
+ * Returns null if current token is not a valid segment.
128
+ */
129
+ private parsePathSegment;
130
+ private expr;
131
+ parse(): Expr;
132
+ }
133
+ /**
134
+ * Parse an arithmetic expression string into an AST
135
+ */
136
+ export declare function parse(input: string, options?: ParserOptions): Expr;
137
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiX,MAAM,OAAO,CAAC;AAuf5Y,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAID,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,QAAQ,CAAS;gBAEb,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB;IAMtD,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,GAAG;IAUX,OAAO,CAAC,OAAO;IAwJf,OAAO,CAAC,OAAO;IA8Bf,OAAO,CAAC,KAAK;IAmBb,OAAO,CAAC,KAAK;IAYb,OAAO,CAAC,MAAM;IAqBd,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,QAAQ;IAkBhB,OAAO,CAAC,UAAU;IA4ClB,OAAO,CAAC,QAAQ;IAkBhB,OAAO,CAAC,WAAW;IAWnB;;;OAGG;IACH,OAAO,CA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