This example seems like it requires a parser, not just a lexer:
function identity<Type>(arg: Type): Type {
return arg;
}
let output = identity<string>("myString");
Without knowing what comes after < in the last line, it seems to be impossible to tell if it's a comparison operator or a generics declaration.