Get the latest tech news

Parsing Awk Is Tricky


A somewhat compact implementation of the awk programming language

Apparently nawk, gawk, mawk, and goawk work as follows (bbawk gets a syntax error): in$$0++, the$0 is"2 3 4" but the++ forces it numeric, as 2, so the post-increment applies to$0 which sets the entire record to 3. Once again, the original One True Awk’s behavior seems inconsistent and not easily discernible from the yacc grammar, nor from the documentation. I don’t know much about yacc yet, but I understand it’s basically an LALR(1) parser generator, but with additional features to resolve what would otherwise be ambiguities.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Tricky

Tricky

Photo of Parsing Awk

Parsing Awk