BasicSemanticChecks.checkGrammarName: allow null filenames.

checkGrammarName assumes that all grammars come from actual files, but
grammars loaded using Tool.parseGrammarFromString use input streams
without source file names. This patch changes checkGrammarName to only verify
that grammar names and file names correspond when a file name is
available.
This commit is contained in:
Kyle Kingsbury 2014-03-18 16:43:32 -07:00
parent c0dda79dff
commit a74005972d
1 changed files with 5 additions and 0 deletions

View File

@ -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