You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Tokay homepage [tokay.dev](https://tokay.dev) provides links to a quick start and documentation. The documentation source code is maintained in a [separate repository](https://github.com/tokay-lang/tokay-docs).
199
199
200
+
## Debugging
201
+
202
+
For debugging, there are two methods to use.
203
+
204
+
### Tracing using the `log`-crate
205
+
206
+
For Rust standard trace, use the [`env_logger` facilities](https://docs.rs/env_logger/latest/env_logger/). Full trace is only compiled into debug executables, the release version only provides warning level and upwards.
207
+
208
+
```
209
+
$ RUST_LOG=tokay=debug tokay
210
+
```
211
+
212
+
Alternatively, tracing can be activated for the `__main__`-program by setting `TOKAY_LOG`. This is used to start tracing when the internal parser has been compiled and executed already, and parsed the actual program. `TOKAY_LOG` can be set to any `RUST_LOG`-compliant format, as it becomes `RUST_LOG` right after.
213
+
214
+
```
215
+
$ TOKAY_LOG=tokay=debug tokay
216
+
```
217
+
218
+
### Built-in AST and VM debugger using `TOKAY_DEBUG` and `TOKAY_PARSER_DEBUG`
219
+
220
+
Set `TOKAY_DEBUG` to a debug level between 1-6. This can also be achieved using `tokay -dddd` where every `d` increments the debug level. Additionally, `TOKAY_INSPECT` can be set to one or a list of parselet name (-prefixes) which should be inspected in VM step-by-step trace (`TOKAY_DEBUG=6`).
221
+
222
+
| Level | Mode |
223
+
| ----- | --------------------------------- |
224
+
| 0 | No debug |
225
+
| 1 | Print constructed AST |
226
+
| 2 | Print final intermediate program |
227
+
| 3 | Print compiled VM program |
228
+
| 4 | Print VM execution trace |
229
+
| 5 | Print VM stack contents |
230
+
| 6 | VM opcode debugger |
231
+
232
+
`TOKAY_PARSER_DEBUG` sets the specific debug level for the parser, which is implemented in Tokay itself and is part of the compiler. Only levels > 2 can be recognized here, as the AST of the parser is built into the code.
233
+
200
234
## Logo
201
235
202
236
The Tokay programming language is named after the [Tokay gecko (Gekko gecko)](https://en.wikipedia.org/wiki/Tokay_gecko) from Asia, shouting out "token" in the night.
0 commit comments