1
1
12rbah2021-02-04 17:17:13
Programming
12rbah, 2021-02-04 17:17:13

What can you read about writing code generators?

I would like to know if there is such literature at all, if there is a binding to the language, it would be desirable that it be c-like (but in general it is not very important), I will also be very glad to articles and advice.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-02-04
@12rbah

It will be different for each language. In C and C++, macros are also code generators, in principle.
In general, the principle is this: We take some data, files, source code, run some code generator program on it, which will process this data and create new source files.
Here is about C# source generators: https://devblogs.microsoft.com/dotnet/introducing-...
Here is about T4: https://docs.microsoft.com/en-us/visualstudio/mode...
Here is about code generation in go: https://golang.org/pkg/cmd/go/internal/generate/
rust has declarative and procedural macros that also generate code.
The concept is so terribly simple, I don’t know what you can write about it in books.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question