public virtual void SetFormat(string formatName)
{
this.formatName = formatName;
string fileName = Path.Combine(FORMATS_DIR, formatName + TemplateGroup.GroupFileExtension);
if (!File.Exists(fileName) && formatName != "antlr")
{
SetFormat("antlr");
return;
}
//format.EnableCache = AntlrTool.EnableTemplateCache;
if (!File.Exists(fileName))
{
RawError("ANTLR installation corrupted; cannot find ANTLR messages format file " + fileName);
Panic();
}
//else if (url == null)
//{
// RawError("no such message format file " + fileName + " retrying with default ANTLR format");
// SetFormat("antlr"); // recurse on this rule, trying the default message format
// return;
//}
format = new TemplateGroupFile(
Path.Combine(
Path.GetDirectoryName(typeof(AntlrTool).GetTypeInfo().Assembly.Location),
fileName),
Encoding.UTF8);
format.Load();
if (initSTListener.Errors.Count > 0)
{
RawError("ANTLR installation corrupted; can't load messages format file:\n" +
initSTListener.ToString());
Panic();
}
bool formatOK = VerifyFormat();
if (!formatOK && formatName.Equals("antlr"))
{
RawError("ANTLR installation corrupted; ANTLR messages format file " + formatName + ".stg incomplete");
Panic();
}
else if (!formatOK)
{
SetFormat("antlr"); // recurse on this rule, trying the default message format
}
}