@hyperscale0/hsx 2.4.0 → 3.0.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/CHANGELOG.md +2 -400
- package/README.md +3 -92
- package/dist/src/ast.d.ts +99 -310
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast.js +16 -69
- package/dist/src/ast.js.map +1 -1
- package/dist/src/cli.d.ts +6 -19
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +76 -315
- package/dist/src/cli.js.map +1 -1
- package/dist/src/compile.d.ts +23 -73
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1113 -148
- package/dist/src/compile.js.map +1 -1
- package/dist/src/cost.d.ts +8 -77
- package/dist/src/cost.d.ts.map +1 -1
- package/dist/src/cost.js +13 -422
- package/dist/src/cost.js.map +1 -1
- package/dist/src/format.d.ts +8 -7
- package/dist/src/format.d.ts.map +1 -1
- package/dist/src/format.js +9 -175
- package/dist/src/format.js.map +1 -1
- package/dist/src/headers.d.ts +35 -0
- package/dist/src/headers.d.ts.map +1 -0
- package/dist/src/headers.js +108 -0
- package/dist/src/headers.js.map +1 -0
- package/dist/src/index.d.ts +6 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/lex.d.ts +8 -28
- package/dist/src/lex.d.ts.map +1 -1
- package/dist/src/lex.js +88 -146
- package/dist/src/lex.js.map +1 -1
- package/dist/src/parse.d.ts +4 -17
- package/dist/src/parse.d.ts.map +1 -1
- package/dist/src/parse.js +402 -1040
- package/dist/src/parse.js.map +1 -1
- package/dist/src/std-bundle.d.ts.map +1 -1
- package/dist/src/std-bundle.js +12 -20
- package/dist/src/std-bundle.js.map +1 -1
- package/dist/src/std-library.d.ts +1 -1
- package/dist/src/std-library.d.ts.map +1 -1
- package/dist/src/std-library.js +1 -5
- package/dist/src/std-library.js.map +1 -1
- package/dist/src/tunables.d.ts +7 -0
- package/dist/src/tunables.d.ts.map +1 -0
- package/dist/src/tunables.js +26 -0
- package/dist/src/tunables.js.map +1 -0
- package/dist/src/version.d.ts +2 -4
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +2 -4
- package/dist/src/version.js.map +1 -1
- package/docs/README.md +179 -41
- package/docs/headers.md +44 -0
- package/examples/cost-table.json +99 -751
- package/examples/library.hsx +59 -0
- package/package.json +9 -17
- package/src/ast.ts +82 -441
- package/src/cli.ts +77 -362
- package/src/compile.ts +1535 -247
- package/src/cost.ts +28 -671
- package/src/format.ts +12 -256
- package/src/headers.ts +126 -0
- package/src/index.ts +7 -39
- package/src/lex.ts +99 -195
- package/src/parse.ts +403 -1209
- package/src/std-bundle.ts +12 -20
- package/src/std-library.ts +2 -7
- package/src/tunables.ts +31 -0
- package/src/version.ts +2 -5
- package/std/approvals.hsx +17 -0
- package/std/cards.hsx +63 -0
- package/std/collections.hsx +31 -0
- package/std/escrow.hsx +43 -0
- package/std/financing.hsx +372 -0
- package/std/insurance.hsx +59 -0
- package/std/lending.hsx +115 -0
- package/std/marketplace.hsx +24 -0
- package/std/money.hsx +195 -0
- package/std/savings.hsx +44 -0
- package/std/travel.hsx +98 -0
- package/std/wallet.hsx +41 -0
- package/dist/src/diagnostics.d.ts +0 -13
- package/dist/src/diagnostics.d.ts.map +0 -1
- package/dist/src/diagnostics.js +0 -587
- package/dist/src/diagnostics.js.map +0 -1
- package/dist/src/emit.d.ts +0 -51
- package/dist/src/emit.d.ts.map +0 -1
- package/dist/src/emit.js +0 -192
- package/dist/src/emit.js.map +0 -1
- package/dist/src/entry-overrides.d.ts +0 -58
- package/dist/src/entry-overrides.d.ts.map +0 -1
- package/dist/src/entry-overrides.js +0 -284
- package/dist/src/entry-overrides.js.map +0 -1
- package/dist/src/ir.d.ts +0 -73
- package/dist/src/ir.d.ts.map +0 -1
- package/dist/src/ir.js +0 -15
- package/dist/src/ir.js.map +0 -1
- package/dist/src/limits.d.ts +0 -23
- package/dist/src/limits.d.ts.map +0 -1
- package/dist/src/limits.js +0 -23
- package/dist/src/limits.js.map +0 -1
- package/dist/src/lsp/server.d.ts +0 -32
- package/dist/src/lsp/server.d.ts.map +0 -1
- package/dist/src/lsp/server.js +0 -391
- package/dist/src/lsp/server.js.map +0 -1
- package/dist/src/modules.d.ts +0 -38
- package/dist/src/modules.d.ts.map +0 -1
- package/dist/src/modules.js +0 -372
- package/dist/src/modules.js.map +0 -1
- package/dist/src/typecheck.d.ts +0 -8
- package/dist/src/typecheck.d.ts.map +0 -1
- package/dist/src/typecheck.js +0 -4131
- package/dist/src/typecheck.js.map +0 -1
- package/docs/guide/01-first-program.md +0 -24
- package/docs/guide/02-money.md +0 -25
- package/docs/guide/03-instruments.md +0 -93
- package/docs/guide/04-lifecycles.md +0 -40
- package/docs/guide/05-fees-and-splits.md +0 -45
- package/docs/guide/06-schedules.md +0 -26
- package/docs/guide/07-composition.md +0 -52
- package/docs/guide/08-writing-a-module.md +0 -85
- package/docs/guide/09-cost.md +0 -24
- package/docs/guide/10-diagnostics.md +0 -27
- package/docs/llms-full.txt +0 -3684
- package/docs/llms.txt +0 -44
- package/docs/piece-plans.md +0 -120
- package/docs/playground.md +0 -55
- package/docs/reference/cli.md +0 -36
- package/docs/reference/diagnostics.md +0 -901
- package/docs/reference/grammar.md +0 -38
- package/docs/reference/std/advance.md +0 -112
- package/docs/reference/std/cancellable_booking.md +0 -159
- package/docs/reference/std/captured_payment.md +0 -115
- package/docs/reference/std/conditional_disbursement.md +0 -101
- package/docs/reference/std/credit_facility.md +0 -108
- package/docs/reference/std/held_payment.md +0 -173
- package/docs/reference/std/instant_transfer.md +0 -97
- package/docs/reference/std/metered.md +0 -89
- package/docs/reference/std/pooled_split.md +0 -95
- package/docs/reference/std/premium_forward.md +0 -119
- package/docs/reference/std/reconciled_payout.md +0 -103
- package/docs/reference/std/rotating_pool.md +0 -130
- package/docs/reference/std/scheduled.md +0 -136
- package/docs/reference/std/security_deposit.md +0 -138
- package/docs/reference/std/settlement_batch.md +0 -123
- package/docs/reference/std/swap.md +0 -133
- package/docs/reference/std/threshold_pool.md +0 -138
- package/docs/reference/std/weighted_distribution.md +0 -135
- package/docs/reference/types.md +0 -61
- package/docs/reference/udl-output.md +0 -13
- package/examples/01-first-program/README.md +0 -45
- package/examples/01-first-program/tip-jar.hsx +0 -17
- package/examples/02-imports-and-modules/README.md +0 -96
- package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
- package/examples/03-diagnostics/README.md +0 -68
- package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
- package/examples/03-diagnostics/corner-shop.hsx +0 -19
- package/examples/04-complete-product/README.md +0 -84
- package/examples/04-complete-product/study-hall.hsx +0 -67
- package/examples/05-authored-instrument/README.md +0 -5
- package/examples/05-authored-instrument/payment.hsx +0 -37
- package/examples/05-watch-club/README.md +0 -6
- package/examples/05-watch-club/watch-club.hsx +0 -123
- package/examples/README.md +0 -48
- package/examples/advance/README.md +0 -3
- package/examples/advance/advance.hsx +0 -13
- package/examples/advance/advance.udl +0 -367
- package/examples/cancellable_booking/README.md +0 -3
- package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
- package/examples/cancellable_booking/cancellable_booking.udl +0 -413
- package/examples/captured_payment/README.md +0 -3
- package/examples/captured_payment/captured_payment.hsx +0 -17
- package/examples/captured_payment/captured_payment.udl +0 -686
- package/examples/conditional_disbursement/README.md +0 -3
- package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
- package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
- package/examples/credit_facility/README.md +0 -3
- package/examples/credit_facility/credit_facility.hsx +0 -24
- package/examples/credit_facility/credit_facility.udl +0 -1396
- package/examples/held_payment/README.md +0 -3
- package/examples/held_payment/held_payment.hsx +0 -13
- package/examples/held_payment/held_payment.udl +0 -569
- package/examples/instant_transfer/README.md +0 -3
- package/examples/instant_transfer/instant_transfer.hsx +0 -16
- package/examples/instant_transfer/instant_transfer.udl +0 -376
- package/examples/metered/README.md +0 -3
- package/examples/metered/metered.hsx +0 -13
- package/examples/metered/metered.udl +0 -253
- package/examples/pooled_split/README.md +0 -3
- package/examples/pooled_split/pooled_split.hsx +0 -15
- package/examples/pooled_split/pooled_split.udl +0 -432
- package/examples/premium_forward/README.md +0 -3
- package/examples/premium_forward/premium_forward.hsx +0 -19
- package/examples/premium_forward/premium_forward.udl +0 -604
- package/examples/reconciled_payout/README.md +0 -3
- package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
- package/examples/reconciled_payout/reconciled_payout.udl +0 -312
- package/examples/rotating_pool/README.md +0 -3
- package/examples/rotating_pool/rotating_pool.hsx +0 -18
- package/examples/rotating_pool/rotating_pool.udl +0 -4370
- package/examples/scheduled/README.md +0 -3
- package/examples/scheduled/scheduled.hsx +0 -12
- package/examples/scheduled/scheduled.udl +0 -355
- package/examples/security_deposit/README.md +0 -3
- package/examples/security_deposit/security_deposit.hsx +0 -21
- package/examples/security_deposit/security_deposit.udl +0 -320
- package/examples/settlement_batch/README.md +0 -3
- package/examples/settlement_batch/settlement_batch.hsx +0 -19
- package/examples/settlement_batch/settlement_batch.udl +0 -757
- package/examples/swap/README.md +0 -3
- package/examples/swap/swap.hsx +0 -19
- package/examples/swap/swap.udl +0 -892
- package/examples/threshold_pool/README.md +0 -3
- package/examples/threshold_pool/threshold_pool.hsx +0 -16
- package/examples/threshold_pool/threshold_pool.udl +0 -680
- package/examples/weighted_distribution/README.md +0 -3
- package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
- package/examples/weighted_distribution/weighted_distribution.udl +0 -348
- package/skills/hsx/SKILL.md +0 -449
- package/src/diagnostics.ts +0 -620
- package/src/emit.ts +0 -282
- package/src/entry-overrides.ts +0 -428
- package/src/ir.ts +0 -113
- package/src/limits.ts +0 -22
- package/src/lsp/server.ts +0 -460
- package/src/modules.ts +0 -452
- package/src/typecheck.ts +0 -5381
- package/std/SEMANTICS.md +0 -44
- package/std/money_flows/advance.hsx +0 -235
- package/std/money_flows/cancellable_booking.hsx +0 -402
- package/std/money_flows/captured_payment.hsx +0 -220
- package/std/money_flows/conditional_disbursement.hsx +0 -226
- package/std/money_flows/credit_facility.hsx +0 -214
- package/std/money_flows/held_payment.hsx +0 -812
- package/std/money_flows/index.hsx +0 -4
- package/std/money_flows/instant_transfer.hsx +0 -231
- package/std/money_flows/metered.hsx +0 -104
- package/std/money_flows/pooled_split.hsx +0 -109
- package/std/money_flows/premium_forward.hsx +0 -307
- package/std/money_flows/reconciled_payout.hsx +0 -119
- package/std/money_flows/rotating_pool.hsx +0 -305
- package/std/money_flows/scheduled.hsx +0 -599
- package/std/money_flows/security_deposit.hsx +0 -248
- package/std/money_flows/settlement_batch.hsx +0 -173
- package/std/money_flows/swap.hsx +0 -1192
- package/std/money_flows/threshold_pool.hsx +0 -307
- package/std/money_flows/weighted_distribution.hsx +0 -237
package/dist/src/ast.d.ts
CHANGED
|
@@ -1,317 +1,106 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The HSX abstract syntax tree.
|
|
3
|
-
*
|
|
4
|
-
* Every node carries a byte-offset span into the original source. Spans are
|
|
5
|
-
* the compiler's source-mapping currency: diagnostics at every later stage
|
|
6
|
-
* (typecheck, lowering, verdicts) point at source coordinates, never at
|
|
7
|
-
* lowered IR paths. Offsets convert to line/column via `lineColAt`.
|
|
8
|
-
*/
|
|
9
1
|
export interface Span {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** Exclusive end byte offset into the source text. */
|
|
13
|
-
readonly end: number;
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
14
4
|
}
|
|
15
|
-
export interface
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
readonly span: Span;
|
|
58
|
-
readonly value: string;
|
|
59
|
-
}
|
|
60
|
-
export interface NumberExpr {
|
|
61
|
-
readonly kind: "number";
|
|
62
|
-
/** The literal exactly as written, e.g. "99.5". Interpretation is typed later. */
|
|
63
|
-
readonly raw: string;
|
|
64
|
-
readonly span: Span;
|
|
65
|
-
}
|
|
66
|
-
export interface BooleanExpr {
|
|
67
|
-
readonly kind: "boolean";
|
|
68
|
-
readonly span: Span;
|
|
69
|
-
readonly value: boolean;
|
|
70
|
-
}
|
|
71
|
-
/** A currency-indexed literal. The checker converts it to integer minor units. */
|
|
72
|
-
export interface MoneyExpr {
|
|
73
|
-
readonly currency: IdentExpr;
|
|
74
|
-
readonly kind: "money";
|
|
75
|
-
readonly raw: string;
|
|
76
|
-
readonly span: Span;
|
|
77
|
-
}
|
|
78
|
-
/** A dotted name used for modules, UDL operations, and field paths. */
|
|
79
|
-
export interface PathExpr {
|
|
80
|
-
readonly kind: "path";
|
|
81
|
-
readonly parts: readonly IdentExpr[];
|
|
82
|
-
readonly span: Span;
|
|
83
|
-
}
|
|
84
|
-
/** A nominal type application such as `money<SAR>` or `ref<invoice>`. */
|
|
85
|
-
export interface TypeApplyExpr {
|
|
86
|
-
readonly args: readonly Expr[];
|
|
87
|
-
readonly callee: IdentExpr;
|
|
88
|
-
readonly kind: "type_apply";
|
|
89
|
-
readonly span: Span;
|
|
90
|
-
}
|
|
91
|
-
/** A general instrument or constant application, with optional type arguments. */
|
|
92
|
-
export interface ApplyExpr {
|
|
93
|
-
readonly args: readonly Expr[];
|
|
94
|
-
readonly callee: PathExpr;
|
|
95
|
-
readonly kind: "apply";
|
|
96
|
-
readonly span: Span;
|
|
97
|
-
readonly typeArgs: readonly Expr[];
|
|
98
|
-
}
|
|
99
|
-
export interface PercentExpr {
|
|
100
|
-
/** Exact basis points: 99.5% is 9950. Percents never round. */
|
|
101
|
-
readonly bps: number;
|
|
102
|
-
readonly kind: "percent";
|
|
103
|
-
readonly raw: string;
|
|
104
|
-
readonly span: Span;
|
|
105
|
-
}
|
|
106
|
-
/** A type or constructor application: `money(SAR)`, `id(vehicle)`. */
|
|
107
|
-
export interface CallExpr {
|
|
108
|
-
readonly args: readonly Expr[];
|
|
109
|
-
readonly callee: IdentExpr;
|
|
110
|
-
readonly kind: "call";
|
|
111
|
-
readonly span: Span;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* An exit amount chosen by a decision port and bounded by stored money:
|
|
115
|
-
* `decided { field: damageAmount, bound: depositAmount, remainder: return }`.
|
|
116
|
-
*/
|
|
117
|
-
export interface DecidedAmountExpr {
|
|
118
|
-
readonly body: BlockExpr;
|
|
119
|
-
readonly kind: "decided_amount";
|
|
120
|
-
readonly span: Span;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* A reference to a decision port, optionally bounded (`port dispute within
|
|
124
|
-
* P14D`) or carrying the date that decides when the port has not
|
|
125
|
-
* (`port approve_release | at(releaseDueAt)`).
|
|
126
|
-
*/
|
|
127
|
-
export interface PortRefExpr {
|
|
128
|
-
/** `| at(<field>)`, the stored date field that resolves an undecided hold. */
|
|
129
|
-
readonly deadline?: IdentExpr;
|
|
130
|
-
readonly kind: "port_ref";
|
|
131
|
-
readonly name: IdentExpr;
|
|
132
|
-
readonly span: Span;
|
|
133
|
-
readonly within?: IdentExpr;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* `retention.release`, one settlement naming another settlement's declared
|
|
137
|
-
* referenceable exit. The checker resolves it wholly before lowering.
|
|
138
|
-
*/
|
|
139
|
-
export interface SettlementRefExpr {
|
|
140
|
-
readonly kind: "settlement_ref";
|
|
141
|
-
/** The exit named on the owner, e.g. `release`. */
|
|
142
|
-
readonly member: IdentExpr;
|
|
143
|
-
/** The settlement being referenced. */
|
|
144
|
-
readonly owner: IdentExpr;
|
|
145
|
-
readonly span: Span;
|
|
146
|
-
}
|
|
147
|
-
export interface ListExpr {
|
|
148
|
-
readonly items: readonly Expr[];
|
|
149
|
-
readonly kind: "list";
|
|
150
|
-
readonly span: Span;
|
|
151
|
-
}
|
|
152
|
-
/** A brace block of entries: `{ buyer: 1%, seller: 2% }`. */
|
|
153
|
-
export interface BlockExpr {
|
|
154
|
-
readonly entries: readonly Entry[];
|
|
155
|
-
readonly kind: "block";
|
|
156
|
-
readonly span: Span;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* A named typed binding inside an expression position:
|
|
160
|
-
* `amount: price: money(SAR)` binds the field name `price` to type
|
|
161
|
-
* `money(SAR)`: the entry key is `amount`, the value is this binding.
|
|
162
|
-
*/
|
|
163
|
-
export interface BindingExpr {
|
|
164
|
-
readonly kind: "binding";
|
|
165
|
-
readonly name: IdentExpr;
|
|
166
|
-
readonly span: Span;
|
|
167
|
-
readonly type: Expr;
|
|
168
|
-
}
|
|
169
|
-
export type Expr = ApplyExpr | BindingExpr | BlockExpr | BooleanExpr | CallExpr | DecidedAmountExpr | IdentExpr | ListExpr | MoneyExpr | NumberExpr | PathExpr | PercentExpr | PortRefExpr | SettlementRefExpr | StringExpr | TypeApplyExpr;
|
|
170
|
-
/**
|
|
171
|
-
* One keyed entry inside a declaration body. Three surface shapes normalize
|
|
172
|
-
* here: `payer: buyer` (key + value), `fees { ... }` (key + block value),
|
|
173
|
-
* and `on_cancel(funded) { ... }` (key + qualifiers + block value).
|
|
174
|
-
*/
|
|
5
|
+
export interface Diagnostic {
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
fix: string;
|
|
9
|
+
span: Span;
|
|
10
|
+
}
|
|
11
|
+
export type Expr = {
|
|
12
|
+
kind: "name" | "text" | "number" | "money" | "percent" | "duration" | "date";
|
|
13
|
+
value: string;
|
|
14
|
+
span: Span;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "list";
|
|
17
|
+
items: Expr[];
|
|
18
|
+
span: Span;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "block";
|
|
21
|
+
entries: Entry[];
|
|
22
|
+
span: Span;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "call";
|
|
25
|
+
name: string;
|
|
26
|
+
args: Expr[];
|
|
27
|
+
span: Span;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "type";
|
|
30
|
+
name: string;
|
|
31
|
+
target?: string;
|
|
32
|
+
owner?: string;
|
|
33
|
+
optional: boolean;
|
|
34
|
+
many?: boolean;
|
|
35
|
+
span: Span;
|
|
36
|
+
} | {
|
|
37
|
+
kind: "default";
|
|
38
|
+
type: Expr;
|
|
39
|
+
value: Expr;
|
|
40
|
+
span: Span;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "capped";
|
|
43
|
+
rate: Expr;
|
|
44
|
+
cap: Expr;
|
|
45
|
+
span: Span;
|
|
46
|
+
};
|
|
175
47
|
export interface Entry {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
readonly iteration?: {
|
|
180
|
-
readonly binding: IdentExpr;
|
|
181
|
-
readonly bound: Expr;
|
|
182
|
-
};
|
|
183
|
-
readonly key: IdentExpr;
|
|
184
|
-
readonly qualifiers: readonly IdentExpr[];
|
|
185
|
-
readonly span: Span;
|
|
186
|
-
readonly value: Expr;
|
|
48
|
+
key: string;
|
|
49
|
+
value: Expr;
|
|
50
|
+
span: Span;
|
|
187
51
|
}
|
|
188
|
-
/** `program used_car_escrow "Used-car escrow"` names the company program. */
|
|
189
|
-
export interface ProgramDecl {
|
|
190
|
-
readonly kind: "program";
|
|
191
|
-
readonly name: IdentExpr;
|
|
192
|
-
readonly span: Span;
|
|
193
|
-
readonly title?: StringExpr;
|
|
194
|
-
}
|
|
195
|
-
/** `use held_settlement` selects one published catalog instrument. */
|
|
196
|
-
export interface UseDecl {
|
|
197
|
-
readonly instrument: IdentExpr;
|
|
198
|
-
readonly kind: "use";
|
|
199
|
-
readonly span: Span;
|
|
200
|
-
}
|
|
201
|
-
/** `expose held_settlement.release as releaseFunds` names a public action. */
|
|
202
|
-
export interface ExposeDecl {
|
|
203
|
-
readonly action: IdentExpr;
|
|
204
|
-
readonly instrument: IdentExpr;
|
|
205
|
-
readonly kind: "expose";
|
|
206
|
-
readonly publicName: IdentExpr;
|
|
207
|
-
readonly span: Span;
|
|
208
|
-
}
|
|
209
|
-
/** `import { held_payment } from "std/money_flows"`. */
|
|
210
|
-
export interface ImportDecl {
|
|
211
|
-
readonly from: StringExpr;
|
|
212
|
-
readonly kind: "import";
|
|
213
|
-
readonly names: readonly IdentExpr[];
|
|
214
|
-
readonly span: Span;
|
|
215
|
-
}
|
|
216
|
-
/** `party buyer: person` with an optional attribute block. */
|
|
217
|
-
export interface PartyDecl {
|
|
218
|
-
readonly attrs?: BlockExpr;
|
|
219
|
-
readonly kind: "party";
|
|
220
|
-
readonly name: IdentExpr;
|
|
221
|
-
readonly partyKind: IdentExpr;
|
|
222
|
-
readonly span: Span;
|
|
223
|
-
}
|
|
224
|
-
/** `asset vehicle: good { title_transfer: off_platform }`. */
|
|
225
|
-
export interface AssetDecl {
|
|
226
|
-
readonly assetKind: IdentExpr;
|
|
227
|
-
readonly attrs?: BlockExpr;
|
|
228
|
-
readonly kind: "asset";
|
|
229
|
-
readonly name: IdentExpr;
|
|
230
|
-
readonly span: Span;
|
|
231
|
-
}
|
|
232
|
-
/** A full UDL subject-kind declaration. `asset` remains shorthand for this form. */
|
|
233
|
-
export interface SubjectDecl {
|
|
234
|
-
readonly body: BlockExpr;
|
|
235
|
-
readonly kind: "subject";
|
|
236
|
-
readonly name: IdentExpr;
|
|
237
|
-
readonly span: Span;
|
|
238
|
-
}
|
|
239
|
-
/** `port confirm_handover { allowed: [buyer], ... }`. */
|
|
240
|
-
export interface PortDecl {
|
|
241
|
-
readonly body: BlockExpr;
|
|
242
|
-
readonly kind: "port";
|
|
243
|
-
readonly name: IdentExpr;
|
|
244
|
-
readonly span: Span;
|
|
245
|
-
}
|
|
246
|
-
/** `module std.money_flows` gives a file its importable module name. */
|
|
247
|
-
export interface ModuleDecl {
|
|
248
|
-
readonly kind: "module";
|
|
249
|
-
readonly name: PathExpr;
|
|
250
|
-
readonly span: Span;
|
|
251
|
-
}
|
|
252
|
-
export interface TypeParameter {
|
|
253
|
-
readonly name: IdentExpr;
|
|
254
|
-
readonly span: Span;
|
|
255
|
-
}
|
|
256
|
-
export interface Parameter {
|
|
257
|
-
readonly name: IdentExpr;
|
|
258
|
-
readonly span: Span;
|
|
259
|
-
readonly type: Expr;
|
|
260
|
-
}
|
|
261
|
-
/** The single general instrument definition form. */
|
|
262
52
|
export interface InstrumentDecl {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
export type ApplicationScopeDecl = ConstDecl | InstrumentDecl | PartyDecl | PortDecl | TypeDecl;
|
|
302
|
-
export type Decl = AssetDecl | ConstDecl | ExposeDecl | ImportDecl | InstrumentApplyDecl | InstrumentDecl | ModuleDecl | PartyDecl | PortDecl | ProgramDecl | SubjectDecl | TypeDecl | UseDecl;
|
|
53
|
+
kind: "instrument";
|
|
54
|
+
name: string;
|
|
55
|
+
parameters: Entry[];
|
|
56
|
+
body: Extract<Expr, {
|
|
57
|
+
kind: "block";
|
|
58
|
+
}>;
|
|
59
|
+
span: Span;
|
|
60
|
+
}
|
|
61
|
+
export interface ObjectDecl {
|
|
62
|
+
kind: "object";
|
|
63
|
+
name: string;
|
|
64
|
+
object: string;
|
|
65
|
+
body: Extract<Expr, {
|
|
66
|
+
kind: "block";
|
|
67
|
+
}>;
|
|
68
|
+
span: Span;
|
|
69
|
+
}
|
|
70
|
+
export type Decl = InstrumentDecl | ObjectDecl | {
|
|
71
|
+
kind: "party";
|
|
72
|
+
name: string;
|
|
73
|
+
partyKind: string;
|
|
74
|
+
role?: string;
|
|
75
|
+
span: Span;
|
|
76
|
+
} | {
|
|
77
|
+
kind: "use";
|
|
78
|
+
name: string;
|
|
79
|
+
span: Span;
|
|
80
|
+
} | {
|
|
81
|
+
kind: "expose";
|
|
82
|
+
target: string;
|
|
83
|
+
name: string;
|
|
84
|
+
span: Span;
|
|
85
|
+
} | {
|
|
86
|
+
kind: "hide";
|
|
87
|
+
target: string;
|
|
88
|
+
span: Span;
|
|
89
|
+
};
|
|
303
90
|
export interface Program {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
export
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
91
|
+
name: string;
|
|
92
|
+
title: string;
|
|
93
|
+
currency: string;
|
|
94
|
+
header: boolean;
|
|
95
|
+
decls: Decl[];
|
|
96
|
+
span: Span;
|
|
97
|
+
}
|
|
98
|
+
export declare const lineColAt: (source: string, offset: number) => {
|
|
99
|
+
line: number;
|
|
100
|
+
column: number;
|
|
101
|
+
};
|
|
102
|
+
export declare function byteOffsetToCodeUnit(source: string, offset: number): number;
|
|
103
|
+
export type BlockExpr = Extract<Expr, {
|
|
104
|
+
kind: "block";
|
|
105
|
+
}>;
|
|
317
106
|
//# sourceMappingURL=ast.d.ts.map
|
package/dist/src/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"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"}
|
package/dist/src/ast.js
CHANGED
|
@@ -1,72 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
line += 1;
|
|
17
|
-
lineStart = index + 1;
|
|
18
|
-
}
|
|
1
|
+
export const lineColAt = (source, offset) => {
|
|
2
|
+
const before = source.slice(0, offset);
|
|
3
|
+
return {
|
|
4
|
+
line: before.split("\n").length,
|
|
5
|
+
column: offset - before.lastIndexOf("\n"),
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export function byteOffsetToCodeUnit(source, offset) {
|
|
9
|
+
let bytes = 0;
|
|
10
|
+
let units = 0;
|
|
11
|
+
for (const c of source) {
|
|
12
|
+
bytes += new TextEncoder().encode(c).length;
|
|
13
|
+
if (bytes > offset)
|
|
14
|
+
break;
|
|
15
|
+
units += c.length;
|
|
19
16
|
}
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
const utf8Encoder = new TextEncoder();
|
|
23
|
-
/**
|
|
24
|
-
* Convert a UTF-8 byte offset to a UTF-16 code-unit offset over a string.
|
|
25
|
-
* Walks Unicode code points, counting UTF-8 bytes and UTF-16 code units.
|
|
26
|
-
* Clamps to [0, source.length].
|
|
27
|
-
*/
|
|
28
|
-
export function byteOffsetToCodeUnit(source, byteOffset) {
|
|
29
|
-
if (byteOffset <= 0)
|
|
30
|
-
return 0;
|
|
31
|
-
let currentByte = 0;
|
|
32
|
-
let codeUnit = 0;
|
|
33
|
-
for (const char of source) {
|
|
34
|
-
const charBytes = utf8Encoder.encode(char).length;
|
|
35
|
-
if (currentByte + charBytes > byteOffset) {
|
|
36
|
-
return codeUnit;
|
|
37
|
-
}
|
|
38
|
-
currentByte += charBytes;
|
|
39
|
-
codeUnit += char.length;
|
|
40
|
-
if (currentByte === byteOffset) {
|
|
41
|
-
return codeUnit;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return source.length;
|
|
45
|
-
}
|
|
46
|
-
/** Scan a source once for the offset every line starts at. */
|
|
47
|
-
export function lineIndex(source) {
|
|
48
|
-
const starts = [0];
|
|
49
|
-
for (let index = 0; index < source.length; index += 1) {
|
|
50
|
-
if (source.charCodeAt(index) === 10)
|
|
51
|
-
starts.push(index + 1);
|
|
52
|
-
}
|
|
53
|
-
return { length: source.length, starts };
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Resolve one offset against a prebuilt index. Returns exactly what
|
|
57
|
-
* `lineColAt` returns for the same source and offset.
|
|
58
|
-
*/
|
|
59
|
-
export function lineColIn(index, offset) {
|
|
60
|
-
const clamped = Math.max(0, Math.min(offset, index.length));
|
|
61
|
-
let low = 0;
|
|
62
|
-
let high = index.starts.length - 1;
|
|
63
|
-
while (low < high) {
|
|
64
|
-
const middle = Math.floor((low + high + 1) / 2);
|
|
65
|
-
if (index.starts[middle] <= clamped)
|
|
66
|
-
low = middle;
|
|
67
|
-
else
|
|
68
|
-
high = middle - 1;
|
|
69
|
-
}
|
|
70
|
-
return { column: clamped - index.starts[low] + 1, line: low + 1 };
|
|
17
|
+
return units;
|
|
71
18
|
}
|
|
72
19
|
//# sourceMappingURL=ast.js.map
|
package/dist/src/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/ast.ts"],"names":[],"mappings":"AA6EA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM;QAC/B,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;KAC1C,CAAC;AACJ,CAAC,CAAC;AACF,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,MAAc;IACjE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,KAAK,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC5C,IAAI,KAAK,GAAG,MAAM;YAAE,MAAM;QAC1B,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `hsx` command line over the one compiler entry point and catalog.
|
|
3
|
-
*
|
|
4
|
-
* `check` prints diagnostics and says nothing else; `build` writes the
|
|
5
|
-
* compiled artifacts as JSON. Neither reads the environment, neither touches
|
|
6
|
-
* a network, and neither writes outside the path the caller names.
|
|
7
|
-
*
|
|
8
|
-
* Everything here is a pure function of `argv` plus the injected `Io`, so the
|
|
9
|
-
* spec drives the real code paths with an in-memory filesystem instead of
|
|
10
|
-
* asserting on a subprocess's scrollback.
|
|
11
|
-
*/
|
|
12
|
-
/** Filesystem and streams, injected so the CLI stays testable. */
|
|
13
1
|
export interface Io {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
out(line: string): void;
|
|
3
|
+
err(line: string): void;
|
|
4
|
+
readFile(path: string): Promise<string>;
|
|
5
|
+
writeFile(path: string, text: string): Promise<void>;
|
|
6
|
+
stdin?: NodeJS.ReadableStream;
|
|
7
|
+
stdout?: NodeJS.WritableStream;
|
|
20
8
|
}
|
|
21
|
-
export declare const USAGE_TEXT = "hsx 2.4.0, the HSX compiler\n\nUsage:\n hsx check <file.hsx> [--catalog <catalog.udl>] [--strict]\n hsx build <file.hsx> [--catalog <catalog.udl>] [--out <file.json>] [--strict]\n hsx cost <file.hsx> [--catalog <catalog.udl>] [--json] [--out <file.json>] [--strict]\n hsx explain <HSX####>\n hsx format <file.hsx>\n hsx lsp\n hsx --version\n hsx --help\n\nCommands:\n check Compile and report diagnostics. Prints nothing when the program is clean.\n build Compile and write canonical UDL as JSON.\n cost Compile and print the version-pinned cost manifest as a table or JSON.\n explain Print one diagnostic title, fix, and source example.\n format Print the source in the one canonical HSX style.\n lsp Run the language server over stdin and stdout.\n\nOptions:\n --catalog <file> Read the published instrument catalogue as canonical UDL JSON.\n --json Print the cost manifest as JSON instead of a table.\n --out <file> Write build or cost JSON to this path instead of stdout.\n --strict Treat warning-severity diagnostics as failures.\n\nExit codes:\n 0 the program compiled (verdict valid, or warning without --strict)\n 1 the program was refused (verdict invalid, or warning with --strict)\n 2 the command line or the input file could not be used";
|
|
22
9
|
export declare function runCli(argv: readonly string[], io: Io): Promise<number>;
|
|
23
10
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/src/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,EAAE;IACjB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC;AACD,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAiE7E"}
|