Inheritance: GrammarTreeVisitor
Ejemplo n.º 1
0
        /** Given list of X and r refs in alt, compute how many of each there are */
        protected virtual System.Tuple <FrequencySet <string>, FrequencySet <string> > GetElementFrequenciesForAlt(AltAST ast)
        {
            try
            {
                ElementFrequenciesVisitor visitor = new ElementFrequenciesVisitor(rule.g, new CommonTreeNodeStream(new GrammarASTAdaptor(), ast));
                visitor.outerAlternative();
                if (visitor.frequencies.Count != 1)
                {
                    factory.GetGrammar().tool.errMgr.ToolError(ErrorType.INTERNAL_ERROR);
                    return(Tuple.Create(new FrequencySet <string>(), new FrequencySet <string>()));
                }

                return(Tuple.Create(visitor.GetMinFrequencies(), visitor.frequencies.Peek()));
            }
            catch (RecognitionException ex)
            {
                factory.GetGrammar().tool.errMgr.ToolError(ErrorType.INTERNAL_ERROR, ex);
                return(Tuple.Create(new FrequencySet <string>(), new FrequencySet <string>()));
            }
        }
Ejemplo n.º 2
0
        /** Given list of X and r refs in alt, compute how many of each there are */
        protected virtual System.Tuple<FrequencySet<string>, FrequencySet<string>> GetElementFrequenciesForAlt(AltAST ast)
        {
            try
            {
                ElementFrequenciesVisitor visitor = new ElementFrequenciesVisitor(rule.g, new CommonTreeNodeStream(new GrammarASTAdaptor(), ast));
                visitor.outerAlternative();
                if (visitor.frequencies.Count != 1)
                {
                    factory.GetGrammar().tool.errMgr.ToolError(ErrorType.INTERNAL_ERROR);
                    return Tuple.Create(new FrequencySet<string>(), new FrequencySet<string>());
                }

                return Tuple.Create(visitor.GetMinFrequencies(), visitor.frequencies.Peek());
            }
            catch (RecognitionException ex)
            {
                factory.GetGrammar().tool.errMgr.ToolError(ErrorType.INTERNAL_ERROR, ex);
                return Tuple.Create(new FrequencySet<string>(), new FrequencySet<string>());
            }
        }