3 ms·
That's really cool. I wrote a parser (and implementation for much of the semantics) for just sh; bash is much much bigger. Just figuring out how to do things
by aidenn0 10y ago
That's really cool. I wrote a parser (and implementation for much of the semantics) for just sh; bash is much much bigger.
Just figuring out how to do things like alias expansion (which actually requires relexing as the grammar is defined in the POSIX spec) and here documents in a formal grammar is such a pain that one quickly reaches for recursive decent parsing. I used what was ostensibly a PEG tool (esrap), but ended up using an undocumented escape hatch that let you call arbitrary functions for parsing subexpressions.
- chubot 10y agoCool, I'd be curious to see it! I actually wanted to bootstrap a shell in Lisp, inspired by the es shell [1] and so forth, but I decided against it after some experimentation. [1] https://wryun.github.io/es-shell/ https://wryun.github.io/es-shell/
- aidenn0 10y agohttps://github.com/jasom/plush https://github.com/jasom/plush It was never intended to be actually used. I mainly wrote this to learn more about sh. I realized that the bourne family of shells was not in my top 10 languages in terms of knowledge, but was typically in my top 3 languages in terms of use, and thought implementing just the minimal sh stuff would be a good way to learn.