6 ms·
awkcc: awk-to-C transcompiler (1988, 2011)
- gompertz 5y agoI actually have this code compiling and running from a few months back with some minor compiler corrections; but was hesitant to release to github because of the copyright. It was very difficult to come across. I asked several people at Bell/Nokia if it would be okay to release and they weren't sure if anyone cared (but couldn't guarantee anything legally) ... Looks like they took the liberty themselves... I'll try to find time to do a PR or fork of this copy with my corrections and writeup for instructions. Imagine it's best I just fork as can't fathom Nokia is going to approve PRs.
- mustache_kimono 5y agoCurious: What kind of performance is gained by this over just using awk?
- gompertz 5y agoProbably extremely minimal if any; especially with all the advances in Mawk/Gawk since 1988. The only immediate advantage being you can essentially turn your Awk into a compiled exe with Awkcc. However it's important to note that this is so old it only works with the original Bell Labs Awk. Previously compiling directly from Awk to an executable was only possible with Tawk (commercial version of Awk by Thompson Automation... And long defunct).
- gompertz 5y agoFor those that are interested, here is my compiling fork.... shorturl.at/tO036
- tyingq 5y agolinux build: Lex needs to be run on Solaris machine. awk.lx.c is built on solaris, then modified by hand to remove the static initialization of yyin and yyout. That kind of situation is a fun throwback.
- cogburnd02 5y agoInterested parties should also check out awka (https://github.com/noyesno/awka https://github.com/noyesno/awka) and ELVM (which can compile C into awk or sed, among various other things) (https://github.com/shinh/elvm https://github.com/shinh/elvm)
- sanxiyn 5y ago> which can compile C into awk or sed, among various other things What did I just read? Thanks a lot for letting us know about ELVM. Much appreciated.
- cogburnd02 5y ago> What did I just read? It can compile C into BF, too. So....that's a thing.
- benhoyt 5y agoInteresting! I recently did something similar based on my GoAWK interpreter (an AWK interpreter written in Go): I wrote a compiler that tries to statically infer types and compile a subset of AWK to Go source: https://benhoyt.com/writings/awkgo/ https://benhoyt.com/writings/awkgo/ My conclusion: > Is it useful? Not really. If you want performance, just use Mawk! And if you want your text processing script in a more maintainable language than AWK, you’d probably just write it in something like Go from the start. You’re pretty certain to end up with more idiomatic Go that way, and it’ll probably be more efficient as well. > Still, if you have some AWK scripts lying around that you want to convert to “real programs”, AWKGo might not be a bad place to start: you could compile a script to Go to get the structure, then clean it up and maintain the cleaned-up version.
- watersb 5y agoI love AWK for some dead-simple borderlands between sed and Perl (or worse). But the performance can be a problem with associative arrays.
- deeg 5y agoA long time ago MKS Utilities had an awk compiler that would compile an awk script into a Windows exe. Dunno if it actually compiled anything or just packaged the awk interpreter onto the exe. That was my first intro to awk. Was nice to be able to write a script that I could send to people who didn't have awk.