Modularise lexer framework