| I was referring to the bash-completion project, the default on Debian/Ubuntu - https://github.com/scop/bash-completion/ But yes, ble.sh also has a shell parser in shell, although it uses a state machine style that's more principled than bash regex / sed crap. --- Also, distro build systems like Alpine Linux and others tend to parse shell in shell (or with sed). They often need package metadata without executing package builds, so they do that by trying to parse shell. In YSH, you will be able to do that with reflection, basically like Lisp/Python/Ruby, rather than ad hoc parsing. --- I'm glad to hear you can see the effect of the optimizations ! That took a long time :-) Some more benchmarks here, which I'll write about: https://oils.pub/release/0.33.0/benchmarks.wwz/osh-runtime/ |
That's the way to go. I don't even consider other shallow and ad-hoc approaches as actually parsing it.
I've been working on a state-machine based parser of my own. It's hard, I'm targetting very barebones interpreters such as posh and dash. Here's what it looks like
https://gist.github.com/alganet/23df53c567b8a0bf959ecbc7b689...
(not fully working example, but it gives an idea of what pure POSIX shell parsing looks like, ignore the aliases, they'll not be in the final version).
> I'm glad to hear you can see the effect of the optimizations ! That took a long time :-)
Yep, been testing osh since 0.9! Still a long way to go to catch up with ksh93 though, it's the fastest of all shells (even dash) by a wide margin.
By beating bash, you also have beaten zsh (it's one of the slowest shells around).