Skip to content

Commit 034d1d2

Browse files
committed
docs: actualize docs
1 parent 8b325cc commit 034d1d2

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ Here are some of them with syntax highlighting from the [LO VS Code extension](#
6464
2️⃣ Using wasmtime
6565

6666
- Install [wasmtime](https://github.com/bytecodealliance/wasmtime)
67-
- Compiling files: `wasmtime --dir=. lo.wasm <input>.lo > <output>.wasm`
68-
- Getting diagnostics (in json format): `wasmtime --dir=. lo.wasm <input>.lo --inspect`
67+
- Compiling files: `wasmtime --dir=. lo.wasm compile <input>.lo > <output>.wasm`
68+
- Getting diagnostics (in json format): `wasmtime --dir=. lo.wasm inspect <input>.lo`
6969

7070
---
7171

docs/README.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ Documentation of LO language features.
2626
- [(info) Error reporting](#info-error-reporting)
2727
- [Compiling](#compiling)
2828
- [Inspecting code (IDE intergration)](#inspecting-code-ide-intergration)
29-
- [Pretty Printing](#pretty-printing)
29+
- [Formatting](#formatting)
3030
- [(experimental) Interpreting source code](#experimental-interpreting-source-code)
31-
- [(experimental) Interpreting WASM modules](#experimental-interpreting-wasm-modules)
31+
- [(experimental) Interpreting WASM modules (supports small WASI subset)](#experimental-interpreting-wasm-modules-supports-small-wasi-subset)
3232
- [Comment rearrangement](#comment-rearrangement)
3333
- [🧪 Compiler development](#-compiler-development)
3434
- [Building the initial compiler](#building-the-initial-compiler)
@@ -42,8 +42,8 @@ Top level expressions are only allowed at the top level of the file (not inside
4242

4343
```lo
4444
fn add(x: u32, y: u32): u32 {
45-
return a + b;
46-
};
45+
return a + b
46+
}
4747
```
4848

4949
#### Exporting functions
@@ -52,7 +52,7 @@ Function can be exported from WASM module like this:
5252

5353
```lo
5454
export fn main(): u32 {
55-
return 0;
55+
return 0
5656
}
5757
```
5858

@@ -61,7 +61,7 @@ export fn main(): u32 {
6161
### Include
6262

6363
```lo
64-
include "./file.lo";
64+
include "./file.lo"
6565
```
6666

6767
Include pathes are relative to the file they are included to.
@@ -73,8 +73,8 @@ File paths are fully resolved before including.
7373
Example:
7474

7575
```lo
76-
include "./abc.lo"; // will include
77-
include "./some-folder/../abc.lo"; // will skip
76+
include "./abc.lo" // will include
77+
include "./some-folder/../abc.lo" // will skip
7878
```
7979

8080
## 🧑‍💻 Code Expressions
@@ -95,7 +95,7 @@ Int literals are always fully typed, there is no generic "number" type that will
9595
### Return expressions
9696

9797
```lo
98-
return 123;
98+
return 123
9999
```
100100

101101
> Expression type: `never`
@@ -124,8 +124,8 @@ Binary operators require both operands to be of the same type.
124124

125125
```lo
126126
if x < 0 {
127-
return 1;
128-
};
127+
return 1
128+
}
129129
```
130130

131131
> Expression type: `void`
@@ -143,13 +143,13 @@ if x < 0 {
143143
// positive
144144
} else {
145145
// zero
146-
};
146+
}
147147
```
148148

149149
### Function calls
150150

151151
```lo
152-
add(2, 2);
152+
add(2, 2)
153153
```
154154

155155
> Expression type: same as function return type
@@ -175,8 +175,8 @@ Only `//` comments are supported for now.
175175
// this is a comment
176176
fn main(): u32 {
177177
// this is another comment
178-
return 0;
179-
};
178+
return 0
179+
}
180180
```
181181

182182
Comments are allowed between any tokens, but they might get moved during formatting. See [Pretty Printing](#pretty-printing) for more info.
@@ -196,13 +196,12 @@ wasmtime --dir=. lo.wasm
196196
This should print something like the following:
197197

198198
```text
199-
Usage: lo <file> [<mode>]
200-
Where <mode> is either:
201-
--compile (default if not provided)
202-
--inspect
203-
--pretty-print
204-
--eval (experimental)
205-
--eval-wasm (experimental)
199+
Usage:
200+
lo compile <input.lo>
201+
lo inspect <input.lo>
202+
lo format <input.lo>
203+
lo eval <input.lo> (experimental)
204+
lo wasi <input.lo> (experimental)
206205
```
207206

208207
---
@@ -216,13 +215,13 @@ Usage: lo <file> [<mode>]
216215
Compiler errors are printed to `<stderr>` using the following format:
217216

218217
```text
219-
<file-path>:<line>:<col> - <message>
218+
[ERROR|WARNING] <file-path>:<line>:<col> - <message>
220219
```
221220

222221
### Compiling
223222

224223
```bash
225-
lo input.lo
224+
lo compile input.lo
226225
```
227226

228227
> Compiles `input.lo` file into a WASM module
@@ -234,23 +233,24 @@ lo input.lo
234233
### Inspecting code (IDE intergration)
235234

236235
```bash
237-
lo input.lo --inspect
236+
lo inspect input.lo
238237
```
239238

240239
> Prints inspection info of `input.lo` file in JSON format. Useful for IDE integrations.
241240
>
242241
> `<stdout>` - JSON object with inspection results
242+
> NOTE: during inspection errors are reported in JSON format as well so stderr will be empty
243243
244244
Inspection object schema is defined as `DiagnisticItem` in [VSCode extension sources](../vscode-ext/src/extension.ts)
245245

246-
### Pretty Printing
246+
### Formatting
247247

248248
> NOTE: this formats a single file at a time, imported files are not formatted
249249
250250
Usage:
251251

252252
```bash
253-
lo input.lo --pretty-print
253+
lo format input.lo
254254
```
255255

256256
> Formats `input.lo` using non-configurable formatting style
@@ -262,19 +262,19 @@ lo input.lo --pretty-print
262262
Usage:
263263

264264
```bash
265-
lo input.lo --eval
265+
lo eval input.lo
266266
```
267267

268268
> Compiles `input.lo` and interprets the WASM module built (without producing any intermediate files). Supports a subset of WASI. Entrypoint is either `_start` or `main`.
269269
>
270270
> `<stdout>` - Interpreted program output (if any). In case of `main` entrypoint the function's result is printed.
271271
272-
### (experimental) Interpreting WASM modules
272+
### (experimental) Interpreting WASM modules (supports small WASI subset)
273273

274274
Usage:
275275

276276
```bash
277-
lo input.wasm --eval-wasm
277+
lo wasi input.wasm
278278
```
279279

280280
> Parses and interprets `input.wasm`. Supports a subset of WASI. Entrypoint is either `_start` or `main`.
@@ -295,8 +295,8 @@ fn main():
295295
// this will be moved
296296
u32 { // this will also be moved
297297
// this is fine
298-
return 0; // this will also be moved
299-
};
298+
return 0 // this will also be moved
299+
}
300300
```
301301

302302
Will get formatted as:
@@ -307,9 +307,9 @@ fn main(): u32 {
307307
// this will be moved
308308
// this will also be moved
309309
// this is fine
310-
return 0;
310+
return 0
311311
// this will also be moved
312-
};
312+
}
313313
```
314314

315315
## 🧪 Compiler development

examples/test/demos/wasm4/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ A collection of example games written in LO for the [WASM-4](https://wasm4.org)
77
Run any of the samples:
88

99
```shell
10-
wasmtime --dir=. lo.wasm examples/test/demos/wasm4/src/dark-maze.lo | npx wasm4 run -n -
10+
wasmtime --dir=. lo.wasm compile examples/test/demos/wasm4/src/dark-maze.lo | npx wasm4 run -n -
1111
```
1212

1313
## Building cart files
1414

1515
To build the cart file run:
1616

1717
```shell
18-
wasmtime --dir=. lo.wasm examples/test/demos/wasm4/src/dark-maze.lo > cart.wasm
18+
wasmtime --dir=. lo.wasm compile examples/test/demos/wasm4/src/dark-maze.lo > cart.wasm
1919
```

0 commit comments

Comments
 (0)