diff --git a/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java b/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java index 91ebc32ce..0540189d2 100644 --- a/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java +++ b/tool/src/org/antlr/v4/semantics/BasicSemanticChecks.java @@ -290,6 +290,11 @@ public class BasicSemanticChecks extends GrammarTreeVisitor { void checkGrammarName(Token nameToken) { String fullyQualifiedName = nameToken.getInputStream().getSourceName(); + if (fullyQualifiedName == null) { + // This wasn't read from a file. + return; + } + File f = new File(fullyQualifiedName); String fileName = f.getName(); if ( g.originalGrammar!=null ) return; // don't warn about diff if this is implicit lexer