Hey list, I'm evolving what I consider "best practices". My latest efforts:
https://github.com/bottle2/swf2c/blob/master/movies.m4 Item separators are annoying: - C90 doesn't allow a trailing comma after the last enumerator in an enum - A Ragel union takes the form "a | b | c | ... | n" - I don't like trailing backslashes in the last line of a multi-line Makefile macro definition Sometimes you can get away with excess separators, such as in "+ a + b + c" where the first plus becomes an unary plus. I'm generating separators "to the left", then I simply chop the excess separator using m4 substr. Previously, I wrote a ton of boring m4 macro "machinery" to cautiously place and expand macros between items. I also considered using dummy neutral elements such as a trailing dummy enumerator or the "empty" Ragel machine which cannot be ever matched. I'm also now formatting code using nroff, relying significantly on tbl. Until then, I wasted a lot of time writing extensive "machinery" to calculate whitespace production, too often fighting with macros expanding too little or too early. nroff doesn't reliably produce tab characters nor ASCII hyphen-minus, which is crucial for Makefile. So I borrowed the concept of quadrigraphs from autoconf. No problem. troff escape sequences \N'9' and \N'45' are inconvenient due to requiring typing an apostrophe. So I think I'm now equipped to write rather compact self-contained and useful m4 code generators with reduced maintenance burden. I have some further ideas I want to put to test, I'll share my findings soon. Once I find myself forced to generate Rust code, I might shitpost on LinkedIn. Best regards, Bento
