rei-lang 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +230 -191
- package/PEACE_USE_CLAUSE.md +95 -0
- package/README.md +257 -186
- package/bin/rei.js +259 -144
- package/dist/index.d.mts +257 -0
- package/dist/index.d.ts +181 -93
- package/dist/index.js +5710 -239
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8741 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +73 -62
- package/spec/REI_BNF_v0.2.md +398 -0
- package/spec/REI_BNF_v0.3.md +358 -0
- package/spec/REI_SPEC_v0.1.md +587 -0
- package/theory/LICENSE-THEORY.md +57 -0
- package/theory/README.md +85 -0
- package/theory/category-c-design.md +502 -0
- package/theory/core-theories-11-14.md +799 -0
- package/theory/core-theories-15-21.md +675 -0
- package/theory/core-theories-8-10.md +582 -0
- package/theory/d-fumt-overview.md +99 -0
- package/theory/genesis-axiom-system.md +124 -0
- package/theory/gft-theory.md +160 -0
- package/theory/index.ts +9 -0
- package/theory/notation-equivalence.md +134 -0
- package/theory/semantic-compressor.ts +903 -0
- package/theory/stdlib-tier1-design.md +477 -0
- package/theory/theories-11-14.ts +466 -0
- package/theory/theories-15-21.ts +762 -0
- package/theory/theories-22-28.ts +794 -0
- package/theory/theories-29-35.ts +607 -0
- package/theory/theories-36-42.ts +937 -0
- package/theory/theories-43-49.ts +1298 -0
- package/theory/theories-50-56.ts +1449 -0
- package/theory/theories-57-66.ts +1724 -0
- package/theory/theories-67.ts +1696 -0
- package/theory/theories-8-10.ts +284 -0
- package/dist/index.cjs +0 -3282
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -169
package/dist/index.d.ts
CHANGED
|
@@ -1,72 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/** 結合モード */
|
|
2
|
+
type BindingMode = 'mirror' | 'inverse' | 'resonance' | 'entangle' | 'causal';
|
|
3
|
+
/** 伝播規則 */
|
|
4
|
+
interface PropagationRule {
|
|
5
|
+
type: 'immediate' | 'delayed' | 'attenuated';
|
|
6
|
+
delay: number;
|
|
7
|
+
attenuation: number;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(source: string);
|
|
16
|
-
tokenize(): Token[];
|
|
17
|
-
private skipWhitespaceAndComments;
|
|
18
|
-
private readString;
|
|
19
|
-
private isExtStart;
|
|
20
|
-
private readExtLit;
|
|
21
|
-
private readNumber;
|
|
22
|
-
private readUnicodeToken;
|
|
23
|
-
private readMultiCharOp;
|
|
24
|
-
private readSingleCharOp;
|
|
25
|
-
private readIdentOrKeyword;
|
|
26
|
-
private advance;
|
|
27
|
-
private peek;
|
|
28
|
-
private emit;
|
|
29
|
-
private isDigit;
|
|
30
|
-
private isIdentStart;
|
|
31
|
-
private isIdentPart;
|
|
32
|
-
private shouldNegateBePrefix;
|
|
9
|
+
/** 結合イベント — 記憶属性との統合 */
|
|
10
|
+
interface BindingEvent {
|
|
11
|
+
step: number;
|
|
12
|
+
type: 'created' | 'propagated' | 'broken' | 'strengthened' | 'weakened';
|
|
13
|
+
sourceValue: any;
|
|
14
|
+
targetValue: any;
|
|
15
|
+
delta: number;
|
|
33
16
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
private
|
|
65
|
-
private
|
|
66
|
-
private
|
|
67
|
-
private
|
|
68
|
-
|
|
69
|
-
|
|
17
|
+
/** 結合(Binding)— 2つの値の非局所的な関係 */
|
|
18
|
+
interface ReiBinding {
|
|
19
|
+
id: string;
|
|
20
|
+
sourceRef: string;
|
|
21
|
+
targetRef: string;
|
|
22
|
+
mode: BindingMode;
|
|
23
|
+
strength: number;
|
|
24
|
+
propagation: PropagationRule;
|
|
25
|
+
bidirectional: boolean;
|
|
26
|
+
active: boolean;
|
|
27
|
+
history: BindingEvent[];
|
|
28
|
+
createdAt: number;
|
|
29
|
+
}
|
|
30
|
+
/** 結合の要約(σ.relation に含める用) */
|
|
31
|
+
interface BindingSummary {
|
|
32
|
+
id: string;
|
|
33
|
+
target: string;
|
|
34
|
+
mode: BindingMode;
|
|
35
|
+
strength: number;
|
|
36
|
+
active: boolean;
|
|
37
|
+
propagationCount: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 結合レジストリ — 全結合を管理し、伝播を実行する
|
|
41
|
+
*
|
|
42
|
+
* Evaluator内に1つのインスタンスを保持する。
|
|
43
|
+
* 変数への代入(Environment.set)時に propagate() が呼ばれ、
|
|
44
|
+
* 結合先に変更が自動的に伝播する。
|
|
45
|
+
*/
|
|
46
|
+
declare class BindingRegistry {
|
|
47
|
+
private bindings;
|
|
48
|
+
private refIndex;
|
|
49
|
+
private globalStep;
|
|
50
|
+
private _propagating;
|
|
51
|
+
/**
|
|
52
|
+
* 2つの変数参照を結合する
|
|
53
|
+
*
|
|
54
|
+
* @param sourceRef 結合元の変数名
|
|
55
|
+
* @param targetRef 結合先の変数名
|
|
56
|
+
* @param mode 結合モード
|
|
57
|
+
* @param strength 結合の強さ (0.0~1.0)
|
|
58
|
+
* @param bidirectional 双方向結合にするか
|
|
59
|
+
* @param propagation 伝播規則
|
|
60
|
+
* @returns 作成された結合
|
|
61
|
+
*/
|
|
62
|
+
bind(sourceRef: string, targetRef: string, mode?: BindingMode, strength?: number, bidirectional?: boolean, propagation?: PropagationRule): ReiBinding;
|
|
63
|
+
/**
|
|
64
|
+
* 変数の値が変化したとき、結合先に変更を伝播する
|
|
65
|
+
*
|
|
66
|
+
* @param changedRef 変更された変数名
|
|
67
|
+
* @param newValue 新しい値
|
|
68
|
+
* @param getValue 変数の値を取得する関数
|
|
69
|
+
* @param setValue 変数の値を設定する関数
|
|
70
|
+
* @returns 伝播された結合の数
|
|
71
|
+
*/
|
|
72
|
+
propagate(changedRef: string, newValue: any, getValue: (ref: string) => any, setValue: (ref: string, value: any) => void): number;
|
|
73
|
+
private computePropagatedValue;
|
|
74
|
+
/**
|
|
75
|
+
* 2つの変数間の結合を解除する
|
|
76
|
+
*/
|
|
77
|
+
unbind(sourceRef: string, targetRef: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* 変数に関連する全結合を解除する
|
|
80
|
+
*/
|
|
81
|
+
unbindAll(ref: string): number;
|
|
82
|
+
/**
|
|
83
|
+
* 変数に関連する全結合の要約を返す
|
|
84
|
+
*/
|
|
85
|
+
getBindingsFor(ref: string): BindingSummary[];
|
|
86
|
+
/**
|
|
87
|
+
* 全結合を返す
|
|
88
|
+
*/
|
|
89
|
+
getAllBindings(): ReiBinding[];
|
|
90
|
+
/**
|
|
91
|
+
* アクティブな結合の数を返す
|
|
92
|
+
*/
|
|
93
|
+
get activeCount(): number;
|
|
94
|
+
/**
|
|
95
|
+
* レジストリをリセットする
|
|
96
|
+
*/
|
|
97
|
+
reset(): void;
|
|
98
|
+
/**
|
|
99
|
+
* 変数のσ.relation情報を構築する
|
|
100
|
+
*/
|
|
101
|
+
buildRelationSigma(ref: string): any[];
|
|
102
|
+
private findBinding;
|
|
103
|
+
private addToIndex;
|
|
70
104
|
}
|
|
71
105
|
|
|
72
106
|
interface SigmaMetadata {
|
|
@@ -93,6 +127,7 @@ declare class Environment {
|
|
|
93
127
|
}
|
|
94
128
|
declare class Evaluator {
|
|
95
129
|
env: Environment;
|
|
130
|
+
bindingRegistry: BindingRegistry;
|
|
96
131
|
constructor(parent?: Environment);
|
|
97
132
|
private registerBuiltins;
|
|
98
133
|
eval(ast: any): any;
|
|
@@ -131,39 +166,92 @@ declare class Evaluator {
|
|
|
131
166
|
isSpace(v: any): boolean;
|
|
132
167
|
isDNode(v: any): boolean;
|
|
133
168
|
isReiVal(v: any): boolean;
|
|
169
|
+
isStringMDim(v: any): boolean;
|
|
134
170
|
/** 値からσメタデータを取得(Tier 1) */
|
|
135
171
|
getSigmaMetadata(v: any): SigmaMetadata;
|
|
136
172
|
/** ReiValを透過的にアンラップ */
|
|
137
173
|
unwrap(v: any): any;
|
|
174
|
+
/** 値からその変数名を逆引きする(参照一致) */
|
|
175
|
+
findRefByValue(value: any): string | null;
|
|
176
|
+
/** 結合の伝播をトリガーする(変数名 + 新値) */
|
|
177
|
+
triggerPropagation(ref: string, newValue: any): number;
|
|
138
178
|
}
|
|
139
179
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
180
|
+
interface Token {
|
|
181
|
+
type: string;
|
|
182
|
+
value: string;
|
|
183
|
+
line: number;
|
|
184
|
+
col: number;
|
|
185
|
+
}
|
|
186
|
+
declare class Lexer {
|
|
187
|
+
private source;
|
|
188
|
+
private chars;
|
|
189
|
+
private pos;
|
|
190
|
+
private line;
|
|
191
|
+
private col;
|
|
192
|
+
private tokens;
|
|
193
|
+
constructor(source: string);
|
|
194
|
+
tokenize(): Token[];
|
|
195
|
+
private skipWhitespaceAndComments;
|
|
196
|
+
private readString;
|
|
197
|
+
private isExtStart;
|
|
198
|
+
private readExtLit;
|
|
199
|
+
private readNumber;
|
|
200
|
+
private readUnicodeToken;
|
|
201
|
+
private readMultiCharOp;
|
|
202
|
+
private readSingleCharOp;
|
|
203
|
+
private readIdentOrKeyword;
|
|
204
|
+
private advance;
|
|
205
|
+
private peek;
|
|
206
|
+
private emit;
|
|
207
|
+
private isDigit;
|
|
208
|
+
private isIdentStart;
|
|
209
|
+
private isIdentPart;
|
|
210
|
+
private shouldNegateBePrefix;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare class Parser {
|
|
214
|
+
private pos;
|
|
215
|
+
private tokens;
|
|
216
|
+
constructor(tokens: Token[]);
|
|
217
|
+
parseProgram(): any;
|
|
218
|
+
private parseStatement;
|
|
219
|
+
private parseLetStmt;
|
|
220
|
+
private parseCompressDef;
|
|
221
|
+
private parseCompressLevel;
|
|
222
|
+
private parseParamDecl;
|
|
223
|
+
private parseExpression;
|
|
224
|
+
private parsePipe;
|
|
225
|
+
private parsePipeCommand;
|
|
226
|
+
private parseLogicOr;
|
|
227
|
+
private parseLogicAnd;
|
|
228
|
+
private parseComparison;
|
|
229
|
+
private parseAddition;
|
|
230
|
+
private parseMultiplication;
|
|
231
|
+
private parseExtendReduce;
|
|
232
|
+
private parseUnary;
|
|
233
|
+
private parsePostfix;
|
|
234
|
+
private parsePrimary;
|
|
235
|
+
private parseMDimLit;
|
|
236
|
+
private parseSpaceLit;
|
|
237
|
+
private parseIfExpr;
|
|
238
|
+
private parseMatchExpr;
|
|
239
|
+
private peek;
|
|
240
|
+
private isAtEnd;
|
|
241
|
+
private check;
|
|
242
|
+
private checkAhead;
|
|
243
|
+
private advance;
|
|
244
|
+
private match;
|
|
245
|
+
private expect;
|
|
246
|
+
private error;
|
|
247
|
+
private shouldNegateBePrefix;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
declare function reiFn(source: string): any;
|
|
251
|
+
declare namespace reiFn {
|
|
163
252
|
var reset: () => void;
|
|
164
253
|
var evaluator: () => Evaluator;
|
|
165
|
-
var parse: (code: string) => any;
|
|
166
|
-
var tokenize: (code: string) => Token[];
|
|
167
254
|
}
|
|
255
|
+
declare const rei: typeof reiFn;
|
|
168
256
|
|
|
169
|
-
export {
|
|
257
|
+
export { Evaluator, Lexer, Parser, rei };
|