Refactor number lexing; part of #5688