tova 0.1.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/LICENSE +21 -0
- package/README.md +112 -0
- package/bin/tova.js +1530 -0
- package/package.json +38 -0
- package/src/analyzer/analyzer.js +2053 -0
- package/src/analyzer/scope.js +60 -0
- package/src/codegen/base-codegen.js +1351 -0
- package/src/codegen/client-codegen.js +876 -0
- package/src/codegen/codegen.js +148 -0
- package/src/codegen/server-codegen.js +2506 -0
- package/src/codegen/shared-codegen.js +29 -0
- package/src/diagnostics/formatter.js +139 -0
- package/src/formatter/formatter.js +559 -0
- package/src/index.js +6 -0
- package/src/lexer/lexer.js +886 -0
- package/src/lexer/tokens.js +214 -0
- package/src/lsp/server.js +738 -0
- package/src/parser/ast.js +1135 -0
- package/src/parser/parser.js +2803 -0
- package/src/runtime/db.js +106 -0
- package/src/runtime/embedded.js +8 -0
- package/src/runtime/reactivity.js +1366 -0
- package/src/runtime/router.js +200 -0
- package/src/runtime/rpc.js +46 -0
- package/src/runtime/ssr.js +134 -0
- package/src/runtime/string-proto.js +27 -0
- package/src/stdlib/collections.js +90 -0
- package/src/stdlib/core.js +98 -0
- package/src/stdlib/inline.js +172 -0
- package/src/stdlib/string.js +100 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Tova Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Tova
|
|
2
|
+
|
|
3
|
+
A modern programming language that transpiles to JavaScript, unifying frontend and backend development with clean, enjoyable syntax.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Full-stack in one file** — `server`, `client`, and `shared` blocks
|
|
8
|
+
- **Immutable by default** — `x = 1` is immutable, `var x = 1` is mutable
|
|
9
|
+
- **Reactive UI** — built-in signals, computed values, and effects
|
|
10
|
+
- **Seamless RPC** — call server functions from client like regular functions
|
|
11
|
+
- **Pattern matching** — exhaustive `match` expressions
|
|
12
|
+
- **Pipe operator** — `data |> transform() |> format()`
|
|
13
|
+
- **Python-inspired** — comprehensions, chained comparisons, `in`/`not in`, `elif`
|
|
14
|
+
- **Gradual typing** — optional type annotations with inference
|
|
15
|
+
- **npm compatible** — use any npm package
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Install (macOS / Linux)
|
|
21
|
+
curl -fsSL https://raw.githubusercontent.com/tova-lang/tova/main/install.sh | sh
|
|
22
|
+
|
|
23
|
+
# Or install via npm (requires Bun)
|
|
24
|
+
bun install -g tova
|
|
25
|
+
|
|
26
|
+
# Create a new project
|
|
27
|
+
tova new my-app
|
|
28
|
+
|
|
29
|
+
# Run development server
|
|
30
|
+
cd my-app
|
|
31
|
+
tova dev
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
|
|
36
|
+
```tova
|
|
37
|
+
shared {
|
|
38
|
+
type User {
|
|
39
|
+
id: Int
|
|
40
|
+
name: String
|
|
41
|
+
email: String
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
server {
|
|
46
|
+
fn get_users() -> [User] {
|
|
47
|
+
db.query("SELECT * FROM users")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
route GET "/api/users" => get_users
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
client {
|
|
54
|
+
state users: [User] = []
|
|
55
|
+
|
|
56
|
+
effect {
|
|
57
|
+
users = server.get_users()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
component App {
|
|
61
|
+
<div class="app">
|
|
62
|
+
<h1>"Users"</h1>
|
|
63
|
+
for user in users {
|
|
64
|
+
<p>"{user.name}"</p>
|
|
65
|
+
}
|
|
66
|
+
</div>
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Syntax Highlights
|
|
72
|
+
|
|
73
|
+
```tova
|
|
74
|
+
// Immutable binding
|
|
75
|
+
name = "Tova"
|
|
76
|
+
|
|
77
|
+
// Mutable binding
|
|
78
|
+
var count = 0
|
|
79
|
+
|
|
80
|
+
// Functions
|
|
81
|
+
fn greet(name = "world") {
|
|
82
|
+
"Hello, {name}!"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Pattern matching
|
|
86
|
+
fn describe(value) {
|
|
87
|
+
match value {
|
|
88
|
+
0 => "zero"
|
|
89
|
+
1..10 => "small"
|
|
90
|
+
n if n > 100 => "big"
|
|
91
|
+
_ => "other"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// List comprehension
|
|
96
|
+
evens = [x * 2 for x in range(10) if x > 0]
|
|
97
|
+
|
|
98
|
+
// Pipe operator
|
|
99
|
+
result = [1, 2, 3, 4, 5]
|
|
100
|
+
|> filter(fn(x) x > 2)
|
|
101
|
+
|> map(fn(x) x * 2)
|
|
102
|
+
|> sum()
|
|
103
|
+
|
|
104
|
+
// Chained comparisons
|
|
105
|
+
if 1 < x < 10 {
|
|
106
|
+
print("in range")
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|