Пример #1
0
        public override void EnterEveryRule(ParserRuleContext context)
        {
            string typeName = context.GetType( ).Name;

            Push(new Node( )
            {
                Id       = context.GetUniqueNodeId( ),
                Label    = typeName.Substring(0, typeName.Length - ContextTypeNameSuffix.Length),
                Category = "TreeNode"
            });
        }
Пример #2
0
        public override void ExitEveryRule(ParserRuleContext context)
        {
            base.ExitEveryRule(context);

            ActiveNode.Properties.Add("Text", context.GetSourceText(Recognizer));
            ActiveNode.Properties.Add("RuleIndex", context.RuleIndex);
            ActiveNode.Properties.Add("SourceInterval", context.SourceInterval.ToString( ));
            if (context.exception != null)
            {
                ActiveNode.Category = "HasException";
                ActiveNode.Properties.Add("Exception", context.exception);
            }

            if (context.Parent != null)
            {
                Graph.Links.Add(new Link( )
                {
                    Source = context.Parent.GetUniqueNodeId( ),
                    Target = context.GetUniqueNodeId( )
                });
            }

            Pop( );
        }