Refactor string and regex specification in javascript grammar