kuhul-es 1.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/@kuhul-es.html +5 -0
- package/New Text Document.txt +0 -0
- package/README.md +11 -0
- package/bin/kuhul-es.js +43 -0
- package/cli/cli.sh +3 -0
- package/cli/src/New Text Document.txt +0 -0
- package/cli/src/main.ts +358 -0
- package/compiler/src/New Text Document.txt +0 -0
- package/compiler/src/parser.ts +396 -0
- package/examples/New Text Document.txt +0 -0
- package/examples/physics.kuhules +93 -0
- package/glyph-execution.js +2 -0
- package/install.sh +18 -0
- package/license.md +26 -0
- package/node.js +3 -0
- package/package.json +36 -0
- package/package.json.backup +61 -0
- package/readme.txt +18 -0
- package/runtime/src/New Text Document.txt +0 -0
- package/runtime/src/browser.js +407 -0
- package/runtime/src/node.js +339 -0
- package/setup-npm.ps1 +40 -0
- package/src/index.js +52 -0
- package//317/200-Bindings.js +2 -0
package/@kuhul-es.html
ADDED
|
File without changes
|
package/README.md
ADDED
package/bin/kuhul-es.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Create bin directory
|
|
2
|
+
New-Item -ItemType Directory -Force -Path bin
|
|
3
|
+
|
|
4
|
+
# Create the CLI file
|
|
5
|
+
@'
|
|
6
|
+
#!/usr/bin/env node
|
|
7
|
+
|
|
8
|
+
console.log(`
|
|
9
|
+
╔══════════════════════════════════════╗
|
|
10
|
+
║ KUHUL-ES v1.0.0 ║
|
|
11
|
+
║ ECMAScript syntax, KUHUL semantics ║
|
|
12
|
+
╚══════════════════════════════════════╝
|
|
13
|
+
`);
|
|
14
|
+
|
|
15
|
+
const { program } = require('commander');
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.name('kuhul-es')
|
|
19
|
+
.description('KUHUL-ES - The Trojan Horse for KUHUL semantics')
|
|
20
|
+
.version('1.0.0');
|
|
21
|
+
|
|
22
|
+
program
|
|
23
|
+
.command('init [project-name]')
|
|
24
|
+
.description('Initialize a new KUHUL-ES project')
|
|
25
|
+
.action((projectName = 'my-kuhul-app') => {
|
|
26
|
+
console.log(`Creating project: ${projectName}`);
|
|
27
|
+
// Implementation would go here
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
program
|
|
31
|
+
.command('compile <file>')
|
|
32
|
+
.description('Compile KUHUL-ES source file')
|
|
33
|
+
.action((file) => {
|
|
34
|
+
console.log(`Compiling: ${file}`);
|
|
35
|
+
// Implementation would go here
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
program.parse(process.argv);
|
|
39
|
+
|
|
40
|
+
if (!process.argv.slice(2).length) {
|
|
41
|
+
program.outputHelp();
|
|
42
|
+
}
|
|
43
|
+
'@ | Out-File bin/kuhul-es.js -Encoding UTF8
|
package/cli/cli.sh
ADDED
|
File without changes
|
package/cli/src/main.ts
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
// kuhul-es/cli/src/main.ts
|
|
2
|
+
#!/usr/bin/env node
|
|
3
|
+
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import { KUHULParser } from '../compiler/src/parser';
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
|
|
10
|
+
const program = new Command();
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.name('kuhul-es')
|
|
14
|
+
.description('KUHUL-ES Compiler - ECMAScript syntax with KUHUL semantics')
|
|
15
|
+
.version('1.0.0');
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.command('compile <input>')
|
|
19
|
+
.description('Compile KUHUL-ES source file')
|
|
20
|
+
.option('-o, --output <file>', 'Output file')
|
|
21
|
+
.option('-w, --watch', 'Watch for changes')
|
|
22
|
+
.action(async (input, options) => {
|
|
23
|
+
try {
|
|
24
|
+
const source = fs.readFileSync(input, 'utf-8');
|
|
25
|
+
const parser = new KUHULParser(source, input);
|
|
26
|
+
const result = parser.parse();
|
|
27
|
+
|
|
28
|
+
const outputFile = options.output || input.replace('.kuhules', '.js');
|
|
29
|
+
fs.writeFileSync(outputFile, result.transformedCode);
|
|
30
|
+
|
|
31
|
+
console.log(chalk.green('✓ Compiled successfully!'));
|
|
32
|
+
console.log(chalk.cyan(` Input: ${input}`));
|
|
33
|
+
console.log(chalk.cyan(` Output: ${outputFile}`));
|
|
34
|
+
console.log(chalk.cyan(` π-Bindings: ${result.πBindings.size}`));
|
|
35
|
+
console.log(chalk.cyan(` τ-Bindings: ${result.τBindings.size}`));
|
|
36
|
+
console.log(chalk.cyan(` Glyph Calls: ${result.glyphCalls.length}`));
|
|
37
|
+
|
|
38
|
+
if (options.watch) {
|
|
39
|
+
console.log(chalk.yellow('👁️ Watching for changes...'));
|
|
40
|
+
fs.watch(input, (eventType) => {
|
|
41
|
+
if (eventType === 'change') {
|
|
42
|
+
console.log(chalk.blue('\n🔄 File changed, recompiling...'));
|
|
43
|
+
const newSource = fs.readFileSync(input, 'utf-8');
|
|
44
|
+
const newParser = new KUHULParser(newSource, input);
|
|
45
|
+
const newResult = newParser.parse();
|
|
46
|
+
fs.writeFileSync(outputFile, newResult.transformedCode);
|
|
47
|
+
console.log(chalk.green('✓ Recompiled!'));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(chalk.red('✗ Compilation failed:'), error.message);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
program
|
|
58
|
+
.command('init [project-name]')
|
|
59
|
+
.description('Initialize a new KUHUL-ES project')
|
|
60
|
+
.action((projectName = 'my-kuhul-app') => {
|
|
61
|
+
const projectDir = path.resolve(projectName);
|
|
62
|
+
|
|
63
|
+
if (fs.existsSync(projectDir)) {
|
|
64
|
+
console.error(chalk.red(`Directory ${projectName} already exists!`));
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Create project structure
|
|
69
|
+
fs.mkdirSync(projectDir, { recursive: true });
|
|
70
|
+
fs.mkdirSync(path.join(projectDir, 'src'), { recursive: true });
|
|
71
|
+
|
|
72
|
+
// Create package.json
|
|
73
|
+
const packageJson = {
|
|
74
|
+
name: projectName,
|
|
75
|
+
version: '1.0.0',
|
|
76
|
+
type: 'module',
|
|
77
|
+
scripts: {
|
|
78
|
+
'dev': 'kuhul-es compile src/main.kuhules -w',
|
|
79
|
+
'build': 'kuhul-es compile src/main.kuhules -o dist/bundle.js',
|
|
80
|
+
'start': 'node dist/bundle.js'
|
|
81
|
+
},
|
|
82
|
+
dependencies: {
|
|
83
|
+
'@kuhul/es-runtime': '^1.0.0'
|
|
84
|
+
},
|
|
85
|
+
devDependencies: {
|
|
86
|
+
'@kuhul/es-compiler': '^1.0.0'
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
fs.writeFileSync(
|
|
91
|
+
path.join(projectDir, 'package.json'),
|
|
92
|
+
JSON.stringify(packageJson, null, 2)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
// Create example KUHUL-ES file
|
|
96
|
+
const exampleCode = `
|
|
97
|
+
// main.kuhules - KUHUL-ES Example
|
|
98
|
+
π gravity = [0, 9.81, 0];
|
|
99
|
+
π world = {
|
|
100
|
+
bodies: [],
|
|
101
|
+
fields: []
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
τ currentFrame = 0;
|
|
105
|
+
|
|
106
|
+
function* initializeWorld() {
|
|
107
|
+
yield* Sek('log', 'Initializing KUHUL-ES world...');
|
|
108
|
+
|
|
109
|
+
@if (gravity[1] > 0) {
|
|
110
|
+
yield* Sek('add_field', world, {
|
|
111
|
+
type: 'gravity',
|
|
112
|
+
strength: gravity[1]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@for (let i = 0; i < 5; i++) {
|
|
117
|
+
π body = {
|
|
118
|
+
id: 'body_' + i,
|
|
119
|
+
position: [i * 10, 0, 0],
|
|
120
|
+
mass: 1.0
|
|
121
|
+
};
|
|
122
|
+
yield* Sek('add_body', world, body);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
yield* Sek('start_physics', world, 60);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function* physicsLoop() {
|
|
129
|
+
@while (world.active) {
|
|
130
|
+
yield* Sek('physics_tick', world);
|
|
131
|
+
currentFrame += 1;
|
|
132
|
+
|
|
133
|
+
@if (currentFrame % 60 === 0) {
|
|
134
|
+
yield* Sek('log', \`Second: \${currentFrame / 60}\`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function* main() {
|
|
140
|
+
yield* initializeWorld();
|
|
141
|
+
yield* physicsLoop();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Start execution
|
|
145
|
+
main();
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
fs.writeFileSync(
|
|
149
|
+
path.join(projectDir, 'src/main.kuhules'),
|
|
150
|
+
exampleCode.trim()
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
// Create HTML example
|
|
154
|
+
const htmlExample = `
|
|
155
|
+
<!DOCTYPE html>
|
|
156
|
+
<html lang="en">
|
|
157
|
+
<head>
|
|
158
|
+
<meta charset="UTF-8">
|
|
159
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
160
|
+
<title>${projectName} - KUHUL-ES</title>
|
|
161
|
+
<style>
|
|
162
|
+
body {
|
|
163
|
+
margin: 0;
|
|
164
|
+
padding: 20px;
|
|
165
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
166
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
167
|
+
color: white;
|
|
168
|
+
min-height: 100vh;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.container {
|
|
172
|
+
max-width: 800px;
|
|
173
|
+
margin: 0 auto;
|
|
174
|
+
background: rgba(255, 255, 255, 0.1);
|
|
175
|
+
backdrop-filter: blur(10px);
|
|
176
|
+
border-radius: 20px;
|
|
177
|
+
padding: 40px;
|
|
178
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
h1 {
|
|
182
|
+
margin-top: 0;
|
|
183
|
+
font-size: 2.5em;
|
|
184
|
+
background: linear-gradient(45deg, #f093fb 0%, #f5576c 100%);
|
|
185
|
+
-webkit-background-clip: text;
|
|
186
|
+
-webkit-text-fill-color: transparent;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.physics-canvas {
|
|
190
|
+
width: 100%;
|
|
191
|
+
height: 400px;
|
|
192
|
+
background: rgba(0, 0, 0, 0.2);
|
|
193
|
+
border-radius: 10px;
|
|
194
|
+
margin: 20px 0;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.stats {
|
|
198
|
+
display: grid;
|
|
199
|
+
grid-template-columns: repeat(3, 1fr);
|
|
200
|
+
gap: 20px;
|
|
201
|
+
margin-top: 30px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.stat {
|
|
205
|
+
background: rgba(255, 255, 255, 0.1);
|
|
206
|
+
padding: 20px;
|
|
207
|
+
border-radius: 10px;
|
|
208
|
+
text-align: center;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.stat-value {
|
|
212
|
+
font-size: 2em;
|
|
213
|
+
font-weight: bold;
|
|
214
|
+
color: #4fd1c5;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.console {
|
|
218
|
+
background: rgba(0, 0, 0, 0.3);
|
|
219
|
+
border-radius: 10px;
|
|
220
|
+
padding: 20px;
|
|
221
|
+
margin-top: 30px;
|
|
222
|
+
font-family: 'Courier New', monospace;
|
|
223
|
+
height: 200px;
|
|
224
|
+
overflow-y: auto;
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
227
|
+
</head>
|
|
228
|
+
<body>
|
|
229
|
+
<div class="container">
|
|
230
|
+
<h1>🧠 ${projectName}</h1>
|
|
231
|
+
<p>KUHUL-ES Physics Simulation Running</p>
|
|
232
|
+
|
|
233
|
+
<div class="physics-canvas" id="physics-canvas"></div>
|
|
234
|
+
|
|
235
|
+
<div class="stats">
|
|
236
|
+
<div class="stat">
|
|
237
|
+
<div class="stat-label">π-Bindings</div>
|
|
238
|
+
<div class="stat-value" id="pi-count">0</div>
|
|
239
|
+
</div>
|
|
240
|
+
<div class="stat">
|
|
241
|
+
<div class="stat-label">τ-Bindings</div>
|
|
242
|
+
<div class="stat-value" id="tau-count">0</div>
|
|
243
|
+
</div>
|
|
244
|
+
<div class="stat">
|
|
245
|
+
<div class="stat-label">Frame</div>
|
|
246
|
+
<div class="stat-value" id="frame-count">0</div>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<div class="console" id="console"></div>
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
<script type="module">
|
|
254
|
+
import { KUHULRuntime } from 'https://unpkg.com/@kuhul/es-runtime@1.0.0/dist/browser.js';
|
|
255
|
+
|
|
256
|
+
// Example KUHUL-ES code
|
|
257
|
+
const source = \`
|
|
258
|
+
π gravity = [0, 9.81, 0];
|
|
259
|
+
π world = { bodies: [], active: true };
|
|
260
|
+
τ frame = 0;
|
|
261
|
+
|
|
262
|
+
function* main() {
|
|
263
|
+
yield* Sek('log', '🚀 KUHUL-ES Starting...');
|
|
264
|
+
|
|
265
|
+
// Create some physics bodies
|
|
266
|
+
@for (let i = 0; i < 10; i++) {
|
|
267
|
+
π body = {
|
|
268
|
+
id: 'body_' + i,
|
|
269
|
+
x: Math.random() * 800,
|
|
270
|
+
y: Math.random() * 400,
|
|
271
|
+
vx: (Math.random() - 0.5) * 10,
|
|
272
|
+
vy: (Math.random() - 0.5) * 10
|
|
273
|
+
};
|
|
274
|
+
yield* Sek('create_body', body);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Physics loop
|
|
278
|
+
@while (world.active) {
|
|
279
|
+
yield* Sek('update_physics', 0.016);
|
|
280
|
+
frame += 1;
|
|
281
|
+
yield* Sek('render_frame');
|
|
282
|
+
|
|
283
|
+
@if (frame % 60 === 0) {
|
|
284
|
+
yield* Sek('log', \`Frame: \${frame}\`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
main();
|
|
290
|
+
\`;
|
|
291
|
+
|
|
292
|
+
const runtime = new KUHULRuntime();
|
|
293
|
+
runtime.on('log', (message) => {
|
|
294
|
+
const consoleEl = document.getElementById('console');
|
|
295
|
+
consoleEl.innerHTML += '<div>' + message + '</div>';
|
|
296
|
+
consoleEl.scrollTop = consoleEl.scrollHeight;
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
runtime.on('frame_update', (frame) => {
|
|
300
|
+
document.getElementById('frame-count').textContent = frame;
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
runtime.on('stat_update', (stats) => {
|
|
304
|
+
document.getElementById('pi-count').textContent = stats.piBindings;
|
|
305
|
+
document.getElementById('tau-count').textContent = stats.tauBindings;
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// Start the runtime
|
|
309
|
+
runtime.execute(source);
|
|
310
|
+
|
|
311
|
+
// Canvas rendering
|
|
312
|
+
const canvas = document.createElement('canvas');
|
|
313
|
+
const ctx = canvas.getContext('2d');
|
|
314
|
+
const container = document.getElementById('physics-canvas');
|
|
315
|
+
canvas.width = container.clientWidth;
|
|
316
|
+
canvas.height = container.clientHeight;
|
|
317
|
+
container.appendChild(canvas);
|
|
318
|
+
|
|
319
|
+
// Simple physics visualization
|
|
320
|
+
function renderBodies(bodies) {
|
|
321
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
322
|
+
|
|
323
|
+
bodies.forEach(body => {
|
|
324
|
+
ctx.beginPath();
|
|
325
|
+
ctx.arc(body.x, body.y, 10, 0, Math.PI * 2);
|
|
326
|
+
ctx.fillStyle = '#4fd1c5';
|
|
327
|
+
ctx.fill();
|
|
328
|
+
|
|
329
|
+
// Velocity vector
|
|
330
|
+
ctx.beginPath();
|
|
331
|
+
ctx.moveTo(body.x, body.y);
|
|
332
|
+
ctx.lineTo(body.x + body.vx, body.y + body.vy);
|
|
333
|
+
ctx.strokeStyle = '#f56565';
|
|
334
|
+
ctx.lineWidth = 2;
|
|
335
|
+
ctx.stroke();
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
runtime.on('render', renderBodies);
|
|
340
|
+
</script>
|
|
341
|
+
</body>
|
|
342
|
+
</html>
|
|
343
|
+
`;
|
|
344
|
+
|
|
345
|
+
fs.writeFileSync(
|
|
346
|
+
path.join(projectDir, 'index.html'),
|
|
347
|
+
htmlExample.trim()
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
console.log(chalk.green(`✓ Created KUHUL-ES project: ${projectName}`));
|
|
351
|
+
console.log(chalk.cyan('\nNext steps:'));
|
|
352
|
+
console.log(chalk.cyan(` cd ${projectName}`));
|
|
353
|
+
console.log(chalk.cyan(' npm install'));
|
|
354
|
+
console.log(chalk.cyan(' npm run dev'));
|
|
355
|
+
console.log(chalk.cyan('\nThen open index.html in your browser!'));
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
program.parse(process.argv);
|
|
File without changes
|