glsl: Refactor code to check that identifier names are valid.