This is a script called m5.awk that I randomly found after reading a paper about it on the ACM website. The paper’s worth reading too but the script is just a piece of work. Commented to the brim, clean, and most importantly, useful as hell. it could be a replacement for m4. It allows you to embed AWK in text files, and besides that, it allows you to use several preprocessng features that it offers via macros. Give it a try.

  • ChubakPDP11+TakeWithGrainOfSalt@programming.devOP
    link
    fedilink
    arrow-up
    3
    arrow-down
    6
    ·
    7 months ago

    I forgot to mention, tools like Bison and Autoconf use m4. Andrew Appel calls languages that need preprocessing ‘weak’. The specs for D also call C ‘weak’ for needing to be preprocessed. Preprocessing is almost an abandoned practice, at least in the world of programming, because Scheme-like ‘hygenic macros’ have taken their place. Some languages like Rust and Zig are attempting to reinvent the wheel by re-inventing macros, but Scheme had it right in the 70s. Truly, C and Pascal’s preprocessor were out the door in the 70s, let alone, now.

    Here’s another preprocessor that is 'neat: GPP.

    I have made my own preprocessor, it’s very nasty and has a lot of bugs because I was an idiot when I made it: https://github.com/Chubek/Ekipp

    I have half a mind to remake Ekipp. I don’t know what purpose would it serve. But it’s just neat, I think preprocessors are neat, as useless as they are.