As far as I know, linguists determine grammaticality by judgement tests. Native speakers are presented with several types of utterances and, based on their intuition, they can judge each of these utterances as being grammatical or ungrammatical.
But languages like Latin and Gothic, for example, are not spoken natively by anyone anymore. So, does it make sense to talk about grammaticality for dead languages?