public override void ConsumeNode(object t)
        {
            int    ID   = adaptor.GetUniqueID(t);
            string text = adaptor.GetText(t);
            int    type = adaptor.GetType(t);

            Console.Out.WriteLine("consumeNode " + ID + " " + text + " " + type);
        }
Example #2
0
        public virtual object LT(int i)
        {
            object node = input.LT(i);
            int    ID   = adaptor.GetUniqueID(node);
            string text = adaptor.GetText(node);
            int    type = adaptor.GetType(node);

            dbg.LT(i, node);
            return(node);
        }
Example #3
0
        public override void LT(int i, object t)
        {
            int           ID   = adaptor.GetUniqueID(t);
            string        text = adaptor.GetText(t);
            int           type = adaptor.GetType(t);
            StringBuilder buf  = new StringBuilder(50);

            buf.Append("LN\t"); // lookahead node; distinguish from LT in protocol
            buf.Append(i);
            SerializeNode(buf, t);
            Transmit(buf.ToString());
        }
Example #4
0
        protected void ExtractInformationFromTreeNodeStream(IIntStream input)
        {
            ITreeNodeStream nodes = (ITreeNodeStream)input;

            this.node = nodes.LT(1);
            ITreeAdaptor adaptor = nodes.TreeAdaptor;
            IToken       payload = adaptor.GetToken(node);

            if (payload != null)
            {
                this.token = payload;
                if (payload.Line <= 0)
                {
                    // imaginary node; no line/pos info; scan backwards
                    int    i         = -1;
                    object priorNode = nodes.LT(i);
                    while (priorNode != null)
                    {
                        IToken priorPayload = adaptor.GetToken(priorNode);
                        if ((priorPayload != null) && (priorPayload.Line > 0))
                        {
                            // we found the most recent real line / pos info
                            this.line = priorPayload.Line;
                            this.charPositionInLine  = priorPayload.CharPositionInLine;
                            this.approximateLineInfo = true;
                            break;
                        }
                        --i;
                        priorNode = nodes.LT(i);
                    }
                }
                else
                {
                    // node created from real token
                    this.line = payload.Line;
                    this.charPositionInLine = payload.CharPositionInLine;
                }
            }
            else if (this.node is ITree)
            {
                this.line = ((ITree)this.node).Line;
                this.charPositionInLine = ((ITree)this.node).CharPositionInLine;
                if (this.node is CommonTree)
                {
                    this.token = ((CommonTree)this.node).Token;
                }
            }
            else
            {
                int    type = adaptor.GetType(this.node);
                string text = adaptor.GetText(this.node);
                this.token = new CommonToken(type, text);
            }
        }
Example #5
0
 public virtual string GetText(object t)
 {
     return(adaptor.GetText(t));
 }