@shd101wyy/yo 0.0.32 → 0.0.33
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 +107 -21
- package/out/cjs/index.cjs +798 -912
- package/out/cjs/yo-cli.cjs +895 -1012
- package/out/esm/index.mjs +745 -859
- package/out/types/src/build-runner.d.ts +3 -1
- package/out/types/src/codegen/index.d.ts +10 -0
- package/out/types/src/evaluator/builtins/build.d.ts +23 -10
- package/out/types/src/evaluator/exprs/while.d.ts +2 -1
- package/out/types/src/expr-traversal.d.ts +1 -0
- package/out/types/src/expr.d.ts +4 -2
- package/out/types/src/fetch.d.ts +1 -0
- package/out/types/src/pkg-config.d.ts +7 -2
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/build.yo +57 -16
package/README.md
CHANGED
|
@@ -9,6 +9,32 @@ Yo aims to be **Simple** and **Fast** (around 0% - 15% slower than C).
|
|
|
9
9
|
|
|
10
10
|
> The name `Yo` comes from the Chinese word `柚` (yòu), meaning `pomelo`, a large citrus fruit similar to grapefruit. It's my daughter's nickname.
|
|
11
11
|
|
|
12
|
+
📖 [My Story with Programming Languages](./docs/en-US/MY_STORY_WITH_PROGRAMMING_LANGUAGES.md) — the journey from Java at 16 to building Yo.
|
|
13
|
+
|
|
14
|
+
<!-- @import "[TOC]" {cmd="toc" depthFrom=2 depthTo=6 orderedList=false} -->
|
|
15
|
+
|
|
16
|
+
<!-- code_chunk_output -->
|
|
17
|
+
|
|
18
|
+
- [Features](#features)
|
|
19
|
+
- [Installation](#installation)
|
|
20
|
+
- [C Compiler Requirement](#c-compiler-requirement)
|
|
21
|
+
- [Installing Clang](#installing-clang)
|
|
22
|
+
- [Linux liburing Requirement](#linux-liburing-requirement)
|
|
23
|
+
- [Installing liburing (Linux)](#installing-liburing-linux)
|
|
24
|
+
- [Quick Start](#quick-start)
|
|
25
|
+
- [Prelude](#prelude)
|
|
26
|
+
- [Standard Library](#standard-library)
|
|
27
|
+
- [Code examples](#code-examples)
|
|
28
|
+
- [Hello World](#hello-world)
|
|
29
|
+
- [Example Projects](#example-projects)
|
|
30
|
+
- [Contributing](#contributing)
|
|
31
|
+
- [Setup](#setup)
|
|
32
|
+
- [Editor Support](#editor-support)
|
|
33
|
+
- [Star History](#star-history)
|
|
34
|
+
- [License](#license)
|
|
35
|
+
|
|
36
|
+
<!-- /code_chunk_output -->
|
|
37
|
+
|
|
12
38
|
## Features
|
|
13
39
|
|
|
14
40
|
For the design of the language, please refer to [DESIGN.md](./docs/en-US/DESIGN.md).
|
|
@@ -79,6 +105,12 @@ $ brew install llvm
|
|
|
79
105
|
|
|
80
106
|
**Windows:**
|
|
81
107
|
|
|
108
|
+
Clang on Windows requires a linker and Windows SDK headers. Install **Visual Studio** (Community edition is free) or the **Build Tools for Visual Studio** with the "Desktop development with C++" workload:
|
|
109
|
+
|
|
110
|
+
1. Download from [https://visualstudio.microsoft.com/downloads/](https://visualstudio.microsoft.com/downloads/)
|
|
111
|
+
2. In the installer, select **"Desktop development with C++"** (this includes MSVC, Windows SDK, and the linker)
|
|
112
|
+
3. Then install LLVM/Clang:
|
|
113
|
+
|
|
82
114
|
```bash
|
|
83
115
|
# Using Chocolatey
|
|
84
116
|
$ choco install llvm
|
|
@@ -89,6 +121,16 @@ $ scoop install llvm
|
|
|
89
121
|
# Or download from https://releases.llvm.org/
|
|
90
122
|
```
|
|
91
123
|
|
|
124
|
+
Alternatively, you can use `zig` as the C compiler (no Visual Studio needed):
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Using Chocolatey
|
|
128
|
+
$ choco install zig
|
|
129
|
+
|
|
130
|
+
# Then compile with:
|
|
131
|
+
$ yo compile main.yo --c-compiler zig --release -o main
|
|
132
|
+
```
|
|
133
|
+
|
|
92
134
|
Alternatively, you can use other C compilers like `gcc` or `zig` by specifying the compiler with the `--c-compiler` flag.
|
|
93
135
|
|
|
94
136
|
### Linux liburing Requirement
|
|
@@ -109,33 +151,69 @@ $ sudo dnf install liburing-devel
|
|
|
109
151
|
$ sudo pacman -S liburing
|
|
110
152
|
```
|
|
111
153
|
|
|
154
|
+
## Quick Start
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
$ yo init my-project # Scaffold a new project
|
|
158
|
+
$ cd my-project
|
|
159
|
+
$ yo build run # Build and run
|
|
160
|
+
Hello, world!
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
`yo init` generates a project with a build file, source, and tests:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
my-project/
|
|
167
|
+
├── build.yo # Build configuration
|
|
168
|
+
├── src/
|
|
169
|
+
│ ├── main.yo # Entry point
|
|
170
|
+
│ └── lib.yo # Library module
|
|
171
|
+
└── tests/
|
|
172
|
+
└── main.test.yo # Unit tests
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`src/main.yo`:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
{ println } :: import "std/fmt";
|
|
179
|
+
|
|
180
|
+
main :: (fn() -> unit)({
|
|
181
|
+
println("Hello, world!");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
export main;
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Common build commands:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
$ yo build # Build all artifacts
|
|
191
|
+
$ yo build run # Build and run the executable
|
|
192
|
+
$ yo build test # Run tests
|
|
193
|
+
$ yo build --list-steps # List available build steps
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Prelude
|
|
197
|
+
|
|
198
|
+
Every Yo file automatically imports **[std/prelude.yo](./std/prelude.yo)**, which provides the core types, traits, and builtins available without any explicit import:
|
|
199
|
+
|
|
200
|
+
- **Primitive types**: `bool`, `i8`–`i64`, `u8`–`u64`, `f32`, `f64`, `isize`, `usize`, `str`
|
|
201
|
+
- **C-compatible types**: `int`, `uint`, `short`, `long`, `longlong`, `char`, etc.
|
|
202
|
+
- **Core traits**: `Eq`, `Ord`, `Add`, `Sub`, `Mul`, `Div`, `Iterator`, `IntoIterator`, `TryFrom`, `TryInto`, `Dispose`, `Send`, `Rc`, `Acyclic`, etc.
|
|
203
|
+
- **Metaprogramming**: `Type`, `Expr`, `ExprList`, `Var`
|
|
204
|
+
- **Async**: `IO`, `FutureState`, `JoinHandle`
|
|
205
|
+
- **Utilities**: `assert`, `unsafe`, `try`, `for`, `not`, `arc`, `Box`, `box`
|
|
206
|
+
- etc.
|
|
207
|
+
|
|
112
208
|
## Standard Library
|
|
113
209
|
|
|
114
210
|
_Still In Design_
|
|
115
211
|
|
|
116
|
-
Yo ships with a comprehensive standard library covering strings, collections, file I/O, networking, encoding, regex, crypto, and more. For the full module reference, see **[Standard Library Modules](./docs/STD_LIBRARY_MODULES.md)**.
|
|
117
|
-
|
|
118
|
-
Key modules include:
|
|
119
|
-
|
|
120
|
-
| Module | Import | Description |
|
|
121
|
-
| ----------- | ------------------------------------------------------- | ----------------------------------------------------------- |
|
|
122
|
-
| String | `import "std/string"` | UTF-8 strings with parsing, search, transform |
|
|
123
|
-
| Collections | `import "std/collections/array_list"`, `hash_map`, etc. | ArrayList, HashMap, HashSet, BTreeMap, Deque, PriorityQueue |
|
|
124
|
-
| File System | `import "std/fs/file"` | Async file I/O, directories, metadata |
|
|
125
|
-
| Networking | `import "std/net/tcp"` | TCP/UDP sockets, DNS resolution |
|
|
126
|
-
| HTTP | `import "std/http"` | HTTP types, async client, `fetch` function |
|
|
127
|
-
| JSON | `import "std/encoding/json"` | Full JSON parser/stringifier |
|
|
128
|
-
| TOML | `import "std/encoding/toml"` | TOML config file parser |
|
|
129
|
-
| Regex | `import "std/regex"` | Regular expression engine |
|
|
130
|
-
| Crypto | `import "std/crypto/sha256"` | SHA-256, MD5, random |
|
|
131
|
-
| URL | `import "std/url"` | URL parsing and formatting |
|
|
132
|
-
| Glob | `import "std/glob"` | Unix-style glob pattern matching |
|
|
133
|
-
| Log | `import "std/log"` | Leveled logging |
|
|
134
|
-
| Formatting | `import "std/fmt"` | `print`, `println` for any `ToString` type |
|
|
212
|
+
Yo ships with a comprehensive standard library covering strings, collections, file I/O, networking, encoding, regex, crypto, and more. For the full module reference, see **[Standard Library Modules](./docs/en-US/STD_LIBRARY_MODULES.md)**.
|
|
135
213
|
|
|
136
214
|
## Code examples
|
|
137
215
|
|
|
138
|
-
Check the [./tests](./tests/) and [./std](./std/) folders for code examples.
|
|
216
|
+
Check the [./tests](./tests/) and [./std](./std/) folders for more code examples.
|
|
139
217
|
|
|
140
218
|
### Hello World
|
|
141
219
|
|
|
@@ -153,7 +231,15 @@ export main;
|
|
|
153
231
|
// $ ./main
|
|
154
232
|
```
|
|
155
233
|
|
|
156
|
-
|
|
234
|
+
### Example Projects
|
|
235
|
+
|
|
236
|
+
| Project | Description |
|
|
237
|
+
| ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
238
|
+
| [raylib_yo](https://github.com/shd101wyy/raylib_yo) | Comprehensive [raylib](https://www.raylib.com/) bindings — 35 struct types, 535 functions, 227 constants |
|
|
239
|
+
| [tetris_yo](https://github.com/shd101wyy/tetris_yo) | Classic Tetris game built with raylib_yo, demonstrating Yo's build system and C interop |
|
|
240
|
+
| [http_server_demo_yo](https://github.com/shd101wyy/http_server_demo_yo) | Simple HTTP/1.1 server — async I/O, algebraic effects, TCP networking, request parsing & routing |
|
|
241
|
+
|
|
242
|
+
## Contributing
|
|
157
243
|
|
|
158
244
|
The `Yo` compiler is written in [TypeScript](https://www.typescriptlang.org/) and uses [Bun](https://bun.sh/) as the runtime.
|
|
159
245
|
|