@grimoirelabs/core 0.1.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/dist/builders/expressions.d.ts +33 -0
- package/dist/builders/expressions.d.ts.map +1 -0
- package/dist/builders/expressions.js +57 -0
- package/dist/builders/expressions.js.map +1 -0
- package/dist/builders/index.d.ts +44 -0
- package/dist/builders/index.d.ts.map +1 -0
- package/dist/builders/index.js +32 -0
- package/dist/builders/index.js.map +1 -0
- package/dist/builders/spell-builder.d.ts +124 -0
- package/dist/builders/spell-builder.d.ts.map +1 -0
- package/dist/builders/spell-builder.js +299 -0
- package/dist/builders/spell-builder.js.map +1 -0
- package/dist/builders/step-builder.d.ts +212 -0
- package/dist/builders/step-builder.d.ts.map +1 -0
- package/dist/builders/step-builder.js +499 -0
- package/dist/builders/step-builder.js.map +1 -0
- package/dist/compiler/expression-parser.d.ts +14 -0
- package/dist/compiler/expression-parser.d.ts.map +1 -0
- package/dist/compiler/expression-parser.js +460 -0
- package/dist/compiler/expression-parser.js.map +1 -0
- package/dist/compiler/grimoire/ast.d.ts +450 -0
- package/dist/compiler/grimoire/ast.d.ts.map +1 -0
- package/dist/compiler/grimoire/ast.js +19 -0
- package/dist/compiler/grimoire/ast.js.map +1 -0
- package/dist/compiler/grimoire/errors.d.ts +65 -0
- package/dist/compiler/grimoire/errors.d.ts.map +1 -0
- package/dist/compiler/grimoire/errors.js +86 -0
- package/dist/compiler/grimoire/errors.js.map +1 -0
- package/dist/compiler/grimoire/index.d.ts +24 -0
- package/dist/compiler/grimoire/index.d.ts.map +1 -0
- package/dist/compiler/grimoire/index.js +63 -0
- package/dist/compiler/grimoire/index.js.map +1 -0
- package/dist/compiler/grimoire/parser.d.ts +135 -0
- package/dist/compiler/grimoire/parser.d.ts.map +1 -0
- package/dist/compiler/grimoire/parser.js +2148 -0
- package/dist/compiler/grimoire/parser.js.map +1 -0
- package/dist/compiler/grimoire/tokenizer.d.ts +59 -0
- package/dist/compiler/grimoire/tokenizer.d.ts.map +1 -0
- package/dist/compiler/grimoire/tokenizer.js +509 -0
- package/dist/compiler/grimoire/tokenizer.js.map +1 -0
- package/dist/compiler/grimoire/transformer.d.ts +71 -0
- package/dist/compiler/grimoire/transformer.d.ts.map +1 -0
- package/dist/compiler/grimoire/transformer.js +1011 -0
- package/dist/compiler/grimoire/transformer.js.map +1 -0
- package/dist/compiler/index.d.ts +45 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +97 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/ir-generator.d.ts +16 -0
- package/dist/compiler/ir-generator.d.ts.map +1 -0
- package/dist/compiler/ir-generator.js +997 -0
- package/dist/compiler/ir-generator.js.map +1 -0
- package/dist/compiler/validator.d.ts +15 -0
- package/dist/compiler/validator.d.ts.map +1 -0
- package/dist/compiler/validator.js +401 -0
- package/dist/compiler/validator.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/circuit-breaker.d.ts +59 -0
- package/dist/runtime/circuit-breaker.d.ts.map +1 -0
- package/dist/runtime/circuit-breaker.js +155 -0
- package/dist/runtime/circuit-breaker.js.map +1 -0
- package/dist/runtime/context.d.ts +92 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +219 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/error-classifier.d.ts +16 -0
- package/dist/runtime/error-classifier.d.ts.map +1 -0
- package/dist/runtime/error-classifier.js +38 -0
- package/dist/runtime/error-classifier.js.map +1 -0
- package/dist/runtime/expression-evaluator.d.ts +36 -0
- package/dist/runtime/expression-evaluator.d.ts.map +1 -0
- package/dist/runtime/expression-evaluator.js +391 -0
- package/dist/runtime/expression-evaluator.js.map +1 -0
- package/dist/runtime/index.d.ts +12 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +11 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/interpreter.d.ts +59 -0
- package/dist/runtime/interpreter.d.ts.map +1 -0
- package/dist/runtime/interpreter.js +414 -0
- package/dist/runtime/interpreter.js.map +1 -0
- package/dist/runtime/skills/registry.d.ts +11 -0
- package/dist/runtime/skills/registry.d.ts.map +1 -0
- package/dist/runtime/skills/registry.js +73 -0
- package/dist/runtime/skills/registry.js.map +1 -0
- package/dist/runtime/sqlite-state-store.d.ts +28 -0
- package/dist/runtime/sqlite-state-store.d.ts.map +1 -0
- package/dist/runtime/sqlite-state-store.js +180 -0
- package/dist/runtime/sqlite-state-store.js.map +1 -0
- package/dist/runtime/state-store.d.ts +52 -0
- package/dist/runtime/state-store.d.ts.map +1 -0
- package/dist/runtime/state-store.js +32 -0
- package/dist/runtime/state-store.js.map +1 -0
- package/dist/runtime/steps/action.d.ts +17 -0
- package/dist/runtime/steps/action.d.ts.map +1 -0
- package/dist/runtime/steps/action.js +430 -0
- package/dist/runtime/steps/action.js.map +1 -0
- package/dist/runtime/steps/advisory.d.ts +28 -0
- package/dist/runtime/steps/advisory.d.ts.map +1 -0
- package/dist/runtime/steps/advisory.js +209 -0
- package/dist/runtime/steps/advisory.js.map +1 -0
- package/dist/runtime/steps/compute.d.ts +9 -0
- package/dist/runtime/steps/compute.d.ts.map +1 -0
- package/dist/runtime/steps/compute.js +74 -0
- package/dist/runtime/steps/compute.js.map +1 -0
- package/dist/runtime/steps/conditional.d.ts +14 -0
- package/dist/runtime/steps/conditional.d.ts.map +1 -0
- package/dist/runtime/steps/conditional.js +58 -0
- package/dist/runtime/steps/conditional.js.map +1 -0
- package/dist/runtime/steps/emit.d.ts +9 -0
- package/dist/runtime/steps/emit.d.ts.map +1 -0
- package/dist/runtime/steps/emit.js +70 -0
- package/dist/runtime/steps/emit.js.map +1 -0
- package/dist/runtime/steps/halt.d.ts +9 -0
- package/dist/runtime/steps/halt.d.ts.map +1 -0
- package/dist/runtime/steps/halt.js +19 -0
- package/dist/runtime/steps/halt.js.map +1 -0
- package/dist/runtime/steps/loop.d.ts +14 -0
- package/dist/runtime/steps/loop.d.ts.map +1 -0
- package/dist/runtime/steps/loop.js +109 -0
- package/dist/runtime/steps/loop.js.map +1 -0
- package/dist/runtime/steps/parallel.d.ts +9 -0
- package/dist/runtime/steps/parallel.d.ts.map +1 -0
- package/dist/runtime/steps/parallel.js +87 -0
- package/dist/runtime/steps/parallel.js.map +1 -0
- package/dist/runtime/steps/pipeline.d.ts +9 -0
- package/dist/runtime/steps/pipeline.d.ts.map +1 -0
- package/dist/runtime/steps/pipeline.js +125 -0
- package/dist/runtime/steps/pipeline.js.map +1 -0
- package/dist/runtime/steps/try.d.ts +13 -0
- package/dist/runtime/steps/try.d.ts.map +1 -0
- package/dist/runtime/steps/try.js +222 -0
- package/dist/runtime/steps/try.js.map +1 -0
- package/dist/runtime/steps/wait.d.ts +9 -0
- package/dist/runtime/steps/wait.d.ts.map +1 -0
- package/dist/runtime/steps/wait.js +38 -0
- package/dist/runtime/steps/wait.js.map +1 -0
- package/dist/types/actions.d.ts +162 -0
- package/dist/types/actions.d.ts.map +1 -0
- package/dist/types/actions.js +5 -0
- package/dist/types/actions.js.map +1 -0
- package/dist/types/execution.d.ts +276 -0
- package/dist/types/execution.d.ts.map +1 -0
- package/dist/types/execution.js +5 -0
- package/dist/types/execution.js.map +1 -0
- package/dist/types/expressions.d.ts +100 -0
- package/dist/types/expressions.d.ts.map +1 -0
- package/dist/types/expressions.js +48 -0
- package/dist/types/expressions.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/ir.d.ts +187 -0
- package/dist/types/ir.d.ts.map +1 -0
- package/dist/types/ir.js +5 -0
- package/dist/types/ir.js.map +1 -0
- package/dist/types/policy.d.ts +123 -0
- package/dist/types/policy.d.ts.map +1 -0
- package/dist/types/policy.js +5 -0
- package/dist/types/policy.js.map +1 -0
- package/dist/types/primitives.d.ts +76 -0
- package/dist/types/primitives.d.ts.map +1 -0
- package/dist/types/primitives.js +10 -0
- package/dist/types/primitives.js.map +1 -0
- package/dist/types/steps.d.ts +226 -0
- package/dist/types/steps.d.ts.map +1 -0
- package/dist/types/steps.js +5 -0
- package/dist/types/steps.js.map +1 -0
- package/dist/venues/index.d.ts +6 -0
- package/dist/venues/index.d.ts.map +1 -0
- package/dist/venues/index.js +26 -0
- package/dist/venues/index.js.map +1 -0
- package/dist/venues/types.d.ts +40 -0
- package/dist/venues/types.d.ts.map +1 -0
- package/dist/venues/types.js +5 -0
- package/dist/venues/types.js.map +1 -0
- package/dist/wallet/executor.d.ts +109 -0
- package/dist/wallet/executor.d.ts.map +1 -0
- package/dist/wallet/executor.js +354 -0
- package/dist/wallet/executor.js.map +1 -0
- package/dist/wallet/index.d.ts +14 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +13 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/wallet/keystore.d.ts +44 -0
- package/dist/wallet/keystore.d.ts.map +1 -0
- package/dist/wallet/keystore.js +296 -0
- package/dist/wallet/keystore.js.map +1 -0
- package/dist/wallet/provider.d.ts +111 -0
- package/dist/wallet/provider.d.ts.map +1 -0
- package/dist/wallet/provider.js +309 -0
- package/dist/wallet/provider.js.map +1 -0
- package/dist/wallet/tx-builder.d.ts +85 -0
- package/dist/wallet/tx-builder.d.ts.map +1 -0
- package/dist/wallet/tx-builder.js +290 -0
- package/dist/wallet/tx-builder.js.map +1 -0
- package/dist/wallet/types.d.ts +116 -0
- package/dist/wallet/types.d.ts.map +1 -0
- package/dist/wallet/types.js +86 -0
- package/dist/wallet/types.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST node types for the Grimoire syntax
|
|
3
|
+
*/
|
|
4
|
+
import type { SourceSpan } from "./errors.js";
|
|
5
|
+
/** Base AST node with location info */
|
|
6
|
+
export interface ASTNode {
|
|
7
|
+
span?: SourceSpan;
|
|
8
|
+
}
|
|
9
|
+
/** Complete spell AST */
|
|
10
|
+
export interface SpellAST extends ASTNode {
|
|
11
|
+
kind: "spell";
|
|
12
|
+
name: string;
|
|
13
|
+
sections: SectionNode[];
|
|
14
|
+
triggers: TriggerHandler[];
|
|
15
|
+
imports: ImportNode[];
|
|
16
|
+
blocks: BlockDef[];
|
|
17
|
+
}
|
|
18
|
+
/** Section node types */
|
|
19
|
+
export type SectionNode = VersionSection | DescriptionSection | AssetsSection | ParamsSection | LimitsSection | VenuesSection | StateSection | SkillsSection | AdvisorsSection | GuardsSection;
|
|
20
|
+
/** Version declaration */
|
|
21
|
+
export interface VersionSection extends ASTNode {
|
|
22
|
+
kind: "version";
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
/** Description section */
|
|
26
|
+
export interface DescriptionSection extends ASTNode {
|
|
27
|
+
kind: "description";
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
30
|
+
/** Assets section: assets: [USDC, USDT, DAI] or assets: { ... } */
|
|
31
|
+
export interface AssetsSection extends ASTNode {
|
|
32
|
+
kind: "assets";
|
|
33
|
+
items: AssetItem[];
|
|
34
|
+
}
|
|
35
|
+
export interface AssetItem extends ASTNode {
|
|
36
|
+
symbol: string;
|
|
37
|
+
chain?: number;
|
|
38
|
+
address?: string;
|
|
39
|
+
decimals?: number;
|
|
40
|
+
}
|
|
41
|
+
/** Params section */
|
|
42
|
+
export interface ParamsSection extends ASTNode {
|
|
43
|
+
kind: "params";
|
|
44
|
+
items: ParamItem[];
|
|
45
|
+
}
|
|
46
|
+
export interface ParamItem extends ASTNode {
|
|
47
|
+
name: string;
|
|
48
|
+
value?: ExpressionNode;
|
|
49
|
+
type?: "number" | "bool" | "address" | "asset" | "string" | "amount" | "bps" | "duration";
|
|
50
|
+
asset?: string;
|
|
51
|
+
min?: number;
|
|
52
|
+
max?: number;
|
|
53
|
+
}
|
|
54
|
+
/** Limits section */
|
|
55
|
+
export interface LimitsSection extends ASTNode {
|
|
56
|
+
kind: "limits";
|
|
57
|
+
items: LimitItem[];
|
|
58
|
+
}
|
|
59
|
+
export interface LimitItem extends ASTNode {
|
|
60
|
+
name: string;
|
|
61
|
+
value: ExpressionNode;
|
|
62
|
+
}
|
|
63
|
+
/** Venues section */
|
|
64
|
+
export interface VenuesSection extends ASTNode {
|
|
65
|
+
kind: "venues";
|
|
66
|
+
groups: VenueGroup[];
|
|
67
|
+
}
|
|
68
|
+
export interface VenueGroup extends ASTNode {
|
|
69
|
+
name: string;
|
|
70
|
+
venues: VenueRef[];
|
|
71
|
+
}
|
|
72
|
+
/** Venue reference: @aave_v3 */
|
|
73
|
+
export interface VenueRef extends ASTNode {
|
|
74
|
+
kind: "venue_ref";
|
|
75
|
+
name: string;
|
|
76
|
+
chain?: number;
|
|
77
|
+
address?: string;
|
|
78
|
+
}
|
|
79
|
+
/** State section */
|
|
80
|
+
export interface StateSection extends ASTNode {
|
|
81
|
+
kind: "state";
|
|
82
|
+
persistent: StateItem[];
|
|
83
|
+
ephemeral: StateItem[];
|
|
84
|
+
}
|
|
85
|
+
export interface StateItem extends ASTNode {
|
|
86
|
+
name: string;
|
|
87
|
+
initialValue: ExpressionNode;
|
|
88
|
+
}
|
|
89
|
+
/** Skills section */
|
|
90
|
+
export interface SkillsSection extends ASTNode {
|
|
91
|
+
kind: "skills";
|
|
92
|
+
items: SkillItem[];
|
|
93
|
+
}
|
|
94
|
+
export interface SkillItem extends ASTNode {
|
|
95
|
+
name: string;
|
|
96
|
+
type: "swap" | "yield" | "lending" | "staking" | "bridge";
|
|
97
|
+
adapters: string[];
|
|
98
|
+
defaultConstraints?: {
|
|
99
|
+
maxSlippage?: ExpressionNode;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Advisors section */
|
|
103
|
+
export interface AdvisorsSection extends ASTNode {
|
|
104
|
+
kind: "advisors";
|
|
105
|
+
items: AdvisorItem[];
|
|
106
|
+
}
|
|
107
|
+
export interface AdvisorItem extends ASTNode {
|
|
108
|
+
name: string;
|
|
109
|
+
model: string;
|
|
110
|
+
systemPrompt?: string;
|
|
111
|
+
skills?: string[];
|
|
112
|
+
allowedTools?: string[];
|
|
113
|
+
mcp?: string[];
|
|
114
|
+
timeout?: number;
|
|
115
|
+
fallback?: boolean;
|
|
116
|
+
maxPerRun?: number;
|
|
117
|
+
maxPerHour?: number;
|
|
118
|
+
}
|
|
119
|
+
/** Guards section */
|
|
120
|
+
export interface GuardsSection extends ASTNode {
|
|
121
|
+
kind: "guards";
|
|
122
|
+
items: GuardItem[];
|
|
123
|
+
}
|
|
124
|
+
export interface GuardItem extends ASTNode {
|
|
125
|
+
id: string;
|
|
126
|
+
check: ExpressionNode | AdvisoryExpr;
|
|
127
|
+
severity: "warn" | "revert" | "halt" | "pause";
|
|
128
|
+
message?: string;
|
|
129
|
+
fallback?: boolean;
|
|
130
|
+
}
|
|
131
|
+
/** Trigger types */
|
|
132
|
+
export type TriggerType = {
|
|
133
|
+
kind: "manual";
|
|
134
|
+
} | {
|
|
135
|
+
kind: "schedule";
|
|
136
|
+
cron: string;
|
|
137
|
+
} | {
|
|
138
|
+
kind: "hourly";
|
|
139
|
+
} | {
|
|
140
|
+
kind: "daily";
|
|
141
|
+
} | {
|
|
142
|
+
kind: "condition";
|
|
143
|
+
expression: ExpressionNode;
|
|
144
|
+
pollInterval?: number;
|
|
145
|
+
} | {
|
|
146
|
+
kind: "event";
|
|
147
|
+
event: string;
|
|
148
|
+
filter?: ExpressionNode;
|
|
149
|
+
};
|
|
150
|
+
/** Trigger handler: on manual: / on hourly: etc */
|
|
151
|
+
export interface TriggerHandler extends ASTNode {
|
|
152
|
+
kind: "trigger_handler";
|
|
153
|
+
trigger: TriggerType;
|
|
154
|
+
body: StatementNode[];
|
|
155
|
+
}
|
|
156
|
+
/** Statement node types */
|
|
157
|
+
export type StatementNode = AssignmentNode | DoNode | IfNode | ForNode | RepeatNode | UntilNode | TryNode | ParallelNode | PipelineNode | AdviseNode | AtomicNode | MethodCallNode | EmitNode | HaltNode | WaitNode | AdvisoryNode | PassNode;
|
|
158
|
+
/** Import declaration */
|
|
159
|
+
export interface ImportNode extends ASTNode {
|
|
160
|
+
kind: "import";
|
|
161
|
+
path: string;
|
|
162
|
+
alias?: string;
|
|
163
|
+
}
|
|
164
|
+
/** Block definition */
|
|
165
|
+
export interface BlockDef extends ASTNode {
|
|
166
|
+
kind: "block";
|
|
167
|
+
name: string;
|
|
168
|
+
params: string[];
|
|
169
|
+
body: StatementNode[];
|
|
170
|
+
}
|
|
171
|
+
/** Do (block invocation) */
|
|
172
|
+
export interface DoNode extends ASTNode {
|
|
173
|
+
kind: "do";
|
|
174
|
+
name: string;
|
|
175
|
+
args: ExpressionNode[];
|
|
176
|
+
}
|
|
177
|
+
/** Repeat loop: repeat N: ... */
|
|
178
|
+
export interface RepeatNode extends ASTNode {
|
|
179
|
+
kind: "repeat";
|
|
180
|
+
count: ExpressionNode;
|
|
181
|
+
body: StatementNode[];
|
|
182
|
+
}
|
|
183
|
+
/** Until loop: loop until <expr> max N: ... */
|
|
184
|
+
export interface UntilNode extends ASTNode {
|
|
185
|
+
kind: "until";
|
|
186
|
+
condition: ExpressionNode;
|
|
187
|
+
maxIterations?: number;
|
|
188
|
+
body: StatementNode[];
|
|
189
|
+
}
|
|
190
|
+
/** Try/catch/finally */
|
|
191
|
+
export interface TryNode extends ASTNode {
|
|
192
|
+
kind: "try";
|
|
193
|
+
tryBody: StatementNode[];
|
|
194
|
+
catches: CatchNode[];
|
|
195
|
+
finallyBody?: StatementNode[];
|
|
196
|
+
}
|
|
197
|
+
export interface CatchNode extends ASTNode {
|
|
198
|
+
kind: "catch";
|
|
199
|
+
error: string;
|
|
200
|
+
action?: "skip" | "halt" | "revert";
|
|
201
|
+
retry?: RetrySpec;
|
|
202
|
+
body: StatementNode[];
|
|
203
|
+
}
|
|
204
|
+
export interface RetrySpec extends ASTNode {
|
|
205
|
+
kind: "retry";
|
|
206
|
+
maxAttempts: number;
|
|
207
|
+
backoff: "none" | "linear" | "exponential";
|
|
208
|
+
backoffBase?: number;
|
|
209
|
+
maxBackoff?: number;
|
|
210
|
+
}
|
|
211
|
+
/** Parallel execution */
|
|
212
|
+
export interface ParallelNode extends ASTNode {
|
|
213
|
+
kind: "parallel";
|
|
214
|
+
join?: ParallelJoinNode;
|
|
215
|
+
onFail?: "abort" | "continue";
|
|
216
|
+
branches: ParallelBranchNode[];
|
|
217
|
+
}
|
|
218
|
+
export interface ParallelBranchNode extends ASTNode {
|
|
219
|
+
kind: "parallel_branch";
|
|
220
|
+
name: string;
|
|
221
|
+
body: StatementNode[];
|
|
222
|
+
}
|
|
223
|
+
export interface ParallelJoinNode extends ASTNode {
|
|
224
|
+
kind: "parallel_join";
|
|
225
|
+
type: "all" | "first" | "best" | "any" | "majority";
|
|
226
|
+
metric?: ExpressionNode;
|
|
227
|
+
order?: "max" | "min";
|
|
228
|
+
count?: number;
|
|
229
|
+
}
|
|
230
|
+
/** Pipeline operations */
|
|
231
|
+
export interface PipelineNode extends ASTNode {
|
|
232
|
+
kind: "pipeline";
|
|
233
|
+
source: ExpressionNode;
|
|
234
|
+
stages: PipelineStageNode[];
|
|
235
|
+
outputBinding?: string;
|
|
236
|
+
}
|
|
237
|
+
export interface PipelineStageNode extends ASTNode {
|
|
238
|
+
kind: "pipeline_stage";
|
|
239
|
+
op: "map" | "filter" | "reduce" | "where" | "take" | "skip" | "sort" | "pmap";
|
|
240
|
+
step: StatementNode;
|
|
241
|
+
initial?: ExpressionNode;
|
|
242
|
+
count?: number;
|
|
243
|
+
order?: "asc" | "desc";
|
|
244
|
+
by?: ExpressionNode;
|
|
245
|
+
}
|
|
246
|
+
/** Advisory call statement: x = advise advisor: "prompt" ... */
|
|
247
|
+
export interface AdviseNode extends ASTNode {
|
|
248
|
+
kind: "advise";
|
|
249
|
+
target: string;
|
|
250
|
+
advisor: string;
|
|
251
|
+
prompt: string;
|
|
252
|
+
outputSchema: AdvisoryOutputSchemaNode;
|
|
253
|
+
timeout: number;
|
|
254
|
+
fallback: ExpressionNode;
|
|
255
|
+
}
|
|
256
|
+
export interface AdvisoryOutputSchemaNode extends ASTNode {
|
|
257
|
+
kind: "advisory_output_schema";
|
|
258
|
+
type: "boolean" | "number" | "enum" | "string" | "object" | "array";
|
|
259
|
+
values?: string[];
|
|
260
|
+
min?: number;
|
|
261
|
+
max?: number;
|
|
262
|
+
minLength?: number;
|
|
263
|
+
maxLength?: number;
|
|
264
|
+
pattern?: string;
|
|
265
|
+
fields?: Record<string, AdvisoryOutputSchemaNode>;
|
|
266
|
+
items?: AdvisoryOutputSchemaNode;
|
|
267
|
+
}
|
|
268
|
+
/** Assignment: x = expr [with key=value, ...] */
|
|
269
|
+
export interface AssignmentNode extends ASTNode {
|
|
270
|
+
kind: "assignment";
|
|
271
|
+
target: string;
|
|
272
|
+
value: ExpressionNode;
|
|
273
|
+
constraints?: ConstraintClause;
|
|
274
|
+
skill?: string;
|
|
275
|
+
}
|
|
276
|
+
/** If statement: if cond: ... elif cond: ... else: ... */
|
|
277
|
+
export interface IfNode extends ASTNode {
|
|
278
|
+
kind: "if";
|
|
279
|
+
condition: ExpressionNode;
|
|
280
|
+
thenBody: StatementNode[];
|
|
281
|
+
elifs: Array<{
|
|
282
|
+
condition: ExpressionNode;
|
|
283
|
+
body: StatementNode[];
|
|
284
|
+
}>;
|
|
285
|
+
elseBody: StatementNode[];
|
|
286
|
+
}
|
|
287
|
+
/** For loop: for x in items: ... */
|
|
288
|
+
export interface ForNode extends ASTNode {
|
|
289
|
+
kind: "for";
|
|
290
|
+
variable: string;
|
|
291
|
+
iterable: ExpressionNode;
|
|
292
|
+
body: StatementNode[];
|
|
293
|
+
maxIterations?: number;
|
|
294
|
+
}
|
|
295
|
+
/** Atomic block: atomic: ... (transaction grouping) */
|
|
296
|
+
export interface AtomicNode extends ASTNode {
|
|
297
|
+
kind: "atomic";
|
|
298
|
+
body: StatementNode[];
|
|
299
|
+
onFailure?: "revert" | "skip" | "halt";
|
|
300
|
+
}
|
|
301
|
+
/** Method call: venue.deposit(asset, amount) [with key=value, ...] */
|
|
302
|
+
export interface MethodCallNode extends ASTNode {
|
|
303
|
+
kind: "method_call";
|
|
304
|
+
object: ExpressionNode;
|
|
305
|
+
method: string;
|
|
306
|
+
args: ExpressionNode[];
|
|
307
|
+
outputBinding?: string;
|
|
308
|
+
constraints?: ConstraintClause;
|
|
309
|
+
skill?: string;
|
|
310
|
+
}
|
|
311
|
+
/** Emit statement: emit event_name(key=value, ...) */
|
|
312
|
+
export interface EmitNode extends ASTNode {
|
|
313
|
+
kind: "emit";
|
|
314
|
+
event: string;
|
|
315
|
+
data: Array<{
|
|
316
|
+
key: string;
|
|
317
|
+
value: ExpressionNode;
|
|
318
|
+
}>;
|
|
319
|
+
}
|
|
320
|
+
/** Halt statement: halt "reason" */
|
|
321
|
+
export interface HaltNode extends ASTNode {
|
|
322
|
+
kind: "halt";
|
|
323
|
+
reason: string;
|
|
324
|
+
}
|
|
325
|
+
/** Wait statement: wait 10s / wait 1h */
|
|
326
|
+
export interface WaitNode extends ASTNode {
|
|
327
|
+
kind: "wait";
|
|
328
|
+
duration: number;
|
|
329
|
+
}
|
|
330
|
+
/** Advisory statement: if **prompt**: ... */
|
|
331
|
+
export interface AdvisoryNode extends ASTNode {
|
|
332
|
+
kind: "advisory";
|
|
333
|
+
advisor?: string;
|
|
334
|
+
prompt: string;
|
|
335
|
+
thenBody: StatementNode[];
|
|
336
|
+
elseBody: StatementNode[];
|
|
337
|
+
timeout?: number;
|
|
338
|
+
fallback?: boolean;
|
|
339
|
+
}
|
|
340
|
+
/** Pass statement (no-op) */
|
|
341
|
+
export interface PassNode extends ASTNode {
|
|
342
|
+
kind: "pass";
|
|
343
|
+
}
|
|
344
|
+
/** Constraint clause: with slippage=50, deadline=300 */
|
|
345
|
+
export interface ConstraintClause extends ASTNode {
|
|
346
|
+
kind: "constraint_clause";
|
|
347
|
+
constraints: Array<{
|
|
348
|
+
key: string;
|
|
349
|
+
value: ExpressionNode;
|
|
350
|
+
}>;
|
|
351
|
+
}
|
|
352
|
+
/** Expression node types */
|
|
353
|
+
export type ExpressionNode = LiteralNode | UnitLiteralNode | IdentifierNode | VenueRefExpr | AdvisoryExpr | PercentageExpr | BinaryExprNode | UnaryExprNode | TernaryExprNode | CallExprNode | PropertyAccessNode | ArrayAccessNode | ArrayLiteralNode | ObjectLiteralNode;
|
|
354
|
+
/** Literal value */
|
|
355
|
+
export interface LiteralNode extends ASTNode {
|
|
356
|
+
kind: "literal";
|
|
357
|
+
value: string | number | boolean;
|
|
358
|
+
literalType: "string" | "number" | "boolean" | "address";
|
|
359
|
+
}
|
|
360
|
+
/** Unit literal: 1.5 USDC, 50 bps */
|
|
361
|
+
export interface UnitLiteralNode extends ASTNode {
|
|
362
|
+
kind: "unit_literal";
|
|
363
|
+
value: number;
|
|
364
|
+
unit: string;
|
|
365
|
+
}
|
|
366
|
+
/** Identifier reference */
|
|
367
|
+
export interface IdentifierNode extends ASTNode {
|
|
368
|
+
kind: "identifier";
|
|
369
|
+
name: string;
|
|
370
|
+
}
|
|
371
|
+
/** Venue reference expression: @aave_v3 */
|
|
372
|
+
export interface VenueRefExpr extends ASTNode {
|
|
373
|
+
kind: "venue_ref_expr";
|
|
374
|
+
name: string;
|
|
375
|
+
}
|
|
376
|
+
/** Advisory expression: **prompt text** */
|
|
377
|
+
export interface AdvisoryExpr extends ASTNode {
|
|
378
|
+
kind: "advisory_expr";
|
|
379
|
+
prompt: string;
|
|
380
|
+
advisor?: string;
|
|
381
|
+
}
|
|
382
|
+
/** Percentage literal: 50% */
|
|
383
|
+
export interface PercentageExpr extends ASTNode {
|
|
384
|
+
kind: "percentage";
|
|
385
|
+
value: number;
|
|
386
|
+
}
|
|
387
|
+
/** Binary operation */
|
|
388
|
+
export interface BinaryExprNode extends ASTNode {
|
|
389
|
+
kind: "binary";
|
|
390
|
+
op: BinaryOperator;
|
|
391
|
+
left: ExpressionNode;
|
|
392
|
+
right: ExpressionNode;
|
|
393
|
+
}
|
|
394
|
+
export type BinaryOperator = "+" | "-" | "*" | "/" | "%" | "==" | "!=" | "<" | ">" | "<=" | ">=" | "and" | "or";
|
|
395
|
+
/** Unary operation */
|
|
396
|
+
export interface UnaryExprNode extends ASTNode {
|
|
397
|
+
kind: "unary";
|
|
398
|
+
op: UnaryOperator;
|
|
399
|
+
arg: ExpressionNode;
|
|
400
|
+
}
|
|
401
|
+
export type UnaryOperator = "not" | "-";
|
|
402
|
+
/** Ternary expression */
|
|
403
|
+
export interface TernaryExprNode extends ASTNode {
|
|
404
|
+
kind: "ternary";
|
|
405
|
+
condition: ExpressionNode;
|
|
406
|
+
thenExpr: ExpressionNode;
|
|
407
|
+
elseExpr: ExpressionNode;
|
|
408
|
+
}
|
|
409
|
+
/** Function/method call */
|
|
410
|
+
export interface CallExprNode extends ASTNode {
|
|
411
|
+
kind: "call";
|
|
412
|
+
callee: ExpressionNode;
|
|
413
|
+
args: ExpressionNode[];
|
|
414
|
+
kwargs?: Array<{
|
|
415
|
+
key: string;
|
|
416
|
+
value: ExpressionNode;
|
|
417
|
+
}>;
|
|
418
|
+
}
|
|
419
|
+
/** Property access: obj.prop */
|
|
420
|
+
export interface PropertyAccessNode extends ASTNode {
|
|
421
|
+
kind: "property_access";
|
|
422
|
+
object: ExpressionNode;
|
|
423
|
+
property: string;
|
|
424
|
+
}
|
|
425
|
+
/** Array access: arr[index] */
|
|
426
|
+
export interface ArrayAccessNode extends ASTNode {
|
|
427
|
+
kind: "array_access";
|
|
428
|
+
array: ExpressionNode;
|
|
429
|
+
index: ExpressionNode;
|
|
430
|
+
}
|
|
431
|
+
/** Array literal: [a, b, c] */
|
|
432
|
+
export interface ArrayLiteralNode extends ASTNode {
|
|
433
|
+
kind: "array_literal";
|
|
434
|
+
elements: ExpressionNode[];
|
|
435
|
+
}
|
|
436
|
+
/** Object literal: {key: value, ...} */
|
|
437
|
+
export interface ObjectLiteralNode extends ASTNode {
|
|
438
|
+
kind: "object_literal";
|
|
439
|
+
entries: Array<{
|
|
440
|
+
key: string;
|
|
441
|
+
value: ExpressionNode;
|
|
442
|
+
}>;
|
|
443
|
+
}
|
|
444
|
+
/** Check if expression is advisory */
|
|
445
|
+
export declare function isAdvisoryExpr(node: ExpressionNode): node is AdvisoryExpr;
|
|
446
|
+
/** Check if expression is venue ref */
|
|
447
|
+
export declare function isVenueRef(node: ExpressionNode): node is VenueRefExpr;
|
|
448
|
+
/** Check if expression is percentage */
|
|
449
|
+
export declare function isPercentage(node: ExpressionNode): node is PercentageExpr;
|
|
450
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../src/compiler/grimoire/ast.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM9C,uCAAuC;AACvC,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAMD,yBAAyB;AACzB,MAAM,WAAW,QAAS,SAAQ,OAAO;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,MAAM,EAAE,QAAQ,EAAE,CAAC;CACpB;AAMD,yBAAyB;AACzB,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,kBAAkB,GAClB,aAAa,GACb,aAAa,GACb,aAAa,GACb,aAAa,GACb,YAAY,GACZ,aAAa,GACb,eAAe,GACf,aAAa,CAAC;AAElB,0BAA0B;AAC1B,MAAM,WAAW,cAAe,SAAQ,OAAO;IAC7C,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0BAA0B;AAC1B,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AAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,cAAc,CAAA;KAAE,CAAC,CAAC;CACxD;AAMD,sCAAsC;AACtC,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,IAAI,YAAY,CAEzE;AAED,uCAAuC;AACvC,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,IAAI,YAAY,CAErE;AAED,wCAAwC;AACxC,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,IAAI,cAAc,CAEzE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST node types for the Grimoire syntax
|
|
3
|
+
*/
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// HELPERS
|
|
6
|
+
// =============================================================================
|
|
7
|
+
/** Check if expression is advisory */
|
|
8
|
+
export function isAdvisoryExpr(node) {
|
|
9
|
+
return node.kind === "advisory_expr";
|
|
10
|
+
}
|
|
11
|
+
/** Check if expression is venue ref */
|
|
12
|
+
export function isVenueRef(node) {
|
|
13
|
+
return node.kind === "venue_ref_expr";
|
|
14
|
+
}
|
|
15
|
+
/** Check if expression is percentage */
|
|
16
|
+
export function isPercentage(node) {
|
|
17
|
+
return node.kind === "percentage";
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../../src/compiler/grimoire/ast.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmjBH,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,sCAAsC;AACtC,MAAM,UAAU,cAAc,CAAC,IAAoB;IACjD,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC;AACvC,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,UAAU,CAAC,IAAoB;IAC7C,OAAO,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAAC;AACxC,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,YAAY,CAAC,IAAoB;IAC/C,OAAO,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error types and formatting for Grimoire parser
|
|
3
|
+
*/
|
|
4
|
+
/** Source location for error reporting */
|
|
5
|
+
export interface SourceLocation {
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
offset: number;
|
|
9
|
+
}
|
|
10
|
+
/** Source span (start to end) */
|
|
11
|
+
export interface SourceSpan {
|
|
12
|
+
start: SourceLocation;
|
|
13
|
+
end: SourceLocation;
|
|
14
|
+
}
|
|
15
|
+
/** Base error class for Grimoire parsing */
|
|
16
|
+
export declare class GrimoireError extends Error {
|
|
17
|
+
readonly code: string;
|
|
18
|
+
readonly location?: SourceLocation;
|
|
19
|
+
readonly span?: SourceSpan;
|
|
20
|
+
readonly source?: string;
|
|
21
|
+
constructor(code: string, message: string, options?: {
|
|
22
|
+
location?: SourceLocation;
|
|
23
|
+
span?: SourceSpan;
|
|
24
|
+
source?: string;
|
|
25
|
+
});
|
|
26
|
+
/** Format error with source context */
|
|
27
|
+
format(): string;
|
|
28
|
+
}
|
|
29
|
+
/** Tokenization error */
|
|
30
|
+
export declare class TokenizeError extends GrimoireError {
|
|
31
|
+
constructor(message: string, options?: {
|
|
32
|
+
location?: SourceLocation;
|
|
33
|
+
source?: string;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** Parse error */
|
|
37
|
+
export declare class ParseError extends GrimoireError {
|
|
38
|
+
constructor(message: string, options?: {
|
|
39
|
+
location?: SourceLocation;
|
|
40
|
+
span?: SourceSpan;
|
|
41
|
+
source?: string;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** Indentation error */
|
|
45
|
+
export declare class IndentationError extends GrimoireError {
|
|
46
|
+
constructor(message: string, options?: {
|
|
47
|
+
location?: SourceLocation;
|
|
48
|
+
source?: string;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Transform error (AST to SpellSource) */
|
|
52
|
+
export declare class TransformError extends GrimoireError {
|
|
53
|
+
constructor(message: string, options?: {
|
|
54
|
+
location?: SourceLocation;
|
|
55
|
+
span?: SourceSpan;
|
|
56
|
+
source?: string;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** Create a source location from line, column, offset */
|
|
60
|
+
export declare function loc(line: number, column: number, offset: number): SourceLocation;
|
|
61
|
+
/** Create a source span from start and end locations */
|
|
62
|
+
export declare function span(start: SourceLocation, end: SourceLocation): SourceSpan;
|
|
63
|
+
/** Format multiple errors */
|
|
64
|
+
export declare function formatErrors(errors: GrimoireError[]): string;
|
|
65
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/compiler/grimoire/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,0CAA0C;AAC1C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,iCAAiC;AACjC,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,cAAc,CAAC;IACtB,GAAG,EAAE,cAAc,CAAC;CACrB;AAED,4CAA4C;AAC5C,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAGvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,cAAc,CAAC;QAC1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D"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error types and formatting for Grimoire parser
|
|
3
|
+
*/
|
|
4
|
+
/** Base error class for Grimoire parsing */
|
|
5
|
+
export class GrimoireError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
location;
|
|
8
|
+
span;
|
|
9
|
+
source;
|
|
10
|
+
constructor(code, message, options) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "GrimoireError";
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.location = options?.location;
|
|
15
|
+
this.span = options?.span;
|
|
16
|
+
this.source = options?.source;
|
|
17
|
+
}
|
|
18
|
+
/** Format error with source context */
|
|
19
|
+
format() {
|
|
20
|
+
const lines = [];
|
|
21
|
+
// Error header
|
|
22
|
+
const loc = this.location;
|
|
23
|
+
if (loc) {
|
|
24
|
+
lines.push(`Error [${this.code}] at line ${loc.line}, column ${loc.column}:`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
lines.push(`Error [${this.code}]:`);
|
|
28
|
+
}
|
|
29
|
+
lines.push(` ${this.message}`);
|
|
30
|
+
// Source context
|
|
31
|
+
if (this.source && this.location) {
|
|
32
|
+
const sourceLines = this.source.split("\n");
|
|
33
|
+
const lineIdx = this.location.line - 1;
|
|
34
|
+
if (lineIdx >= 0 && lineIdx < sourceLines.length) {
|
|
35
|
+
lines.push("");
|
|
36
|
+
lines.push(` ${this.location.line} | ${sourceLines[lineIdx]}`);
|
|
37
|
+
// Pointer to error location
|
|
38
|
+
const padding = " ".repeat(String(this.location.line).length + 3);
|
|
39
|
+
const pointer = `${" ".repeat(this.location.column - 1)}^`;
|
|
40
|
+
lines.push(` ${padding}${pointer}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return lines.join("\n");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Tokenization error */
|
|
47
|
+
export class TokenizeError extends GrimoireError {
|
|
48
|
+
constructor(message, options) {
|
|
49
|
+
super("TOKENIZE_ERROR", message, options);
|
|
50
|
+
this.name = "TokenizeError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Parse error */
|
|
54
|
+
export class ParseError extends GrimoireError {
|
|
55
|
+
constructor(message, options) {
|
|
56
|
+
super("PARSE_ERROR", message, options);
|
|
57
|
+
this.name = "ParseError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Indentation error */
|
|
61
|
+
export class IndentationError extends GrimoireError {
|
|
62
|
+
constructor(message, options) {
|
|
63
|
+
super("INDENTATION_ERROR", message, options);
|
|
64
|
+
this.name = "IndentationError";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Transform error (AST to SpellSource) */
|
|
68
|
+
export class TransformError extends GrimoireError {
|
|
69
|
+
constructor(message, options) {
|
|
70
|
+
super("TRANSFORM_ERROR", message, options);
|
|
71
|
+
this.name = "TransformError";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Create a source location from line, column, offset */
|
|
75
|
+
export function loc(line, column, offset) {
|
|
76
|
+
return { line, column, offset };
|
|
77
|
+
}
|
|
78
|
+
/** Create a source span from start and end locations */
|
|
79
|
+
export function span(start, end) {
|
|
80
|
+
return { start, end };
|
|
81
|
+
}
|
|
82
|
+
/** Format multiple errors */
|
|
83
|
+
export function formatErrors(errors) {
|
|
84
|
+
return errors.map((e) => e.format()).join("\n\n");
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/compiler/grimoire/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,4CAA4C;AAC5C,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,CAAS;IACb,QAAQ,CAAkB;IAC1B,IAAI,CAAc;IAClB,MAAM,CAAU;IAEzB,YACE,IAAY,EACZ,OAAe,EACf,OAIC;QAED,KAAK,CAAC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ED,yDAAyD;AACzD,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,MAAc,EAAE,MAAc;IAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,IAAI,CAAC,KAAqB,EAAE,GAAmB;IAC7D,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACxB,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,YAAY,CAAC,MAAuB;IAClD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grimoire syntax compiler
|
|
3
|
+
*
|
|
4
|
+
* This module provides the new Python-like syntax for spell definitions.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./errors.js";
|
|
7
|
+
export * from "./tokenizer.js";
|
|
8
|
+
export * from "./ast.js";
|
|
9
|
+
export { Parser, parse } from "./parser.js";
|
|
10
|
+
export { Transformer, transform } from "./transformer.js";
|
|
11
|
+
import type { CompilationResult, SpellSource } from "../../types/ir.js";
|
|
12
|
+
/**
|
|
13
|
+
* Parse Grimoire source to SpellSource
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseGrimoire(source: string, options?: {
|
|
16
|
+
filePath?: string;
|
|
17
|
+
}): SpellSource;
|
|
18
|
+
/**
|
|
19
|
+
* Compile Grimoire source to IR
|
|
20
|
+
*/
|
|
21
|
+
export declare function compileGrimoire(source: string, options?: {
|
|
22
|
+
filePath?: string;
|
|
23
|
+
}): CompilationResult;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|