Extracted most C code from lexer into matchedXXX() functions.

Changed decodeUTF8() to take uint8_t const * instead of unsigned char const *.