public virtual IList<Grammar> GetAllImportedGrammars()
{
if (importedGrammars == null)
{
return null;
}
LinkedHashMap<string, Grammar> delegates = new LinkedHashMap<string, Grammar>();
foreach (Grammar d in importedGrammars)
{
delegates[d.fileName] = d;
IList<Grammar> ds = d.GetAllImportedGrammars();
if (ds != null)
{
foreach (Grammar imported in ds)
{
delegates[imported.fileName] = imported;
}
}
}
return new List<Grammar>(delegates.Values);
}
public virtual void GenerateATNs(Grammar g) { DOTGenerator dotGenerator = new DOTGenerator(g); IList<Grammar> grammars = new List<Grammar>(); grammars.Add(g); IList<Grammar> imported = g.GetAllImportedGrammars(); if (imported != null) { foreach (Grammar importedGrammar in imported) grammars.Add(importedGrammar); } foreach (Grammar ig in grammars) { foreach (Rule r in ig.rules.Values) { try { string dot = dotGenerator.GetDOT(g.atn.ruleToStartState[r.index], g.IsLexer()); if (dot != null) { WriteDOTFile(g, r, dot); } } catch (IOException ioe) { errMgr.ToolError(ErrorType.CANNOT_WRITE_FILE, ioe); } } } }