-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wishlist: use a template language for code generation #113
Comments
I guess I should mention why I thought that particular implementation might be a good fit. The Mustache documentation is all written with the assumption that you'll pass JSON to your template processor, which isn't really what I'd want for this. But the |
Jamey and I chatted briefly about this. The main points were:
Taking on this area is something I had a previous go at, but decided to leave. I was thinking about code generation for TenDRA's lexi at the time. If I do revisit considering tempting, it's definitely a system I'd want to apply for all my code generation in various projects, which is all quite similar to in this repository. Meanwhile the printfing is cumbersome, but isn't actually much trouble for maintenance. So that's why it's here. I'm closing this ticket because it's discussion that applies to many projects - and because it's something I can't figure out how to do without it being an unwieldy project in itself. |
For future reference in case anyone else stumbles across this, I agree with Kate's summary, but I would like to add a couple more comments. I literally had a nightmare just last night about getting the spaces right in these My primary interest in this issue is that there's no way With that in mind, and considering Kate's quite solid points about the difficulty of providing a usable templating language for this purpose... Probably what I really want is an interchange file format that people can consume from their language of choice and do their own codegen however they prefer to do it. Pretty-printing libraries and ASTs are a lot easier to manipulate in languages with automatic memory management, anyway. So I agree with closing this issue, in favor of exploring #118 more. |
I find files like
src/lx/print/c.c
difficult to read and maintain due to complicated sequences offprintf
calls which obscure the structure of the code that's being generated. I speculate that using a simple templating language would make the code generation process easier to understand. Perhaps the templates would even be a useful public interface tolx
, so users could write their own templates without having to recompilelx
.Although I haven't used it, there is a C implementation of the Mustache templating language that looks to me like it might work perfectly here. For Mustache syntax see https://mustache.github.io/ and for the C implementation check out https://gitlab.com/jobol/mustach.
The text was updated successfully, but these errors were encountered: