In some programming languages, there are built-in code builders, which can be very useful for generating boilerplate code.
Does Zig have something similar?
References:
In Golang with go/ast
In Java with sun.codemodel
In some programming languages, there are built-in code builders, which can be very useful for generating boilerplate code.
Does Zig have something similar?
References:
In Golang with go/ast
In Java with sun.codemodel
It would be better if the API could be simpler and more user-friendly, similar to GitHub - square/javapoet: A Java API for generating .java source files..
Hi @whisper-bye !
It sounds like you are asking about metaprograming, like how Rust macros are used to generate/Expand to correct rust code by manipulating the AST.
In zig that is one of the roles of comptime code. rather than having to learn a different sub language, you just write in zig, asserting values and expressions to be comptime as needed. I’m no expert in comptime so i’m not sure if it covers all the usecases that you might be thinking of. What are you wanting to do that you are trying to reach for an AST manipulator?
Hi, My question is not related to metaprogramming. I just want to know if Zig has built-in support for generating boilerplate code, similar to what is mentioned in the reference links.
The relative package is std.zig
Start with Ast.parse and Ast.render.