rip-lang 3.6.0 → 3.6.2
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/README.md +1 -1
- package/docs/RIP-GUIDE.md +51 -0
- package/docs/RIP-TYPES.md +98 -0
- package/docs/dist/rip.browser.js +611 -272
- package/docs/dist/rip.browser.min.js +170 -170
- package/docs/dist/rip.browser.min.js.br +0 -0
- package/docs/index.html +35 -27
- package/package.json +1 -1
- package/src/compiler.js +55 -43
- package/src/components.js +157 -159
- package/src/grammar/grammar.rip +4 -0
- package/src/parser.js +41 -41
- package/src/repl.js +4 -128
- package/src/types.js +416 -35
package/README.md
CHANGED
|
@@ -307,7 +307,7 @@ Simple arrays (with `.loc`) instead of AST node classes. The compiler is self-ho
|
|
|
307
307
|
| Grammar | `src/grammar/grammar.rip` | 935 |
|
|
308
308
|
| Parser Generator | `src/grammar/solar.rip` | 916 |
|
|
309
309
|
| REPL | `src/repl.js` | 707 |
|
|
310
|
-
| Browser Entry | `src/browser.js` |
|
|
310
|
+
| Browser Entry | `src/browser.js` | 119 |
|
|
311
311
|
| Tags | `src/tags.js` | 63 |
|
|
312
312
|
| **Total** | | **~10,325** |
|
|
313
313
|
|
package/docs/RIP-GUIDE.md
CHANGED
|
@@ -534,6 +534,57 @@ user.save!()
|
|
|
534
534
|
|
|
535
535
|
---
|
|
536
536
|
|
|
537
|
+
## Browser
|
|
538
|
+
|
|
539
|
+
Rip runs directly in the browser with full async/await support — no build step.
|
|
540
|
+
|
|
541
|
+
### Inline Scripts
|
|
542
|
+
|
|
543
|
+
Load the compiler, then write Rip:
|
|
544
|
+
|
|
545
|
+
```html
|
|
546
|
+
<script type="module" src="/rip/browser.js"></script>
|
|
547
|
+
<script type="text/rip">
|
|
548
|
+
res = fetch! 'https://api.example.com/data'
|
|
549
|
+
data = res.json!
|
|
550
|
+
console.log data
|
|
551
|
+
</script>
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
The `!` operator works in inline scripts — `processRipScripts` wraps
|
|
555
|
+
compiled code in an async IIFE transparently.
|
|
556
|
+
|
|
557
|
+
### Console REPL
|
|
558
|
+
|
|
559
|
+
The `rip()` function is available in any browser console where `rip.browser.js`
|
|
560
|
+
is loaded:
|
|
561
|
+
|
|
562
|
+
```javascript
|
|
563
|
+
rip("42 * 10 + 8") // → 428
|
|
564
|
+
rip("name = 'Alice'") // → 'Alice' (persists on globalThis)
|
|
565
|
+
rip("(x * x for x in [1..5])") // → [1, 4, 9, 16, 25]
|
|
566
|
+
|
|
567
|
+
// Async — use await, Chrome displays the resolved value
|
|
568
|
+
await rip("res = fetch! 'https://jsonplaceholder.typicode.com/todos/1'; res.json!")
|
|
569
|
+
// → {userId: 1, id: 1, title: 'delectus aut autem', completed: false}
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Sync code returns values directly. Async code (using `!`) returns a Promise
|
|
573
|
+
that Chrome auto-awaits. Variables persist between calls on `globalThis`.
|
|
574
|
+
|
|
575
|
+
### `importRip(url)`
|
|
576
|
+
|
|
577
|
+
Fetch, compile, and import a `.rip` file as an ES module:
|
|
578
|
+
|
|
579
|
+
```html
|
|
580
|
+
<script type="text/rip">
|
|
581
|
+
{ launch } = importRip! '/rip/ui.rip'
|
|
582
|
+
launch '/demo'
|
|
583
|
+
</script>
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
537
588
|
## Full-Stack Example
|
|
538
589
|
|
|
539
590
|
A complete API server in Rip:
|
package/docs/RIP-TYPES.md
CHANGED
|
@@ -1878,6 +1878,104 @@ Each row is a test case. Verify both .js and .d.ts output.
|
|
|
1878
1878
|
|
|
1879
1879
|
---
|
|
1880
1880
|
|
|
1881
|
+
## Current Status
|
|
1882
|
+
|
|
1883
|
+
Rip Types Phase I is complete. The `.d.ts` emission covers the full
|
|
1884
|
+
surface area of the type system — variables, functions, classes, components,
|
|
1885
|
+
type aliases, interfaces, enums, generics, and all four reactive operators.
|
|
1886
|
+
|
|
1887
|
+
Phase II (consuming external `.d.ts` files for IDE intelligence) is in
|
|
1888
|
+
progress via the VS Code extension. Phase III (a standalone Language
|
|
1889
|
+
Server Protocol server) is planned.
|
|
1890
|
+
|
|
1891
|
+
### Architecture
|
|
1892
|
+
|
|
1893
|
+
The type system uses a two-phase approach:
|
|
1894
|
+
|
|
1895
|
+
1. **Lexer phase** — `rewriteTypes()` strips type annotations from the token
|
|
1896
|
+
stream and stores them as `.data` metadata on surviving tokens. The parser
|
|
1897
|
+
never sees types.
|
|
1898
|
+
2. **Compiler phase** — `emitTypes(tokens, sexpr)` runs after parsing,
|
|
1899
|
+
producing `.d.ts` from both annotated tokens (variables, functions, types)
|
|
1900
|
+
and the s-expression tree (components). One function, one output.
|
|
1901
|
+
|
|
1902
|
+
### What's Working
|
|
1903
|
+
|
|
1904
|
+
**Variables and Constants:**
|
|
1905
|
+
|
|
1906
|
+
| Rip Input | .d.ts Output |
|
|
1907
|
+
|-----------|-------------|
|
|
1908
|
+
| `x:: number = 0` | `let x: number;` |
|
|
1909
|
+
| `x:: number =! 100` | `declare const x: number;` |
|
|
1910
|
+
| `x:: number := 0` | `declare const x: Signal<number>;` |
|
|
1911
|
+
| `x:: number ~= y * 2` | `declare const x: Computed<number>;` |
|
|
1912
|
+
| `x:: Function ~> ...` | `declare const x: () => void;` |
|
|
1913
|
+
| `export` variants of all above | `export const/let ...` |
|
|
1914
|
+
|
|
1915
|
+
**Functions:**
|
|
1916
|
+
|
|
1917
|
+
| Rip Input | .d.ts Output |
|
|
1918
|
+
|-----------|-------------|
|
|
1919
|
+
| `def f(a:: T):: R` | `declare function f(a: T): R;` |
|
|
1920
|
+
| `def f<T>(a:: T):: T` | `declare function f<T>(a: T): T;` |
|
|
1921
|
+
| `def f<T extends Base>(...)` | `declare function f<T extends Base>(...);` |
|
|
1922
|
+
| `f = (a:: T) -> ...` | `declare function f(a: T);` |
|
|
1923
|
+
| `export def ...` | `export function ...;` |
|
|
1924
|
+
|
|
1925
|
+
**Types, Interfaces, and Enums:**
|
|
1926
|
+
|
|
1927
|
+
| Rip Input | .d.ts Output |
|
|
1928
|
+
|-----------|-------------|
|
|
1929
|
+
| `Name ::= type { id: number }` | `type Name = { id: number; };` |
|
|
1930
|
+
| `Name ::= number` | `type Name = number;` |
|
|
1931
|
+
| Block union `::= \| "a" \| "b"` | `type Name = "a" \| "b";` |
|
|
1932
|
+
| `interface Name { ... }` | `interface Name { ... }` |
|
|
1933
|
+
| `interface X extends Y` | `interface X extends Y { ... }` |
|
|
1934
|
+
| Function types `read: => string` | `read: () => string` |
|
|
1935
|
+
| `enum Name { A = 1; B = 2 }` | `enum Name { A = 1, B = 2 }` |
|
|
1936
|
+
|
|
1937
|
+
**Classes:**
|
|
1938
|
+
|
|
1939
|
+
| Rip Input | .d.ts Output |
|
|
1940
|
+
|-----------|-------------|
|
|
1941
|
+
| `class X { prop:: T = val }` | `declare class X { prop: T; }` |
|
|
1942
|
+
| `constructor: (@name:: T) ->` | `constructor(name: T);` |
|
|
1943
|
+
| `method: (a:: T) ->` | `method(a: T);` |
|
|
1944
|
+
| `class X extends Y` | `declare class X extends Y { ... }` |
|
|
1945
|
+
|
|
1946
|
+
**Components:**
|
|
1947
|
+
|
|
1948
|
+
| Rip Input | .d.ts Output |
|
|
1949
|
+
|-----------|-------------|
|
|
1950
|
+
| `Name = component { ... }` | `declare class Name { ... }` |
|
|
1951
|
+
| Reactive state `count:: number := 0` | `count: number;` |
|
|
1952
|
+
| Computed `doubled ~= ...` | `readonly doubled: any;` |
|
|
1953
|
+
| Methods | Method declarations |
|
|
1954
|
+
| Auto-generated | `constructor`, `mount()`, `unmount()` |
|
|
1955
|
+
|
|
1956
|
+
**Infrastructure:**
|
|
1957
|
+
|
|
1958
|
+
| Feature | Status |
|
|
1959
|
+
|---------|--------|
|
|
1960
|
+
| `Signal<T>` / `Computed<T>` preamble | Auto-generated when `:=` or `~=` used |
|
|
1961
|
+
| Import pass-through | Working |
|
|
1962
|
+
| Export default | Working |
|
|
1963
|
+
| Optional properties (`email?: string`) | Working |
|
|
1964
|
+
| Type suffixes (`T?`, `T??`, `T!`) | Working |
|
|
1965
|
+
| Generic constraints (`<T extends X>`) | Working |
|
|
1966
|
+
| Deferred emission (after parsing) | Working |
|
|
1967
|
+
| Component variable deduplication | Working |
|
|
1968
|
+
|
|
1969
|
+
### Roadmap
|
|
1970
|
+
|
|
1971
|
+
| Phase | Description | Status |
|
|
1972
|
+
|-------|-------------|--------|
|
|
1973
|
+
| Phase I | `.d.ts` emission from annotated Rip code | **Complete** |
|
|
1974
|
+
| Phase II | External type consumption — read third-party `.d.ts` files for autocomplete, hover, and go-to-definition | In progress (VS Code extension) |
|
|
1975
|
+
| Phase III | Language Server Protocol — full LSP server for IDE-agnostic type intelligence | Planned |
|
|
1976
|
+
|
|
1977
|
+
---
|
|
1978
|
+
|
|
1881
1979
|
**See Also:**
|
|
1882
1980
|
- [RIP-LANG.md](RIP-LANG.md) — Language reference
|
|
1883
1981
|
- [RIP-REACTIVITY.md](RIP-REACTIVITY.md) — Reactive system details
|