I recently wrote an AWK interpreter in Go: https://github.com/benhoyt/goawk
It's a pretty simple implementation: hand-rolled lexer, recursive-descent
parser, and tree-walk interpreter. It's pretty complete according to the
POSIX spec, and it passes the AWK ("one true awk") test suite as well as my
own unit tests.
In some quick tests I ran, I/O speed is on a par or better than AWK but the
interpreter itself is quite slow -- about 5x slower for a lot of things. I
hope to add some proper benchmarks soon. I have a pretty good of why and
how to fix it: variable lookup and assignment is slow, and I'm planning to
fix by resolving more things at parse time.
One thing that's a bit funky about AWK is its type handling: string values
can be real strings or "numeric strings" (numbers that came from user
input). I'm currently passing the "value" struct (see interp/value.go)
around by value. I still need to test if that's a good idea
performance-wise or not.
I'd love to hear any comments, bug reports, or -- especially -- code
reviews.
-Ben
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.