Refactor tm_parser_format_function: merge double `switch (lang)` (#3463)