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.
Files changed (40) hide show
  1. package/LICENSE +230 -191
  2. package/PEACE_USE_CLAUSE.md +95 -0
  3. package/README.md +257 -186
  4. package/bin/rei.js +259 -144
  5. package/dist/index.d.mts +257 -0
  6. package/dist/index.d.ts +181 -93
  7. package/dist/index.js +5710 -239
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +8741 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/package.json +73 -62
  12. package/spec/REI_BNF_v0.2.md +398 -0
  13. package/spec/REI_BNF_v0.3.md +358 -0
  14. package/spec/REI_SPEC_v0.1.md +587 -0
  15. package/theory/LICENSE-THEORY.md +57 -0
  16. package/theory/README.md +85 -0
  17. package/theory/category-c-design.md +502 -0
  18. package/theory/core-theories-11-14.md +799 -0
  19. package/theory/core-theories-15-21.md +675 -0
  20. package/theory/core-theories-8-10.md +582 -0
  21. package/theory/d-fumt-overview.md +99 -0
  22. package/theory/genesis-axiom-system.md +124 -0
  23. package/theory/gft-theory.md +160 -0
  24. package/theory/index.ts +9 -0
  25. package/theory/notation-equivalence.md +134 -0
  26. package/theory/semantic-compressor.ts +903 -0
  27. package/theory/stdlib-tier1-design.md +477 -0
  28. package/theory/theories-11-14.ts +466 -0
  29. package/theory/theories-15-21.ts +762 -0
  30. package/theory/theories-22-28.ts +794 -0
  31. package/theory/theories-29-35.ts +607 -0
  32. package/theory/theories-36-42.ts +937 -0
  33. package/theory/theories-43-49.ts +1298 -0
  34. package/theory/theories-50-56.ts +1449 -0
  35. package/theory/theories-57-66.ts +1724 -0
  36. package/theory/theories-67.ts +1696 -0
  37. package/theory/theories-8-10.ts +284 -0
  38. package/dist/index.cjs +0 -3282
  39. package/dist/index.cjs.map +0 -1
  40. package/dist/index.d.cts +0 -169
package/bin/rei.js CHANGED
@@ -1,144 +1,259 @@
1
- #!/usr/bin/env node
2
-
3
- // ============================================================
4
- // Rei v0.3 CLI — D-FUMT Computational Language
5
- // Space-Layer-Diffusion + Category C (25 Axioms)
6
- // Author: Nobuki Fujimoto
7
- // ============================================================
8
-
9
- const VERSION = '0.3.0';
10
-
11
- async function main() {
12
- // Dynamic import for ESM compatibility
13
- const { Lexer, Parser, Evaluator } = await import('../dist/index.js');
14
-
15
- const args = process.argv.slice(2);
16
-
17
- // --version / -v
18
- if (args.includes('--version') || args.includes('-v')) {
19
- console.log(`Rei (0₀式) v${VERSION}`);
20
- process.exit(0);
21
- }
22
-
23
- // --help / -h
24
- if (args.includes('--help') || args.includes('-h')) {
25
- console.log(`
26
- Rei (0₀式/れいしき) v${VERSION}
27
- D-FUMT Computational Language — Space-Layer-Diffusion + Category C (25 Axioms)
28
-
29
- Usage:
30
- rei Start interactive REPL
31
- rei <file.rei> Execute a Rei source file
32
- rei -e "<code>" Evaluate code directly
33
- rei --version Show version
34
- rei --help Show this help
35
-
36
- Examples:
37
- rei -e "𝕄{5; 1, 2, 3} |> compute"
38
- rei -e "42 |> sigma"
39
- rei -e "[1, 5, 3] |> project('max') |> consensus"
40
- rei -e "𝕄{5; 1, 2, 3} |> encode |> decode('array')"
41
-
42
- v0.3 New Features:
43
- Category C 25 consciousness axioms (C1-C5, N1-N5, M1-M5, U1-U5, A1-A5)
44
- Space-Layer-Diffusion spatial computation model
45
- 226 tests passing
46
-
47
- Homepage: https://github.com/fc0web/rei-lang
48
- npm: https://www.npmjs.com/package/rei-lang
49
- `);
50
- process.exit(0);
51
- }
52
-
53
- // -e "<code>" evaluate code
54
- const eIdx = args.indexOf('-e');
55
- if (eIdx >= 0 && args[eIdx + 1]) {
56
- const ev = new Evaluator();
57
- try {
58
- const tokens = new Lexer(args[eIdx + 1]).tokenize();
59
- const ast = new Parser(tokens).parseProgram();
60
- const result = ev.eval(ast);
61
- if (result !== undefined && result !== null) {
62
- console.log(typeof result === 'object' ? JSON.stringify(result, null, 2) : result);
63
- }
64
- } catch (e) {
65
- console.error('Error:', e.message);
66
- process.exit(1);
67
- }
68
- process.exit(0);
69
- }
70
-
71
- // <file.rei> — execute file
72
- if (args.length > 0 && !args[0].startsWith('-')) {
73
- const fs = await import('fs');
74
- const path = await import('path');
75
- const filePath = path.resolve(args[0]);
76
- try {
77
- const code = fs.readFileSync(filePath, 'utf-8');
78
- const ev = new Evaluator();
79
- const tokens = new Lexer(code).tokenize();
80
- const ast = new Parser(tokens).parseProgram();
81
- const result = ev.eval(ast);
82
- if (result !== undefined && result !== null) {
83
- console.log(typeof result === 'object' ? JSON.stringify(result, null, 2) : result);
84
- }
85
- } catch (e) {
86
- console.error('Error:', e.message);
87
- process.exit(1);
88
- }
89
- process.exit(0);
90
- }
91
-
92
- // REPL mode
93
- const readline = await import('readline');
94
- const rl = readline.createInterface({
95
- input: process.stdin,
96
- output: process.stdout,
97
- prompt: 'rei> ',
98
- });
99
-
100
- console.log(`Rei (0₀式) v${VERSION} — D-FUMT Computational Language`);
101
- console.log('Category C: 25 axioms | 226 tests | Space-Layer-Diffusion');
102
- console.log('Type "exit" or Ctrl+C to quit.\n');
103
-
104
- const ev = new Evaluator();
105
- rl.prompt();
106
-
107
- rl.on('line', (line) => {
108
- const input = line.trim();
109
- if (input === 'exit' || input === 'quit') {
110
- rl.close();
111
- process.exit(0);
112
- }
113
- if (!input) {
114
- rl.prompt();
115
- return;
116
- }
117
-
118
- try {
119
- const tokens = new Lexer(input).tokenize();
120
- const ast = new Parser(tokens).parseProgram();
121
- const result = ev.eval(ast);
122
- if (result !== undefined && result !== null) {
123
- if (typeof result === 'object') {
124
- console.log(JSON.stringify(result, null, 2));
125
- } else {
126
- console.log(result);
127
- }
128
- }
129
- } catch (e) {
130
- console.error('Error:', e.message);
131
- }
132
- rl.prompt();
133
- });
134
-
135
- rl.on('close', () => {
136
- console.log('\nさようなら。');
137
- process.exit(0);
138
- });
139
- }
140
-
141
- main().catch((e) => {
142
- console.error('Fatal:', e.message);
143
- process.exit(1);
144
- });
1
+ #!/usr/bin/env node
2
+
3
+ // ============================================================
4
+ // Rei (0₀式) CLI — REPL & File Execution
5
+ // v0.3 — Space-Layer-Diffusion Model
6
+ // Author: Nobuki Fujimoto
7
+ // ============================================================
8
+
9
+ const { Lexer } = require('../dist/index.js');
10
+ const { Parser } = require('../dist/index.js');
11
+ const { Evaluator } = require('../dist/index.js');
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+ const readline = require('readline');
15
+
16
+ const VERSION = '0.3.0';
17
+
18
+ // --- Result formatting ---
19
+ function formatResult(val) {
20
+ if (val === null || val === undefined) return 'null';
21
+ if (typeof val === 'number') return String(val);
22
+ if (typeof val === 'string') return `"${val}"`;
23
+ if (typeof val === 'boolean') return String(val);
24
+ if (Array.isArray(val)) return `[${val.map(formatResult).join(', ')}]`;
25
+
26
+ if (val && typeof val === 'object') {
27
+ switch (val.reiType) {
28
+ case 'Ext':
29
+ return `Ext(base=${val.base}, order=${val.order}, subs="${val.subscripts}", val*=${val.valStar()})`;
30
+ case 'MDim':
31
+ return `𝕄{${val.center}; ${val.neighbors.join(', ')}} :${val.mode}`;
32
+ case 'State':
33
+ return `Genesis(${val.state}, ω=${val.omega})`;
34
+ case 'Function':
35
+ return `compress ${val.name}(${val.params.join(', ')})`;
36
+ case 'Quad':
37
+ const sym = { top: '⊤', bottom: '⊥', topPi: '⊤π', bottomPi: '⊥π' };
38
+ return sym[val.value] || val.value;
39
+ // ── v0.3 Space-Layer-Diffusion ──
40
+ case 'Space': {
41
+ const layers = [];
42
+ for (const [idx, layer] of val.layers) {
43
+ const nodes = layer.nodes.map(n =>
44
+ `𝕄{${n.center}; ${n.neighbors.slice(0, 4).join(', ')}${n.neighbors.length > 4 ? ', ...' : ''}}[stage=${n.stage}]`
45
+ ).join(', ');
46
+ const frozen = layer.frozen ? ' ❄' : '';
47
+ layers.push(` 層 ${idx}${frozen}: ${nodes}`);
48
+ }
49
+ return `空{${val.topology !== 'flat' ? ` topology: ${val.topology}` : ''}\n${layers.join('\n')}\n} [global_stage=${val.globalStage}]`;
50
+ }
51
+ case 'DNode': {
52
+ const ns = val.neighbors.slice(0, 4).join(', ') + (val.neighbors.length > 4 ? `, ... (${val.neighbors.length}方向)` : '');
53
+ return `DNode{${val.center}; ${ns}} [stage=${val.stage}, ${val.momentum}]`;
54
+ }
55
+ case 'SigmaResult': {
56
+ return `σ{ flow: {stage=${val.flow.stage}, dirs=${val.flow.directions}, ${val.flow.momentum}}, layer=${val.layer}, memory=[${val.memory.length}] }`;
57
+ }
58
+ default:
59
+ // Handle plain objects (sigma sub-objects, resonance pairs, etc.)
60
+ if (val.similarity !== undefined && val.nodeA && val.nodeB) {
61
+ return `Resonance(層${val.nodeA.layer}[${val.nodeA.index}] 層${val.nodeB.layer}[${val.nodeB.index}], sim=${val.similarity})`;
62
+ }
63
+ if (val.stage !== undefined && val.momentum !== undefined && val.directions !== undefined) {
64
+ return `σ.flow{stage=${val.stage}, dirs=${val.directions}, ${val.momentum}, v=${val.velocity}}`;
65
+ }
66
+ if (val.tendency !== undefined && val.strength !== undefined) {
67
+ return `σ.will{τ=${val.tendency}, strength=${val.strength}}`;
68
+ }
69
+ if (val.layers !== undefined && val.total_nodes !== undefined) {
70
+ return `σ.field{layers=${val.layers}, nodes=${val.total_nodes}, active=${val.active_nodes}}`;
71
+ }
72
+ if (val.global_stage !== undefined) {
73
+ return `σ.flow{global_stage=${val.global_stage}, converged=${val.converged_nodes}, expanding=${val.expanding_nodes}}`;
74
+ }
75
+ return JSON.stringify(val);
76
+ }
77
+ }
78
+ return String(val);
79
+ }
80
+
81
+ // --- Evaluate code string ---
82
+ function evaluate(code, evaluator) {
83
+ const lexer = new Lexer(code);
84
+ const tokens = lexer.tokenize();
85
+ const parser = new Parser(tokens);
86
+ const ast = parser.parseProgram();
87
+ return evaluator.eval(ast);
88
+ }
89
+
90
+ // --- CLI argument parsing ---
91
+ const args = process.argv.slice(2);
92
+
93
+ if (args.includes('--version') || args.includes('-v')) {
94
+ console.log(`rei-lang v${VERSION}`);
95
+ process.exit(0);
96
+ }
97
+
98
+ if (args.includes('--help') || args.includes('-h')) {
99
+ console.log(`
100
+ Rei (0₀式) — D-FUMT Computational Language v${VERSION}
101
+ Space-Layer-Diffusion Model (場-層-拡散計算モデル)
102
+
103
+ Usage:
104
+ rei Start interactive REPL
105
+ rei <file.rei> Execute a Rei source file
106
+ rei -e "<code>" Evaluate inline code
107
+ rei --version Show version
108
+ rei --help Show this help
109
+
110
+ REPL commands:
111
+ :env Show all bindings
112
+ :ast <code> Show AST for code
113
+ :tokens <code> Show token stream
114
+ :reset Clear all state
115
+ :quit Exit REPL
116
+
117
+ v0.3 New Features:
118
+ 空{ 層 N: 𝕄{...} } Space literal with layers
119
+ s |> step Single diffusion step
120
+ s |> diffuse(N) Diffuse N steps
121
+ s |> sigma Self-reference (σ)
122
+ s |> freeze(N) Freeze layer N
123
+ s |> thaw(N) Thaw layer N
124
+ s |> resonances(0.5) Find resonance pairs
125
+
126
+ Author: Nobuki Fujimoto
127
+ `);
128
+ process.exit(0);
129
+ }
130
+
131
+ // --- Inline eval: -e ---
132
+ const eIdx = args.indexOf('-e');
133
+ if (eIdx >= 0 && args[eIdx + 1]) {
134
+ try {
135
+ const evaluator = new Evaluator();
136
+ const result = evaluate(args[eIdx + 1], evaluator);
137
+ console.log(formatResult(result));
138
+ } catch (e) {
139
+ console.error(`Error: ${e.message}`);
140
+ process.exit(1);
141
+ }
142
+ process.exit(0);
143
+ }
144
+
145
+ // --- File execution ---
146
+ if (args.length > 0 && !args[0].startsWith('-')) {
147
+ const filePath = path.resolve(args[0]);
148
+ try {
149
+ const code = fs.readFileSync(filePath, 'utf-8');
150
+ const evaluator = new Evaluator();
151
+ const result = evaluate(code, evaluator);
152
+ if (result !== null && result !== undefined) {
153
+ console.log(formatResult(result));
154
+ }
155
+ } catch (e) {
156
+ if (e.code === 'ENOENT') {
157
+ console.error(`File not found: ${filePath}`);
158
+ } else {
159
+ console.error(`Error: ${e.message}`);
160
+ }
161
+ process.exit(1);
162
+ }
163
+ process.exit(0);
164
+ }
165
+
166
+ // --- Interactive REPL ---
167
+ console.log(`
168
+ ╔══════════════════════════════════════════════╗
169
+ ║ Rei (0₀式) REPL v${VERSION} ║
170
+ ║ D-FUMT Computational Language ║
171
+ ║ Space-Layer-Diffusion Model (場-層-拡散) ║
172
+ ║ Author: Nobuki Fujimoto ║
173
+ ╚══════════════════════════════════════════════╝
174
+
175
+ Type :help for commands, :quit to exit
176
+ `);
177
+
178
+ const evaluator = new Evaluator();
179
+ const rl = readline.createInterface({
180
+ input: process.stdin,
181
+ output: process.stdout,
182
+ prompt: '\x1b[33m零 >\x1b[0m ',
183
+ });
184
+
185
+ rl.prompt();
186
+
187
+ rl.on('line', (input) => {
188
+ const trimmed = input.trim();
189
+ if (!trimmed) { rl.prompt(); return; }
190
+
191
+ // Meta commands
192
+ if (trimmed === ':quit' || trimmed === ':q') {
193
+ console.log('\nさようなら');
194
+ process.exit(0);
195
+ }
196
+ if (trimmed === ':help' || trimmed === ':h') {
197
+ console.log(' :env Show all bindings');
198
+ console.log(' :ast Show AST for last input');
199
+ console.log(' :tokens Show token stream');
200
+ console.log(' :reset Clear state');
201
+ console.log(' :quit Exit');
202
+ rl.prompt();
203
+ return;
204
+ }
205
+ if (trimmed === ':reset') {
206
+ Object.assign(evaluator, new Evaluator());
207
+ console.log(' State reset.');
208
+ rl.prompt();
209
+ return;
210
+ }
211
+ if (trimmed === ':env') {
212
+ const bindings = evaluator.env.allBindings();
213
+ for (const [k, v] of bindings) {
214
+ if (v.value && typeof v.value === 'object' && v.value.reiType === 'Function' && !v.value.body) continue;
215
+ console.log(` ${v.mutable ? 'mut ' : ''}${k} = ${formatResult(v.value)}`);
216
+ }
217
+ rl.prompt();
218
+ return;
219
+ }
220
+ if (trimmed.startsWith(':ast ')) {
221
+ try {
222
+ const code = trimmed.slice(5);
223
+ const lexer = new Lexer(code);
224
+ const tokens = lexer.tokenize();
225
+ const parser = new Parser(tokens);
226
+ const ast = parser.parseProgram();
227
+ console.log(JSON.stringify(ast, null, 2));
228
+ } catch (e) { console.log(`\x1b[31m${e.message}\x1b[0m`); }
229
+ rl.prompt();
230
+ return;
231
+ }
232
+ if (trimmed.startsWith(':tokens ')) {
233
+ try {
234
+ const code = trimmed.slice(8);
235
+ const lexer = new Lexer(code);
236
+ const tokens = lexer.tokenize();
237
+ tokens.forEach(t => console.log(` ${t.type.padEnd(15)} ${JSON.stringify(t.value)}`));
238
+ } catch (e) { console.log(`\x1b[31m${e.message}\x1b[0m`); }
239
+ rl.prompt();
240
+ return;
241
+ }
242
+
243
+ // Evaluate
244
+ try {
245
+ const result = evaluate(trimmed, evaluator);
246
+ const out = formatResult(result);
247
+ if (out !== 'null' && out !== 'undefined') {
248
+ console.log(`\x1b[33m${out}\x1b[0m`);
249
+ }
250
+ } catch (e) {
251
+ console.log(`\x1b[31m${e.message}\x1b[0m`);
252
+ }
253
+ rl.prompt();
254
+ });
255
+
256
+ rl.on('close', () => {
257
+ console.log('\nさようなら');
258
+ process.exit(0);
259
+ });
@@ -0,0 +1,257 @@
1
+ /** 結合モード */
2
+ type BindingMode = 'mirror' | 'inverse' | 'resonance' | 'entangle' | 'causal';
3
+ /** 伝播規則 */
4
+ interface PropagationRule {
5
+ type: 'immediate' | 'delayed' | 'attenuated';
6
+ delay: number;
7
+ attenuation: number;
8
+ }
9
+ /** 結合イベント — 記憶属性との統合 */
10
+ interface BindingEvent {
11
+ step: number;
12
+ type: 'created' | 'propagated' | 'broken' | 'strengthened' | 'weakened';
13
+ sourceValue: any;
14
+ targetValue: any;
15
+ delta: number;
16
+ }
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;
104
+ }
105
+
106
+ interface SigmaMetadata {
107
+ memory: any[];
108
+ tendency: string;
109
+ pipeCount: number;
110
+ }
111
+ declare class Environment {
112
+ parent: Environment | null;
113
+ bindings: Map<string, {
114
+ value: any;
115
+ mutable: boolean;
116
+ }>;
117
+ constructor(parent?: Environment | null);
118
+ define(name: string, value: any, mutable?: boolean): void;
119
+ get(name: string): any;
120
+ set(name: string, value: any): void;
121
+ has(name: string): boolean;
122
+ getBinding(name: string): any;
123
+ allBindings(): Map<string, {
124
+ value: any;
125
+ mutable: boolean;
126
+ }>;
127
+ }
128
+ declare class Evaluator {
129
+ env: Environment;
130
+ bindingRegistry: BindingRegistry;
131
+ constructor(parent?: Environment);
132
+ private registerBuiltins;
133
+ eval(ast: any): any;
134
+ private evalProgram;
135
+ private evalConstLit;
136
+ private evalMDimLit;
137
+ private evalSpaceLit;
138
+ private evalLetStmt;
139
+ private evalMutStmt;
140
+ private evalCompressDef;
141
+ private evalBinOp;
142
+ private evalUnaryOp;
143
+ private evalPipe;
144
+ private execPipeCmd;
145
+ private evalFnCall;
146
+ private callFunction;
147
+ private callBuiltin;
148
+ private evalMemberAccess;
149
+ private evalIndexAccess;
150
+ private evalExtend;
151
+ private evalReduce;
152
+ private evalConverge;
153
+ private evalDiverge;
154
+ private evalReflect;
155
+ private evalIfExpr;
156
+ private evalMatchExpr;
157
+ toNumber(val: any): number;
158
+ private isTruthy;
159
+ private matches;
160
+ isObj(v: any): boolean;
161
+ isMDim(v: any): boolean;
162
+ isExt(v: any): boolean;
163
+ isGenesis(v: any): boolean;
164
+ isFunction(v: any): boolean;
165
+ isQuad(v: any): boolean;
166
+ isSpace(v: any): boolean;
167
+ isDNode(v: any): boolean;
168
+ isReiVal(v: any): boolean;
169
+ isStringMDim(v: any): boolean;
170
+ /** 値からσメタデータを取得(Tier 1) */
171
+ getSigmaMetadata(v: any): SigmaMetadata;
172
+ /** ReiValを透過的にアンラップ */
173
+ unwrap(v: any): any;
174
+ /** 値からその変数名を逆引きする(参照一致) */
175
+ findRefByValue(value: any): string | null;
176
+ /** 結合の伝播をトリガーする(変数名 + 新値) */
177
+ triggerPropagation(ref: string, newValue: any): number;
178
+ }
179
+
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 {
252
+ var reset: () => void;
253
+ var evaluator: () => Evaluator;
254
+ }
255
+ declare const rei: typeof reiFn;
256
+
257
+ export { Evaluator, Lexer, Parser, rei };