public ParserFile(OutputModelFactory factory, string fileName) : base(factory, fileName) { Grammar g = factory.GetGrammar(); namedActions = BuildNamedActions(factory.GetGrammar()); genPackage = g.tool.genPackage; exportMacro = factory.GetGrammar().GetOptionString("exportMacro"); // need the below members in the ST for Python, C++ genListener = g.tool.gen_listener; genVisitor = g.tool.gen_visitor; grammarName = g.name; if (g.GetOptionString("contextSuperClass") != null) { contextSuperClass = new ActionText(null, g.GetOptionString("contextSuperClass")); } }
protected Recognizer(OutputModelFactory factory) : base(factory) { Grammar g = factory.GetGrammar(); grammarFileName = Path.GetFileName(g.fileName); grammarName = g.name; name = g.GetRecognizerName(); tokens = new LinkedHashMap <string, int>(); foreach (KeyValuePair <string, int> entry in g.tokenNameToTypeMap) { int ttype = entry.Value; if (ttype > 0) { tokens[entry.Key] = ttype; } } ruleNames = g.rules.Keys; rules = g.rules.Values; atn = new SerializedATN(factory, g.atn, g.GetRuleNames()); if (g.GetOptionString("superClass") != null) { superClass = new ActionText(null, g.GetOptionString("superClass")); } else { superClass = null; } #pragma warning disable CS0612 // Type or member is obsolete tokenNames = TranslateTokenStringsToTarget(g.GetTokenDisplayNames(), factory); #pragma warning restore CS0612 // Type or member is obsolete literalNames = TranslateTokenStringsToTarget(g.GetTokenLiteralNames(), factory); symbolicNames = TranslateTokenStringsToTarget(g.GetTokenSymbolicNames(), factory); abstractRecognizer = g.IsAbstract(); }