示例#1
0
        public override void EnterEveryRule([NotNull] ParserRuleContext context)
        {
            var name = context.GetType().Name;

            if (name.EndsWith("Context", StringComparison.InvariantCultureIgnoreCase))
            {
                name = name.Remove(name.IndexOf("Context", StringComparison.InvariantCultureIgnoreCase));
            }
            Logger.Info(string.Format("ENTER:{0}{1}", new string('\t', context.Depth()), name));
        }
 static void PrintContext(ParserRuleContext context)
 {
     if (context == null)
     {
         return;
     }
     Log.Write($"{new string(' ', (context.Depth() - 1) * 4)}{context.GetType().Name} [{context.start.Line}, {context.start.Column}] {context.GetText()}");
     foreach (var child in context.children)
     {
         PrintContext(child as ParserRuleContext);
     }
 }
示例#3
0
 public static void Context(ParserRuleContext ctx, LogEventLevel level = LogEventLevel.Debug)
 {
     Log.Write(
         level,
         "[{Depth}:{ContextType}] [{SourceInterval}] | children: {ChildrenCount} | {Code}",
         ctx.Depth(),
         ctx.GetType().Name,
         ctx.SourceInterval,
         ctx.ChildCount,
         ctx.GetText()
         );
 }
示例#4
0
        public override void ExitEveryRule([NotNull] ParserRuleContext context)
        {
            var name = context.GetType().Name;

            if (name.EndsWith("Context", StringComparison.InvariantCultureIgnoreCase))
            {
                name = name.Remove(name.IndexOf("Context", StringComparison.InvariantCultureIgnoreCase));
            }
            Logger.Info(string.Format("EXIT :{0:#####}{1}{2}: {3}", context.start.Line, new string('\t', context.Depth()), name, context.GetText()));
        }