Пример #1
0
        public static bool InRule(this ParserRuleContext parserContext, RuleContextType contextType)
        {
            RuleContext current = parserContext.Parent;

            while (current != null)
            {
                if (current.GetType().Name.ToUpper() == contextType.ToString())
                {
                    return(true);
                }
                current = current.Parent;
            }
            return(false);
        }
Пример #2
0
        public static RuleContext GoOutRule(this ParserRuleContext parserContext, RuleContextType contextType)
        {
            RuleContext current = parserContext;

            while (current != null)
            {
                if (current.GetType().Name.ToUpper() == contextType.ToString())
                {
                    return(current);
                }
                current = current.Parent;
            }
            return(null);
        }