@shd101wyy/yo 0.1.0 → 0.1.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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  <img src="./Yo_logo.png" width=96 height=96 />
4
4
 
5
+ **English** | [简体中文](./docs/zh-CN/README.md)
6
+
5
7
  **Work in Progress :) Not Ready!**
6
8
 
7
9
  A multi-paradigm, general-purpose, compiled programming language.
@@ -17,14 +19,10 @@ Yo aims to be **Simple** and **Fast** (around 0% - 15% slower than C).
17
19
 
18
20
  - [Features](#features)
19
21
  - [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
- - [pkg-config / vcpkg Requirement](#pkg-config--vcpkg-requirement)
25
- - [Installing pkg-config (Linux)](#installing-pkg-config-linux)
26
- - [Installing pkgconf (macOS)](#installing-pkgconf-macos)
27
- - [Installing vcpkg (Windows)](#installing-vcpkg-windows)
22
+ - [Linux](#linux)
23
+ - [macOS](#macos)
24
+ - [Windows](#windows)
25
+ - [WebAssembly (WASM)](#webassembly-wasm)
28
26
  - [Quick Start](#quick-start)
29
27
  - [Prelude](#prelude)
30
28
  - [Standard Library](#standard-library)
@@ -77,37 +75,44 @@ There is also an alias `yo-cli` for `yo` command in case of naming conflicts.
77
75
 
78
76
  Run `yo --help` or `yo-cli --help` to see available commands.
79
77
 
80
- ### C Compiler Requirement
81
-
82
- Yo currently transpiles to C and requires a C compiler to produce machine code. **Clang is recommended** for the best experience.
78
+ Yo transpiles to C, so a **C compiler** is required to produce machine code. Follow the instructions for your platform below.
83
79
 
84
- #### Installing Clang
80
+ ### Linux
85
81
 
86
- **Linux:**
82
+ Install **Clang** (recommended), **liburing** (for async I/O), and **pkg-config** (for system library discovery):
87
83
 
88
84
  ```bash
89
85
  # Ubuntu/Debian
90
86
  $ sudo apt-get update
91
- $ sudo apt-get install clang
87
+ $ sudo apt-get install clang liburing-dev pkg-config
92
88
 
93
89
  # Fedora/RHEL
94
- $ sudo dnf install clang
90
+ $ sudo dnf install clang liburing-devel pkgconf-pkg-config
95
91
 
96
92
  # Arch Linux
97
- $ sudo pacman -S clang
93
+ $ sudo pacman -S clang liburing pkgconf
98
94
  ```
99
95
 
100
- **macOS:**
96
+ You can also use `gcc` or `zig` instead of `clang` by passing `--cc gcc` or `--cc zig`.
97
+
98
+ ### macOS
99
+
100
+ Clang is included with Xcode Command Line Tools:
101
101
 
102
102
  ```bash
103
- # Clang is included with Xcode Command Line Tools
104
103
  $ xcode-select --install
105
104
 
106
- # Or install via Homebrew
107
- $ brew install llvm
105
+ # Also install pkgconf for system library discovery
106
+ $ brew install pkgconf
107
+ ```
108
+
109
+ Or install LLVM via Homebrew:
110
+
111
+ ```bash
112
+ $ brew install llvm pkgconf
108
113
  ```
109
114
 
110
- **Windows:**
115
+ ### Windows
111
116
 
112
117
  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:
113
118
 
@@ -128,72 +133,46 @@ $ scoop install llvm
128
133
  Alternatively, you can use `zig` as the C compiler (no Visual Studio needed):
129
134
 
130
135
  ```bash
131
- # Using Chocolatey
132
136
  $ choco install zig
133
-
134
- # Then compile with:
135
- $ yo compile main.yo --c-compiler zig --release -o main
137
+ $ yo compile main.yo --cc zig --release -o main
136
138
  ```
137
139
 
138
- Alternatively, you can use other C compilers like `gcc` or `zig` by specifying the compiler with the `--c-compiler` flag.
139
-
140
- ### Linux liburing Requirement
141
-
142
- On Linux, Yo uses `io_uring` for async I/O, which requires **liburing** to be installed.
143
-
144
- #### Installing liburing (Linux)
140
+ For system library discovery, install **vcpkg**:
145
141
 
146
142
  ```bash
147
- # Ubuntu/Debian
148
- $ sudo apt-get update
149
- $ sudo apt-get install liburing-dev
150
-
151
- # Fedora/RHEL
152
- $ sudo dnf install liburing-devel
143
+ $ git clone https://github.com/microsoft/vcpkg.git
144
+ $ .\vcpkg\bootstrap-vcpkg.bat
145
+ # Then set the VCPKG_ROOT environment variable to the vcpkg directory
153
146
 
154
- # Arch Linux
155
- $ sudo pacman -S liburing
147
+ # Or using Scoop
148
+ $ scoop install vcpkg
156
149
  ```
157
150
 
158
- ### pkg-config / vcpkg Requirement
159
-
160
- Yo's build system uses **pkg-config** (on Linux and macOS) or **vcpkg** (on Windows) to discover system C libraries when linking with external dependencies.
161
-
162
- #### Installing pkg-config (Linux)
163
-
164
- ```bash
165
- # Ubuntu/Debian
166
- $ sudo apt-get update
167
- $ sudo apt-get install pkg-config
168
-
169
- # Fedora/RHEL
170
- $ sudo dnf install pkgconf-pkg-config
151
+ For more information, see the [vcpkg documentation](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started).
171
152
 
172
- # Arch Linux
173
- $ sudo pacman -S pkgconf
174
- ```
153
+ ### WebAssembly (WASM)
175
154
 
176
- #### Installing pkgconf (macOS)
155
+ Yo can compile to WebAssembly using [Emscripten](https://emscripten.org/):
177
156
 
178
157
  ```bash
179
- # Homebrew
180
- $ brew install pkgconf
181
- ```
158
+ # Install Emscripten (https://emscripten.org/docs/getting_started/downloads.html)
159
+ $ git clone https://github.com/emscripten-core/emsdk.git
160
+ $ cd emsdk
161
+ $ ./emsdk install latest
162
+ $ ./emsdk activate latest
163
+ $ source ./emsdk_env.sh
182
164
 
183
- #### Installing vcpkg (Windows)
165
+ # Compile a Yo program to WASM
166
+ $ yo compile main.yo --cc emcc --release -o app
184
167
 
185
- ```bash
186
- # Using Git
187
- $ git clone https://github.com/microsoft/vcpkg.git
188
- $ .\vcpkg\bootstrap-vcpkg.bat
168
+ # This produces: app.html + app.js + app.wasm
169
+ # Run with Node.js:
170
+ $ node app.js
189
171
 
190
- # Then set the VCPKG_ROOT environment variable to the vcpkg directory
191
-
192
- # Or using Scoop
193
- $ scoop install vcpkg
172
+ # Or open app.html in a browser
194
173
  ```
195
174
 
196
- For more information, see the [vcpkg documentation](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started).
175
+ When using `--cc emcc`, Yo automatically targets `wasm32-emscripten` and uses the `libc` allocator. You can also use `--target wasm-emscripten` (which auto-selects `emcc`). Emscripten produces an `.html` file (browser shell), a `.js` file (runtime glue), and a `.wasm` file (compiled binary).
197
176
 
198
177
  ## Quick Start
199
178
 
@@ -288,7 +267,7 @@ export main;
288
267
  The `Yo` compiler is written in [TypeScript](https://www.typescriptlang.org/) and uses [Bun](https://bun.sh/) as the runtime.
289
268
 
290
269
  Yo is primarily developed on the Steam Deck LCD (Linux). The compiler currently transpiles Yo to C; to produce
291
- machine code you must have a C compiler (for example `gcc`, `clang`, `zig`, `cl`, etc).
270
+ machine code you must have a C compiler (for example `gcc`, `clang`, `zig`, `cl`, `emcc`, etc).
292
271
 
293
272
  Please install [nix](https://nixos.org/download.html) and [direnv](https://direnv.net/) before proceeding.
294
273