@shd101wyy/yo 0.0.31 → 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 +109 -18
- package/out/cjs/index.cjs +890 -1002
- package/out/cjs/yo-cli.cjs +954 -1069
- package/out/esm/index.mjs +786 -898
- package/out/types/src/build-runner.d.ts +3 -1
- package/out/types/src/codegen/codegen-c.d.ts +2 -0
- package/out/types/src/codegen/exprs/asm.d.ts +4 -0
- package/out/types/src/codegen/index.d.ts +10 -0
- package/out/types/src/codegen/utils/index.d.ts +1 -0
- package/out/types/src/evaluator/builtins/asm.d.ts +13 -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 +6 -2
- package/out/types/src/fetch.d.ts +1 -0
- package/out/types/src/module-manager.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/std/{toml → encoding}/toml.yo +6 -1
- package/std/http/client.yo +359 -0
- package/std/http/index.yo +22 -0
- package/std/log/{log.yo → index.yo} +2 -2
- package/std/regex/{regex.yo → index.yo} +1 -1
- package/std/url/{url.yo → index.yo} +2 -2
- /package/std/glob/{glob.yo → index.yo} +0 -0
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).
|
|
@@ -24,7 +50,7 @@ Below is a non-exhaustive list of features that Yo supports:
|
|
|
24
50
|
- `object` type with [Non-atomic Reference Counting and Thread-Local Cycle Collection](./docs/en-US/CYCLE_COLLECTION.md).
|
|
25
51
|
- [Compile-time Reference Counting with Ownership and Lifetime Analysis](./docs/en-US/COMPILE_TIME_RC_WITH_OWNERSHIP_ANALYSIS.md).
|
|
26
52
|
- Thread-per-core parallelism model (see [PARALLELISM.md](./docs/en-US/PARALLELISM.md)).
|
|
27
|
-
- [Declarative build system](./docs/en-US/BUILD_SYSTEM.md) inspired by Zig (`yo build`, `yo init`, cross-compilation
|
|
53
|
+
- [Declarative build system](./docs/en-US/BUILD_SYSTEM.md) inspired by Zig (`yo build`, `yo init`, cross-compilation).
|
|
28
54
|
- **C** interop.
|
|
29
55
|
- etc.
|
|
30
56
|
|
|
@@ -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,28 +151,69 @@ $ sudo dnf install liburing-devel
|
|
|
109
151
|
$ sudo pacman -S liburing
|
|
110
152
|
```
|
|
111
153
|
|
|
112
|
-
##
|
|
154
|
+
## Quick Start
|
|
113
155
|
|
|
114
|
-
|
|
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:
|
|
115
164
|
|
|
116
|
-
|
|
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
|
+
```
|
|
117
174
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
+
|
|
208
|
+
## Standard Library
|
|
209
|
+
|
|
210
|
+
_Still In Design_
|
|
211
|
+
|
|
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)**.
|
|
130
213
|
|
|
131
214
|
## Code examples
|
|
132
215
|
|
|
133
|
-
Check the [./tests](./tests/) and [./std](./std/) folders for code examples.
|
|
216
|
+
Check the [./tests](./tests/) and [./std](./std/) folders for more code examples.
|
|
134
217
|
|
|
135
218
|
### Hello World
|
|
136
219
|
|
|
@@ -148,7 +231,15 @@ export main;
|
|
|
148
231
|
// $ ./main
|
|
149
232
|
```
|
|
150
233
|
|
|
151
|
-
|
|
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
|
|
152
243
|
|
|
153
244
|
The `Yo` compiler is written in [TypeScript](https://www.typescriptlang.org/) and uses [Bun](https://bun.sh/) as the runtime.
|
|
154
245
|
|