[Toybox] [PATCH] awk -- more patches

Rob Landley rob at landley.net
Fri Nov 1 14:39:20 PDT 2024


On 11/1/24 00:29, Oliver Webb wrote:
> On Thursday, October 31st, 2024 at 18:35, Ray Gardner <raygard at gmail.com> wrote:
> 
>> I know you want little perfect bonsai; not always possible. awk will be
>> big,
> 
>> bc will be big,
> 
> Note: If you only care about the linux kernel,
> whatever primitives the arbitrary precision library
> uses could theoretically be replaced with 64-bit
> math while still building the kernel.

Last I checked 
https://landley.net/bin/mkroot/latest/linux-patches/0004-Replace-timeconst.bc-with-mktimeconst.c.patch 
still builds the kernel, and I could do my own arbitrary precision math 
library if I needed to. I've had to make fixed point and shift-and-add 
math work over in j-core, it's not that hard.

But as with awk, it's "learning an entire language I have no immediate 
use for", including all the corner cases, and I need to get back to 
finishing bash->toysh before even looking at that.

> That'd easily take off
> a few thousand LOC. But it'd also remove all special
> functionality from bc.
> 
>> yacc will be big
> 
> I have actually stumbled upon a small POSIX yacc
> (It's unfortunately 2-Clause BSD) that seems to do
> its job in 1200 LOC:
> 
> https://c9x.me/yacc/

Sounds ballpark of right. :)

Yacc and lex are two more commands that I just never needed. I think 
it's part of the "mathematician vs plumber" divide in programming, which 
I've always been on the plumber side of. I've never seen how yacc is 
supposed to HELP making parsers. It just adds steps and intermediate 
files. (But I felt the same way about autoconf...)

> I don't know if the linux-kernel specifically requires
> GNU Bison or if it will build under any random yacc.

It didn't USED to need yacc or lex (and shipped generated files in the 
kconfig directory to enforce that), until they made kconfig turing 
complete in 2019.

Rob


More information about the Toybox mailing list