https://github.com/kevinpt/opbasm/blob/master/opbasm/picobla...
Michael Breen's notes are indispensable documentation on how to make effective use of the language.
.. (just a snip follows)
`define(`_'''$`'1```_LENGTH',strlenc(''$`'2``))'dnl
`; "''$`'2``"'
`ifdef(`PB3', ''$`'1```: calltable($4, $1, estr('''$`'2```))dnl
return',dnl
`table '''$`'1```#, [dec2pbhex(cstr('''$`'2```))]
'''$`'1```: loadaddr($2, $3, _'''$`'1```_STR)
jump __`'$5`'_handler
_'''$`'1```_STR: load&return $1, '''$`'1```#')'
)')'
I have to ask if this is right, or whether a parser would have been a whole lot less work. Credit for your skillz, but that looks like so much pain.FWIW I didn't intend for things to go this far. I just started with some simple macros and it snowballed.
I'm told the person who took over that codebase was equal parts perplexed and horrified by it. They ripped out the m4 code generation and just put the generated files directly in the source tree. As the codebase had stabilized, the purpose that m4 served was basically gone.
So, not still in use, but if I found myself in the same situation today, I'd explore other options and consider doing the same thing. Interface default methods might cover some of the need at this point, but it's so far back, I'm hazy on the details.
The nice thing about doing this sort of code generation with m4 rather than the C preprocessor is that m4 preserves formatting (like line breaks) a lot better. Even if you're not using any of the other functionality of m4 (and there's a lot), that alone makes figuring out where things went wrong easier.
After tying everything together with make, I could include plots for any parameter as I was writing the report and have the relevant data generated as necessary. All without re-running simulations that had already produced results.
Thankfully I never used it in context of sendmail or autotools, so no reason to hate it for me, I guess.