yacc (pre-bison) parser to bash script. jq implementation in bash

Sometimes there is a problem to write a small smart script that understands some built-in grammar, that is, with a mini-language inside. I originally wrote a minimal implementation of jq in bash. But the more “cleverness” was added there, the more difficult it was to implement recursive parsing of subexpressions. It was so annoying that it made me write the LARL(1) yacc (pre-bison) compiler first to generate a bash script, and then, like clockwork, it turned out to be very similar to the original and a good test code for yacc_bash.c mini-jq on bash.

Full article:

Source: linux.org.ru

Add a comment