Exemplo n.º 1
0
        public object GetNilNode()
        {
            object node = adaptor.GetNilNode();

            dbg.GetNilNode(node);
            return(node);
        }
Exemplo n.º 2
0
 public void GetNilNode(object t)
 {
     for (int i = 0; i < listeners.Count; i++)
     {
         IDebugEventListener listener = (IDebugEventListener)listeners[i];
         listener.GetNilNode(t);
     }
 }
Exemplo n.º 3
0
 protected virtual void Dispatch(string line)
 {
     string[] elements = GetEventElements(line);
     if (elements == null || elements[0] == null)
     {
         Console.Error.WriteLine("unknown debug event: " + line);
         return;
     }
     if (elements[0].Equals("enterRule"))
     {
         listener.EnterRule(elements[1], elements[2]);
     }
     else if (elements[0].Equals("exitRule"))
     {
         listener.ExitRule(elements[1], elements[2]);
     }
     else if (elements[0].Equals("enterAlt"))
     {
         listener.EnterAlt(int.Parse(elements[1], CultureInfo.InvariantCulture));
     }
     else if (elements[0].Equals("enterSubRule"))
     {
         listener.EnterSubRule(int.Parse(elements[1], CultureInfo.InvariantCulture));
     }
     else if (elements[0].Equals("exitSubRule"))
     {
         listener.ExitSubRule(int.Parse(elements[1], CultureInfo.InvariantCulture));
     }
     else if (elements[0].Equals("enterDecision"))
     {
         listener.EnterDecision(int.Parse(elements[1], CultureInfo.InvariantCulture));
     }
     else if (elements[0].Equals("exitDecision"))
     {
         listener.ExitDecision(int.Parse(elements[1], CultureInfo.InvariantCulture));
     }
     else if (elements[0].Equals("location"))
     {
         listener.Location(int.Parse(elements[1], CultureInfo.InvariantCulture),
                           int.Parse(elements[2], CultureInfo.InvariantCulture));
     }
     else if (elements[0].Equals("consumeToken"))
     {
         ProxyToken t = DeserializeToken(elements, 1);
         if (t.TokenIndex == previousTokenIndex)
         {
             tokenIndexesInvalid = true;
         }
         previousTokenIndex = t.TokenIndex;
         listener.ConsumeToken(t);
     }
     else if (elements[0].Equals("consumeHiddenToken"))
     {
         ProxyToken t = DeserializeToken(elements, 1);
         if (t.TokenIndex == previousTokenIndex)
         {
             tokenIndexesInvalid = true;
         }
         previousTokenIndex = t.TokenIndex;
         listener.ConsumeHiddenToken(t);
     }
     else if (elements[0].Equals("LT"))
     {
         IToken t = DeserializeToken(elements, 2);
         listener.LT(int.Parse(elements[1], CultureInfo.InvariantCulture), t);
     }
     else if (elements[0].Equals("mark"))
     {
         listener.Mark(int.Parse(elements[1], CultureInfo.InvariantCulture));
     }
     else if (elements[0].Equals("rewind"))
     {
         if (elements[1] != null)
         {
             listener.Rewind(int.Parse(elements[1], CultureInfo.InvariantCulture));
         }
         else
         {
             listener.Rewind();
         }
     }
     else if (elements[0].Equals("beginBacktrack"))
     {
         listener.BeginBacktrack(int.Parse(elements[1], CultureInfo.InvariantCulture));
     }
     else if (elements[0].Equals("endBacktrack"))
     {
         int level    = int.Parse(elements[1], CultureInfo.InvariantCulture);
         int successI = int.Parse(elements[2], CultureInfo.InvariantCulture);
         //listener.EndBacktrack(level, successI == (int)true);
         listener.EndBacktrack(level, successI == 1 /*1=TRUE*/);
     }
     else if (elements[0].Equals("exception"))
     {
         string excName  = elements[1];
         string indexS   = elements[2];
         string lineS    = elements[3];
         string posS     = elements[4];
         Type   excClass = null;
         try
         {
             excClass = System.Type.GetType(excName);
             RecognitionException e = (RecognitionException)System.Activator.CreateInstance(excClass);
             e.Index = int.Parse(indexS, CultureInfo.InvariantCulture);
             e.Line  = int.Parse(lineS, CultureInfo.InvariantCulture);
             e.CharPositionInLine = int.Parse(posS, CultureInfo.InvariantCulture);
             listener.RecognitionException(e);
         }
         catch (System.UnauthorizedAccessException iae)
         {
             Console.Error.WriteLine("can't access class " + iae);
             Console.Error.WriteLine(iae.StackTrace);
         }
     }
     else if (elements[0].Equals("beginResync"))
     {
         listener.BeginResync();
     }
     else if (elements[0].Equals("endResync"))
     {
         listener.EndResync();
     }
     else if (elements[0].Equals("terminate"))
     {
         listener.Terminate();
     }
     else if (elements[0].Equals("semanticPredicate"))
     {
         bool   result        = bool.Parse(elements[1]);
         string predicateText = elements[2];
         predicateText = UnEscapeNewlines(predicateText);
         listener.SemanticPredicate(result, predicateText);
     }
     else if (elements[0].Equals("consumeNode"))
     {
         ProxyTree node = DeserializeNode(elements, 1);
         listener.ConsumeNode(node);
     }
     else if (elements[0].Equals("LN"))
     {
         int       i    = int.Parse(elements[1], CultureInfo.InvariantCulture);
         ProxyTree node = DeserializeNode(elements, 2);
         listener.LT(i, node);
     }
     else if (elements[0].Equals("createNodeFromTokenElements"))
     {
         int    ID   = int.Parse(elements[1], CultureInfo.InvariantCulture);
         int    type = int.Parse(elements[2], CultureInfo.InvariantCulture);
         string text = elements[3];
         text = UnEscapeNewlines(text);
         ProxyTree node = new ProxyTree(ID, type, -1, -1, -1, text);
         listener.CreateNode(node);
     }
     else if (elements[0].Equals("createNode"))
     {
         int ID         = int.Parse(elements[1], CultureInfo.InvariantCulture);
         int tokenIndex = int.Parse(elements[2], CultureInfo.InvariantCulture);
         // create dummy node/token filled with ID, tokenIndex
         ProxyTree  node  = new ProxyTree(ID);
         ProxyToken token = new ProxyToken(tokenIndex);
         listener.CreateNode(node, token);
     }
     else if (elements[0].Equals("nilNode"))
     {
         int       ID   = int.Parse(elements[1], CultureInfo.InvariantCulture);
         ProxyTree node = new ProxyTree(ID);
         listener.GetNilNode(node);
     }
     else if (elements[0].Equals("errorNode"))
     {
         int    ID   = int.Parse(elements[1], CultureInfo.InvariantCulture);
         int    type = int.Parse(elements[2], CultureInfo.InvariantCulture);
         String text = elements[3];
         text = UnEscapeNewlines(text);
         ProxyTree node = new ProxyTree(ID, type, -1, -1, -1, text);
         listener.ErrorNode(node);
     }
     else if (elements[0].Equals("becomeRoot"))
     {
         int       newRootID = int.Parse(elements[1], CultureInfo.InvariantCulture);
         int       oldRootID = int.Parse(elements[2], CultureInfo.InvariantCulture);
         ProxyTree newRoot   = new ProxyTree(newRootID);
         ProxyTree oldRoot   = new ProxyTree(oldRootID);
         listener.BecomeRoot(newRoot, oldRoot);
     }
     else if (elements[0].Equals("addChild"))
     {
         int       rootID  = int.Parse(elements[1], CultureInfo.InvariantCulture);
         int       childID = int.Parse(elements[2], CultureInfo.InvariantCulture);
         ProxyTree root    = new ProxyTree(rootID);
         ProxyTree child   = new ProxyTree(childID);
         listener.AddChild(root, child);
     }
     else if (elements[0].Equals("setTokenBoundaries"))
     {
         int       ID   = int.Parse(elements[1], CultureInfo.InvariantCulture);
         ProxyTree node = new ProxyTree(ID);
         listener.SetTokenBoundaries(node,
                                     int.Parse(elements[2], CultureInfo.InvariantCulture),
                                     int.Parse(elements[3], CultureInfo.InvariantCulture));
     }
     else
     {
         Console.Error.WriteLine("unknown debug event: " + line);
     }
 }
Exemplo n.º 4
0
        // AST Stuff

        public void GetNilNode(object t)
        {
            listener.GetNilNode(t);
        }