John Machin wrote: > Use a proper lexer written by somebody who knows what they are doing, > as has already been recommended to you. My lexer returns a MALFORMED_NUMBER token on '0x' or '0x '. Try that in Python.