rip-lang 2.9.2 → 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 +45 -2
- package/README.md +55 -42
- package/docs/RIP-INTERNALS.md +576 -0
- package/docs/RIP-LANG.md +1126 -0
- package/docs/{TYPES.md → RIP-TYPES.md} +3 -3
- package/docs/dist/rip.browser.js +3278 -5474
- package/docs/dist/rip.browser.min.js +248 -332
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/package.json +1 -1
- package/src/browser.js +3 -20
- package/src/compiler.js +1683 -4550
- package/src/grammar/grammar.rip +529 -488
- package/src/lexer.js +1318 -3035
- package/src/parser.js +212 -220
- package/src/repl.js +16 -9
- package/docs/BROWSER.md +0 -990
- package/docs/GUIDE.md +0 -636
- package/docs/INTERNALS.md +0 -857
- package/docs/RATIONALE.md +0 -180
- package/docs/examples/README.md +0 -33
- package/docs/examples/arrows.rip +0 -74
- package/docs/examples/async-await.rip +0 -59
- package/docs/examples/existential.rip +0 -86
- package/docs/examples/fibonacci.rip +0 -12
- package/docs/examples/module.rip +0 -48
- package/docs/examples/ranges.rip +0 -45
- package/docs/examples/reactivity.rip +0 -48
- package/docs/examples/switch.rip +0 -50
- package/docs/examples/ternary.rip +0 -36
- /package/docs/{REACTIVITY.md → RIP-REACTIVITY.md} +0 -0
|
Binary file
|
package/package.json
CHANGED
package/src/browser.js
CHANGED
|
@@ -23,25 +23,16 @@ async function processRipScripts() {
|
|
|
23
23
|
const scripts = document.querySelectorAll('script[type="text/rip"]');
|
|
24
24
|
|
|
25
25
|
for (const script of scripts) {
|
|
26
|
-
|
|
27
|
-
if (script.hasAttribute('data-rip-processed')) {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
26
|
+
if (script.hasAttribute('data-rip-processed')) continue;
|
|
30
27
|
|
|
31
28
|
try {
|
|
32
|
-
// Get script content and remove HTML indentation
|
|
33
29
|
const ripCode = dedent(script.textContent);
|
|
34
|
-
|
|
35
|
-
// Compile to JavaScript
|
|
36
30
|
const jsCode = compileToJS(ripCode);
|
|
37
31
|
|
|
38
32
|
// Execute in global scope using indirect eval
|
|
39
|
-
// This makes functions available as global variables
|
|
40
33
|
(0, eval)(jsCode);
|
|
41
34
|
|
|
42
|
-
// Mark as processed
|
|
43
35
|
script.setAttribute('data-rip-processed', 'true');
|
|
44
|
-
|
|
45
36
|
} catch (error) {
|
|
46
37
|
console.error('Error compiling Rip script:', error);
|
|
47
38
|
console.error('Script content:', script.textContent);
|
|
@@ -54,12 +45,10 @@ if (typeof document !== 'undefined') {
|
|
|
54
45
|
if (document.readyState === 'loading') {
|
|
55
46
|
document.addEventListener('DOMContentLoaded', processRipScripts);
|
|
56
47
|
} else {
|
|
57
|
-
// DOM already loaded, process immediately
|
|
58
48
|
processRipScripts();
|
|
59
49
|
}
|
|
60
50
|
}
|
|
61
51
|
|
|
62
|
-
// Export for manual processing if needed
|
|
63
52
|
export { processRipScripts };
|
|
64
53
|
|
|
65
54
|
/**
|
|
@@ -70,19 +59,13 @@ export function rip(code) {
|
|
|
70
59
|
try {
|
|
71
60
|
const js = compileToJS(code);
|
|
72
61
|
|
|
73
|
-
//
|
|
74
|
-
// Variables will be created as implicit globals
|
|
62
|
+
// Strip let/const declarations so variables become implicit globals
|
|
75
63
|
let persistentJs = js.replace(/^let\s+[^;]+;\s*\n\s*/m, '');
|
|
76
64
|
persistentJs = persistentJs.replace(/^const\s+/gm, 'var ');
|
|
77
65
|
|
|
78
|
-
// Evaluate in global scope - variables become properties of globalThis
|
|
79
66
|
const result = (1, eval)(persistentJs);
|
|
80
67
|
|
|
81
|
-
|
|
82
|
-
if (result !== undefined) {
|
|
83
|
-
globalThis._ = result;
|
|
84
|
-
}
|
|
85
|
-
|
|
68
|
+
if (result !== undefined) globalThis._ = result;
|
|
86
69
|
return result;
|
|
87
70
|
} catch (error) {
|
|
88
71
|
console.error('Rip compilation error:', error.message);
|