[HN Gopher] An Awk Implementation in C99
___________________________________________________________________
An Awk Implementation in C99
Author : asicsp
Score : 83 points
Date : 2024-04-01 11:47 UTC (11 hours ago)
(HTM) web link (www.raygard.net)
(TXT) w3m dump (www.raygard.net)
| riedel wrote:
| Always good to see some love for the awk language. I, however
| l,went down the rabbit hole to find out about toybox and some
| background. Came back just puzzled (260 slides of slidedeck only
| for the message that it has a more permissive licence).
| throw0101b wrote:
| The second edition of _The AWK Programming Language_ by Aho,
| Kernighan, and Weinberger was just released in February:
|
| * https://awk.dev
|
| ToC and preface of the new edition:
|
| * https://awk.dev/pp1-13.pdf
| elvis70 wrote:
| It was in October or November, I think. The book doesn't add
| much to the first edition, I was quite deceived.
| benhoyt wrote:
| It's a second edition, not a new book -- why did you feel
| deceived? There's a fair bit of restructuring of the first
| few chapters, and a whole new chapter on exploratory data
| analysis (which uses the new CSV support) and a bunch of new
| stuff about the new Unicode-character support.
| abathur wrote:
| Oblique, but since this topic might be catnip for people who'd
| know:
|
| Anyone aware of a Python parser for the Awk language?
|
| I found a number of Awk-alikes implemented in Python, but they
| all sounded like they took enough liberties that I wouldn't
| expect them to have a parser worth trying to lean on to parse
| wild Awk scripts.
| nerdponx wrote:
| Is there a Tree Sitter grammar for AWK? That could be a good
| way to go, via the Python bindings for Tree Sitter.
| dwheeler wrote:
| Cool. Awk is a nice tool for semi-simple record-at-a-time
| processing.
|
| As far as I can tell, this implementation is much slower than
| other awks. Most awk implementations use a non-backtracking regex
| implementation (as do Rust and Go). By contrast, this seems to be
| using a backtracking implementation (e.g., like Perl and Python).
| For simplicity that makes sense, but for some regexes this kind
| of implementation can be many orders of magnitude slower.
|
| My guess is that this slowdown doesn't matter for a typical
| toybox user, where small code size is valued. Thanks for the
| link!
| shawn_w wrote:
| Looks like it uses the standard POSIX regular expression
| functions - regcomp() and regexec().
| UncleEntity wrote:
| Do you mean for the parser or the engine that does the awking?
|
| I was looking over the POSIX spec to see what's so difficult
| about parsing it and just kind of wondering.
| anthk wrote:
| You can write a Z-Machine interpreter in awk, a Tetris and with
| Gawk, even a gopher client.
| anthk wrote:
| I have a mirror of an awk-related gopher hole from an awk fan as
| sadly the former domain it's offline. Here's the github repo, but
| the author has nice addons such as a universal awk library with
| missing functions for awk (tan, bitwise ops...)
| https://git.sr.ht/~luxferre/
|
| Luckly, the AWK library it's used for a project:
|
| https://git.sr.ht/~luxferre/DALE-8A/blob/master/tgl.awk
|
| Also, there's a solitaire written in POSIX AWK:
|
| git://git.luxferre.top/nnfc.git
|
| His homepage:
|
| https://luxferre.top
| benhoyt wrote:
| I've chatted with Ray (the author of wak -- love the name) a few
| times about our respective AWK implementations. He's a nice guy
| and a really thoughtful programmer, and he even found several
| edge-case bugs in my GoAWK implementation:
| https://github.com/search?q=repo%3Abenhoyt%2Fgoawk+raygard&t...
___________________________________________________________________
(page generated 2024-04-01 23:01 UTC)