/** <summary>Override this method to change where error messages go</summary> */
 public virtual void EmitErrorMessage(string msg)
 {
     if (TraceDestination != null)
     {
         TraceDestination.WriteLine(msg);
     }
 }
        /** <summary>
         *  Record whether or not this rule parsed the input at this position
         *  successfully.  Use a standard java hashtable for now.
         *  </summary>
         */
        public virtual void Memoize(IIntStream input,
                                    int ruleIndex,
                                    int ruleStartIndex)
        {
            int stopTokenIndex = state.failed ? MemoRuleFailed : input.Index - 1;

            if (state.ruleMemo == null)
            {
                if (TraceDestination != null)
                {
                    TraceDestination.WriteLine("!!!!!!!!! memo array is null for " + GrammarFileName);
                }
            }
            if (ruleIndex >= state.ruleMemo.Length)
            {
                if (TraceDestination != null)
                {
                    TraceDestination.WriteLine("!!!!!!!!! memo size is " + state.ruleMemo.Length + ", but rule index is " + ruleIndex);
                }
            }
            if (state.ruleMemo[ruleIndex] != null)
            {
                state.ruleMemo[ruleIndex][ruleStartIndex] = stopTokenIndex;
            }
        }
        public virtual void TraceIn(string ruleName, int ruleIndex, object inputSymbol)
        {
            if (TraceDestination == null)
            {
                return;
            }

            TraceDestination.Write("enter " + ruleName + " " + inputSymbol);
            if (state.backtracking > 0)
            {
                TraceDestination.Write(" backtracking=" + state.backtracking);
            }
            TraceDestination.WriteLine();
        }
        public virtual void TraceOut(string ruleName, int ruleIndex, object inputSymbol)
        {
            if (TraceDestination == null)
            {
                return;
            }

            TraceDestination.Write("exit " + ruleName + " " + inputSymbol);
            if (state.backtracking > 0)
            {
                TraceDestination.Write(" backtracking=" + state.backtracking);
                if (state.failed)
                {
                    TraceDestination.Write(" failed");
                }
                else
                {
                    TraceDestination.Write(" succeeded");
                }
            }
            TraceDestination.WriteLine();
        }
Example #5
0
        public void LogTest()
        {
            var destination = new TraceDestination()
            {
                AutoCommit = false,
                Level      = (int)EventSeverity.Verbose,
                WriteTrace = true
            };

            using (var logger = new LoggerClass("TraceDestinationTests"))
            {
                logger.Destinations.Add(destination);

                logger.NotifyInformation("Information");

                logger.Notify((int)EventSeverity.Verbose - 1, () => { return("Not be logged"); });

                int count = destination.LogList.Count;

                Assert.AreEqual(1, count);
            }
        }
Example #6
0
 /// <summary>
 /// Set's the tracing destination
 /// </summary>
 /// <param name="dest">trace destination</param>
 private static void SetDestination(TraceDestination dest)
 {
     sm_Destination = dest;
 }