The source of RISC OS was opened up. https://www.riscosopen.org/viewer/view/castle/RiscOS/Sources... shows part of the BASIC module which has pedigree going back to when Sophie Wilson, designer of the ARM instruction set, wrote it.
But then you've got to remember that Sophie Wilson wrote the 16KiB 6502 BASIC interpreter for the BBC micro, and the BASIC for the Z80 second processor IIRC, and then brought that experience to bear when designing the ARM instruction set. Having done so, she then wrote BBC BASIC V in ARM; hardly surprising if it knew every little nuance and could wring speed out of it.
In later years, the BBC BASIC code, 6502 and ARM, were good stress tests for emulators because of her wide use of the instruction sets.