misc changes to lexer; also introduce code to encode numbers with arbitrary base and custom digits