What would second implementation of Zig need to compile/bootstrap Zig?

For example, in src/codegen/llvm/bindings.zig, Zig does not need @cImport and translate-c. Any second implementaion requiring binary blobs like stage1/zig1.wasm or stage1/wasm2c.c do not count.

Here’s @andrewrk’s answer:

Some more details from the compiler development Zulip:

i.e. a bespoke interpreter for bootstrapping zig 0.13.0. and then when 0.14.0 comes out it gets updated to be able to interpret exactly that source

I bet such an interpreter could operate directly on AST

and it wouldn’t really have to differentiate between comptime and runtime :slight_smile:

My attempt at clarifying after I continually misunderstood the idea:

  • the end goal is for the interpreter to take the compiler source code and run it without the intermediate steps in the “zig → wasm → c → compile zig1 → run zig1” chain. In other words, running the interpreter on the compiler source code should basically do what the compiled zig1 does, and the expected output is actually the same as the zig1-generated zig2.c since it’s the result of running zig1
    • put another way, this is not a zig → c transpiler, that just happens to be the output when running zig1 with the arguments it’s passed
    • in other other words, an interpreter…
  • so, for the hello world, the expected result is Hello World printed to stdout (as mentioned)
5 Likes

Don’t you have a secret lua-based tokenizer somewhere? :wink:

1 Like

Yeah, been sidetracked with other stuff and want to get a proof-of-concept interpreter that can run “hello world” working before I make it public.

1 Like