# compiler: introduce ZonGen and make \`ast-check\` run it for ZON inputs · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/c7485d73ac3e6dd105c6ee8fcf774493cc9eb31e)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: c7485d73ac3e6dd105c6ee8fcf774493cc9eb31e

Requested commit: c7485d73ac3e6dd105c6ee8fcf774493cc9eb31e

Commit: c7485d73ac3e6dd105c6ee8fcf774493cc9eb31e

Tree: 0312df770a62af9cc5bf2f36d865df189ff21a2f

Author: mlugg

Committer: mlugg

## Message

```
compiler: introduce ZonGen and make `ast-check` run it for ZON inputs

Currently, `zig ast-check` fails on ZON files, because it tries to
interpret the file as Zig source code. This commit introduces a new
verification pass, `std.zig.ZonGen`, which applies to an AST in ZON
mode.

Like `AstGen`, this pass also converts the AST into a more helpful
format. Rather than a sequence of instructions like `Zir`, the output
format of `ZonGen` is a new datastructure called `Zoir`. This type is
essentially a simpler form of AST, containing only the information
required for consumers of ZON. It is also far more compact than
`std.zig.Ast`, with the size generally being comparable to the size of
the well-formatted source file.

The emitted `Zoir` is currently not used aside from the `-t` option to
`ast-check` which causes it to be dumped to stdout. However, in future,
it can be used for comptime `@import` of ZON files, as well as for
simpler handling of files like `build.zig.zon`, and even by other parts
of the Zig Standard Library.

Resolves: #22078

```

## Parents

- [d12c0bf90911339c8db0741b257eac251b827b2c](https://git.cafe/gitcafe/zig/commit/d12c0bf90911339c8db0741b257eac251b827b2c?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/c7485d73ac3e6dd105c6ee8fcf774493cc9eb31e?format=markdown)
