public GrammarRootAST parse(String fileName, CharStream in) {
		try {
			GrammarASTAdaptor adaptor = new GrammarASTAdaptor(in);
			ToolANTLRLexer lexer = new ToolANTLRLexer(in, this);
			CommonTokenStream tokens = new CommonTokenStream(lexer);
			lexer.tokens = tokens;
			ToolANTLRParser p = new ToolANTLRParser(tokens, this);
			p.setTreeAdaptor(adaptor);
			ParserRuleReturnScope r = p.grammarSpec();
			GrammarAST root = (GrammarAST) r.getTree();
			if (root instanceof GrammarRootAST) {
				((GrammarRootAST) root).hasErrors = lexer.getNumberOfSyntaxErrors() > 0 || p.getNumberOfSyntaxErrors() > 0;
				assert ((GrammarRootAST) root).tokenStream == tokens;
				if (grammarOptions != null) {
					((GrammarRootAST) root).cmdLineOptions = grammarOptions;
				}
				return ((GrammarRootAST) root);
			}
			return null;
		}
		catch (RecognitionException re) {
			// TODO: do we gen errors now?
			ErrorManager.internalError("can't generate this message at moment; antlr recovers");
		}
		return null;
	}
Try current dir then dir of g then lib dir
@param g
@param nameNode The node associated with the imported grammar name.
tool/src/org/antlr/v4/Tool.java