Maybe some of the ideas I used here for a serial calculator would help out...
https://forum.arduino.cc/t/dont-cross-the-streams-fp-scientific-calculator-serial-co-processor/144054/12?u=mrburnette
Basically allows one to mix commands and numeric strings.