clou-lang 0.3.5 → 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/ai/clou-ai-prompt.md +197 -12
- package/bin/clou.js +138 -6
- package/package.json +1 -1
- package/playground/clou-browser.js +434 -2
- package/playground/index.html +4 -7
- package/src/compiler.js +284 -2
- package/src/errors.js +2 -0
- package/src/lexer.js +28 -0
- package/src/parser.js +122 -0
- package/src/terminal-parser.js +68 -0
- package/src/terminal-runtime.js +56 -0
package/ai/clou-ai-prompt.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Clou Language - AI System Prompt
|
|
2
2
|
|
|
3
|
-
You are an expert in the **Clou** programming language. Clou is
|
|
3
|
+
You are an expert in the **Clou** programming language. Clou is the simplest programming language ever made — designed so even kids can build websites and terminal apps. Its motto: **"Describe it once. Run it everywhere."**
|
|
4
4
|
|
|
5
5
|
## How Clou Works
|
|
6
6
|
|
|
@@ -9,8 +9,11 @@ Clou code compiles to HTML/CSS/JS for websites, or runs directly in the terminal
|
|
|
9
9
|
**Run:** `clou mysite.clou` (auto-detects website vs terminal)
|
|
10
10
|
**Build:** `clou build mysite.clou`
|
|
11
11
|
**Dev server:** `clou dev mysite.clou`
|
|
12
|
+
**Deploy:** `clou deploy mysite.clou`
|
|
13
|
+
**Init project:** `clou init my-project`
|
|
14
|
+
**Playground:** `clou playground`
|
|
12
15
|
|
|
13
|
-
## Website Mode — Full Syntax Reference
|
|
16
|
+
## Website Mode — Full Syntax Reference (40+ Elements)
|
|
14
17
|
|
|
15
18
|
```clou
|
|
16
19
|
// Variables
|
|
@@ -53,17 +56,70 @@ page "Title" at "/":
|
|
|
53
56
|
link "text" to "url" // anchor
|
|
54
57
|
line // horizontal rule
|
|
55
58
|
space 40 // vertical spacing (px)
|
|
56
|
-
|
|
57
|
-
//
|
|
59
|
+
code "let x = 1" // code block
|
|
60
|
+
audio "song.mp3" // audio player
|
|
61
|
+
badge "NEW" // small colored label
|
|
62
|
+
avatar "photo.jpg" // circular profile image
|
|
63
|
+
stars 4 // star rating (0-5)
|
|
64
|
+
stars 4 "Great!" // star rating with label
|
|
65
|
+
tooltip "Hover me" "Extra info shows on hover"
|
|
66
|
+
typing "Hello World" // typewriter animation text
|
|
67
|
+
countdown "2026-12-31" // live countdown timer
|
|
68
|
+
countdown "2026-12-31" "New Year" // with label
|
|
69
|
+
embed "youtube.com/watch?v=..." // embed YouTube/iframe
|
|
70
|
+
search "Search..." // search bar with icon
|
|
71
|
+
darkmode // dark/light mode toggle button
|
|
72
|
+
|
|
73
|
+
// Carousel (image slider)
|
|
74
|
+
carousel:
|
|
75
|
+
image "slide1.jpg"
|
|
76
|
+
image "slide2.jpg"
|
|
77
|
+
image "slide3.jpg"
|
|
78
|
+
|
|
79
|
+
// Forms & Input
|
|
80
|
+
form:
|
|
81
|
+
input "placeholder"
|
|
82
|
+
textarea "Write here..."
|
|
83
|
+
checkbox "I agree"
|
|
84
|
+
dropdown "Country":
|
|
85
|
+
option "Germany"
|
|
86
|
+
option "USA"
|
|
87
|
+
option "Japan"
|
|
88
|
+
slider "Volume" 0 to 100
|
|
89
|
+
submit "Send"
|
|
90
|
+
|
|
91
|
+
// Data Display
|
|
92
|
+
table:
|
|
93
|
+
heading "Name, Role, Status"
|
|
94
|
+
row:
|
|
95
|
+
text "Alex"
|
|
96
|
+
text "Developer"
|
|
97
|
+
text "Active"
|
|
98
|
+
|
|
99
|
+
progress 75 "Loading..."
|
|
100
|
+
|
|
101
|
+
// Interactive Elements
|
|
102
|
+
tabs:
|
|
103
|
+
tab "Info":
|
|
104
|
+
text "Info content"
|
|
105
|
+
tab "Settings":
|
|
106
|
+
text "Settings content"
|
|
107
|
+
|
|
108
|
+
accordion:
|
|
109
|
+
panel "Question 1":
|
|
110
|
+
text "Answer 1"
|
|
111
|
+
panel "Question 2":
|
|
112
|
+
text "Answer 2"
|
|
113
|
+
|
|
114
|
+
// Actions (inside buttons)
|
|
58
115
|
button "Click me":
|
|
59
116
|
show message "Alert text!"
|
|
117
|
+
toast "Saved!" // temporary notification
|
|
60
118
|
open "modal-name"
|
|
61
119
|
close "modal-name"
|
|
62
120
|
toggle "element-id"
|
|
63
121
|
go to "url"
|
|
64
122
|
|
|
65
|
-
input "placeholder"
|
|
66
|
-
|
|
67
123
|
list:
|
|
68
124
|
text "Item 1"
|
|
69
125
|
text "Item 2"
|
|
@@ -95,7 +151,7 @@ style:
|
|
|
95
151
|
font Arial
|
|
96
152
|
size 18
|
|
97
153
|
gradient #color1 to #color2
|
|
98
|
-
animate fade / slide / bounce / grow / glow
|
|
154
|
+
animate fade / slide / bounce / grow / glow / pulse / shake / float / typewrite
|
|
99
155
|
big / huge / small / tiny
|
|
100
156
|
full
|
|
101
157
|
sticky
|
|
@@ -123,6 +179,20 @@ repeat 5:
|
|
|
123
179
|
| `glass` | Glassmorphism, purple gradient |
|
|
124
180
|
| `aurora` | Northern lights, cyan-purple |
|
|
125
181
|
|
|
182
|
+
## Available Animations
|
|
183
|
+
|
|
184
|
+
| Animation | Effect |
|
|
185
|
+
|-----------|--------|
|
|
186
|
+
| `fade` | Fade in from transparent |
|
|
187
|
+
| `slide` | Slide up into view |
|
|
188
|
+
| `bounce` | Bounce down into place |
|
|
189
|
+
| `grow` | Scale up from small |
|
|
190
|
+
| `glow` | Pulsing brightness (infinite) |
|
|
191
|
+
| `pulse` | Scale pulse (infinite) |
|
|
192
|
+
| `shake` | Horizontal shake |
|
|
193
|
+
| `float` | Gentle floating up/down (infinite) |
|
|
194
|
+
| `typewrite` | Typewriter reveal with cursor |
|
|
195
|
+
|
|
126
196
|
## Terminal Mode — Full Syntax Reference
|
|
127
197
|
|
|
128
198
|
```clou
|
|
@@ -142,6 +212,26 @@ app "My App":
|
|
|
142
212
|
multiply 3 by count
|
|
143
213
|
divide 2 by count
|
|
144
214
|
|
|
215
|
+
// Math operators
|
|
216
|
+
set result to 5 + 3
|
|
217
|
+
set total to 10 * 2
|
|
218
|
+
set half to 100 / 4
|
|
219
|
+
|
|
220
|
+
// Random
|
|
221
|
+
random 1 to 10 save as num
|
|
222
|
+
|
|
223
|
+
// HTTP Requests
|
|
224
|
+
fetch "https://api.example.com/data" save as response
|
|
225
|
+
|
|
226
|
+
// Interactive Menu
|
|
227
|
+
menu "Choose an option:":
|
|
228
|
+
option "Play Game":
|
|
229
|
+
print "Starting game..."
|
|
230
|
+
option "View Score":
|
|
231
|
+
print "Score: {score}"
|
|
232
|
+
option "Quit":
|
|
233
|
+
exit
|
|
234
|
+
|
|
145
235
|
// Conditions
|
|
146
236
|
if name is "Alex":
|
|
147
237
|
print "Hi Alex!"
|
|
@@ -189,6 +279,7 @@ app "My App":
|
|
|
189
279
|
6. **Templates**: Use templates for any repeated pattern (cards, sections, etc.)
|
|
190
280
|
7. **Comments**: Use `//` for comments.
|
|
191
281
|
8. **Keep it simple**: Clou's power is simplicity. Don't overcomplicate.
|
|
282
|
+
9. **Use new elements**: Prefer form/table/tabs/accordion/carousel/stars/badge/search when appropriate.
|
|
192
283
|
|
|
193
284
|
## Example: Complete Website
|
|
194
285
|
|
|
@@ -204,22 +295,33 @@ template feature(emoji, title, desc):
|
|
|
204
295
|
|
|
205
296
|
page "{brand}":
|
|
206
297
|
theme "aurora"
|
|
298
|
+
darkmode
|
|
207
299
|
|
|
208
300
|
navbar "{brand}":
|
|
209
301
|
link "Features" to "#features"
|
|
210
|
-
link "
|
|
302
|
+
link "About" to "#about"
|
|
303
|
+
link "Contact" to "#contact"
|
|
211
304
|
|
|
212
305
|
section "hero":
|
|
213
306
|
center
|
|
214
307
|
space 30
|
|
308
|
+
badge "NOW LIVE"
|
|
309
|
+
space 10
|
|
215
310
|
heading "Build the Future":
|
|
216
311
|
huge
|
|
217
312
|
animate fade
|
|
218
313
|
text "Simple tools for complex problems.":
|
|
219
314
|
big
|
|
315
|
+
typing "Describe it once. Run it everywhere."
|
|
316
|
+
space 20
|
|
317
|
+
row:
|
|
318
|
+
center
|
|
319
|
+
button "Get Started":
|
|
320
|
+
toast "Welcome aboard!"
|
|
321
|
+
button "Learn More":
|
|
322
|
+
go to "#features"
|
|
220
323
|
space 20
|
|
221
|
-
|
|
222
|
-
show message "Welcome!"
|
|
324
|
+
countdown "2026-12-31" "Launch Countdown"
|
|
223
325
|
space 30
|
|
224
326
|
|
|
225
327
|
section "features":
|
|
@@ -231,9 +333,92 @@ page "{brand}":
|
|
|
231
333
|
use feature("⚡", "Fast", "Built for speed.")
|
|
232
334
|
use feature("🔒", "Secure", "Safe by default.")
|
|
233
335
|
use feature("🎨", "Beautiful", "Looks great.")
|
|
336
|
+
space 20
|
|
337
|
+
stars 5 "Rated by developers"
|
|
338
|
+
|
|
339
|
+
section "gallery":
|
|
340
|
+
center
|
|
341
|
+
heading "Screenshots":
|
|
342
|
+
huge
|
|
343
|
+
space 20
|
|
344
|
+
carousel:
|
|
345
|
+
image "screenshot1.jpg"
|
|
346
|
+
image "screenshot2.jpg"
|
|
347
|
+
image "screenshot3.jpg"
|
|
348
|
+
|
|
349
|
+
section "about":
|
|
350
|
+
heading "FAQ":
|
|
351
|
+
huge
|
|
352
|
+
space 20
|
|
353
|
+
accordion:
|
|
354
|
+
panel "What is {brand}?":
|
|
355
|
+
text "The simplest way to build software."
|
|
356
|
+
panel "How much does it cost?":
|
|
357
|
+
text "Free forever."
|
|
358
|
+
panel "How do I start?":
|
|
359
|
+
text "npm install -g clou-lang"
|
|
360
|
+
|
|
361
|
+
section "team":
|
|
362
|
+
center
|
|
363
|
+
heading "Our Team":
|
|
364
|
+
huge
|
|
365
|
+
space 20
|
|
366
|
+
grid:
|
|
367
|
+
card:
|
|
368
|
+
avatar "team1.jpg"
|
|
369
|
+
heading "Alex"
|
|
370
|
+
text "Founder"
|
|
371
|
+
stars 5
|
|
372
|
+
card:
|
|
373
|
+
avatar "team2.jpg"
|
|
374
|
+
heading "Sam"
|
|
375
|
+
text "Designer"
|
|
376
|
+
stars 4
|
|
377
|
+
|
|
378
|
+
section "contact":
|
|
379
|
+
center
|
|
380
|
+
heading "Get in Touch"
|
|
381
|
+
space 20
|
|
382
|
+
search "Search our docs..."
|
|
383
|
+
space 20
|
|
384
|
+
form:
|
|
385
|
+
input "Your name"
|
|
386
|
+
input "Your email"
|
|
387
|
+
textarea "Your message"
|
|
388
|
+
submit "Send Message"
|
|
234
389
|
|
|
235
390
|
footer:
|
|
236
|
-
text "© 2026 {brand}"
|
|
391
|
+
text "© 2026 {brand} — Built with Clou"
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
## Example: Terminal App
|
|
395
|
+
|
|
396
|
+
```clou
|
|
397
|
+
app "Number Guessing Game":
|
|
398
|
+
print color cyan "=== Number Guessing Game ==="
|
|
399
|
+
random 1 to 100 save as secret
|
|
400
|
+
set tries to "0"
|
|
401
|
+
set won to "false"
|
|
402
|
+
|
|
403
|
+
while won is "false":
|
|
404
|
+
ask "Guess a number (1-100):" save as guess
|
|
405
|
+
add 1 to tries
|
|
406
|
+
|
|
407
|
+
if guess is secret:
|
|
408
|
+
set won to "true"
|
|
409
|
+
print color green "Correct! You won in {tries} tries!"
|
|
410
|
+
else:
|
|
411
|
+
if guess greater than secret:
|
|
412
|
+
print color yellow "Too high!"
|
|
413
|
+
else:
|
|
414
|
+
print color yellow "Too low!"
|
|
415
|
+
|
|
416
|
+
menu "Play again?":
|
|
417
|
+
option "Yes":
|
|
418
|
+
print "Restarting..."
|
|
419
|
+
option "No":
|
|
420
|
+
print "Goodbye!"
|
|
421
|
+
exit
|
|
237
422
|
```
|
|
238
423
|
|
|
239
|
-
When the user asks you to build something with Clou, generate clean, well-structured Clou code following these patterns.
|
|
424
|
+
When the user asks you to build something with Clou, generate clean, well-structured Clou code following these patterns. Use all available elements (40+) where they make sense.
|
package/bin/clou.js
CHANGED
|
@@ -18,7 +18,7 @@ const args = process.argv.slice(2);
|
|
|
18
18
|
function printHelp() {
|
|
19
19
|
console.log(`
|
|
20
20
|
╔═══════════════════════════════════════╗
|
|
21
|
-
║ CLOU Language v0.
|
|
21
|
+
║ CLOU Language v0.4.0 ║
|
|
22
22
|
║ Describe it once. Run everywhere. ║
|
|
23
23
|
╚═══════════════════════════════════════╝
|
|
24
24
|
|
|
@@ -29,6 +29,7 @@ function printHelp() {
|
|
|
29
29
|
clou build <file.clou> -o <output> Build to specific file
|
|
30
30
|
clou dev <file.clou> Start live dev server
|
|
31
31
|
clou dev <file.clou> -p <port> Dev server on custom port
|
|
32
|
+
clou init <name> Create new project
|
|
32
33
|
clou deploy <file.clou> Deploy to the web (surge)
|
|
33
34
|
clou deploy <file.clou> --github Deploy to GitHub Pages
|
|
34
35
|
clou deploy <file.clou> --netlify Deploy with Netlify
|
|
@@ -91,10 +92,16 @@ function getOutputPath(inputFile, customOutput) {
|
|
|
91
92
|
|
|
92
93
|
function openInBrowser(filePath) {
|
|
93
94
|
const absPath = path.resolve(filePath);
|
|
94
|
-
const { exec } = require('child_process');
|
|
95
|
+
const { exec, execSync } = require('child_process');
|
|
95
96
|
|
|
96
97
|
if (process.platform === 'win32') {
|
|
97
|
-
|
|
98
|
+
// Use start command - escape path for Windows cmd
|
|
99
|
+
exec(`start "" "${absPath}"`, (err) => {
|
|
100
|
+
if (err) {
|
|
101
|
+
// Fallback: use explorer
|
|
102
|
+
exec(`explorer "${absPath}"`);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
98
105
|
} else if (process.platform === 'darwin') {
|
|
99
106
|
exec(`open "${absPath}"`);
|
|
100
107
|
} else {
|
|
@@ -256,9 +263,134 @@ if (args[0] === 'ai') {
|
|
|
256
263
|
}
|
|
257
264
|
|
|
258
265
|
if (args[0] === 'playground' || args[0] === 'play') {
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
266
|
+
const playgroundDir = path.resolve(__dirname, '..', 'playground');
|
|
267
|
+
const playgroundFile = path.join(playgroundDir, 'index.html');
|
|
268
|
+
|
|
269
|
+
if (!fs.existsSync(playgroundFile)) {
|
|
270
|
+
console.error(' Error: Playground files not found.');
|
|
271
|
+
process.exit(1);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Start a simple HTTP server for the playground
|
|
275
|
+
const http = require('http');
|
|
276
|
+
const port = 4000;
|
|
277
|
+
|
|
278
|
+
const mimeTypes = {
|
|
279
|
+
'.html': 'text/html',
|
|
280
|
+
'.js': 'application/javascript',
|
|
281
|
+
'.css': 'text/css',
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const server = http.createServer((req, res) => {
|
|
285
|
+
let filePath = path.join(playgroundDir, req.url === '/' ? 'index.html' : req.url);
|
|
286
|
+
const ext = path.extname(filePath);
|
|
287
|
+
const contentType = mimeTypes[ext] || 'text/plain';
|
|
288
|
+
|
|
289
|
+
fs.readFile(filePath, (err, data) => {
|
|
290
|
+
if (err) {
|
|
291
|
+
res.writeHead(404);
|
|
292
|
+
res.end('Not found');
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
res.writeHead(200, { 'Content-Type': contentType });
|
|
296
|
+
res.end(data);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
server.listen(port, () => {
|
|
301
|
+
console.log(` Clou Playground running at http://localhost:${port}`);
|
|
302
|
+
console.log(' Press Ctrl+C to stop.\n');
|
|
303
|
+
openInBrowser(`http://localhost:${port}`);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// Don't exit - keep server running
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Handle init command
|
|
311
|
+
if (args[0] === 'init') {
|
|
312
|
+
const projectName = args[1] || 'my-clou-site';
|
|
313
|
+
const projectDir = path.resolve(projectName);
|
|
314
|
+
|
|
315
|
+
if (fs.existsSync(projectDir)) {
|
|
316
|
+
console.error(` Error: Directory "${projectName}" already exists.`);
|
|
317
|
+
process.exit(1);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
fs.mkdirSync(projectDir, { recursive: true });
|
|
321
|
+
|
|
322
|
+
const template = `set brand to "${projectName}"
|
|
323
|
+
|
|
324
|
+
template feature(emoji, title, desc):
|
|
325
|
+
card:
|
|
326
|
+
icon "{emoji}"
|
|
327
|
+
heading "{title}"
|
|
328
|
+
text "{desc}"
|
|
329
|
+
animate slide
|
|
330
|
+
|
|
331
|
+
page "{brand}":
|
|
332
|
+
theme "midnight"
|
|
333
|
+
|
|
334
|
+
navbar "{brand}":
|
|
335
|
+
link "Home" to "#"
|
|
336
|
+
link "About" to "#about"
|
|
337
|
+
link "Contact" to "#contact"
|
|
338
|
+
|
|
339
|
+
section "hero":
|
|
340
|
+
center
|
|
341
|
+
space 30
|
|
342
|
+
heading "Welcome to {brand}":
|
|
343
|
+
huge
|
|
344
|
+
animate fade
|
|
345
|
+
text "Built with Clou — the simplest language ever.":
|
|
346
|
+
big
|
|
347
|
+
space 20
|
|
348
|
+
button "Get Started":
|
|
349
|
+
show message "Let's go!"
|
|
350
|
+
space 30
|
|
351
|
+
|
|
352
|
+
section "about":
|
|
353
|
+
center
|
|
354
|
+
heading "Features":
|
|
355
|
+
huge
|
|
356
|
+
space 20
|
|
357
|
+
grid:
|
|
358
|
+
use feature("⚡", "Fast", "Builds in milliseconds.")
|
|
359
|
+
use feature("🎨", "Beautiful", "10 themes included.")
|
|
360
|
+
use feature("🚀", "Easy Deploy", "One command to go live.")
|
|
361
|
+
|
|
362
|
+
section "contact":
|
|
363
|
+
center
|
|
364
|
+
heading "Contact":
|
|
365
|
+
huge
|
|
366
|
+
space 20
|
|
367
|
+
form:
|
|
368
|
+
input "Your name"
|
|
369
|
+
input "Your email"
|
|
370
|
+
textarea "Your message"
|
|
371
|
+
submit "Send"
|
|
372
|
+
|
|
373
|
+
footer:
|
|
374
|
+
text "© 2026 {brand} — Built with Clou"
|
|
375
|
+
`;
|
|
376
|
+
|
|
377
|
+
fs.writeFileSync(path.join(projectDir, 'index.clou'), template, 'utf-8');
|
|
378
|
+
|
|
379
|
+
console.log(`
|
|
380
|
+
╔═══════════════════════════════════════╗
|
|
381
|
+
║ CLOU Project Created! ║
|
|
382
|
+
╚═══════════════════════════════════════╝
|
|
383
|
+
|
|
384
|
+
Created: ${projectName}/index.clou
|
|
385
|
+
|
|
386
|
+
Next steps:
|
|
387
|
+
cd ${projectName}
|
|
388
|
+
clou index.clou Build & open
|
|
389
|
+
clou dev index.clou Live dev server
|
|
390
|
+
clou deploy index.clou Deploy to the web
|
|
391
|
+
|
|
392
|
+
Happy building! 🚀
|
|
393
|
+
`);
|
|
262
394
|
process.exit(0);
|
|
263
395
|
}
|
|
264
396
|
|