Пример #1
0
 // Get the Nth entry.
 public MHParseNode GetArgN(int n)
 {
     if (m_nNodeType == PNTagged)
     {
         MHPTagged pTag = (MHPTagged)this;
         if (n < 0 || n >= pTag.Args.Size)
         {
             Failure("Argument not found");
         }
         return(pTag.Args.GetAt(n));
     }
     else if (m_nNodeType == PNSeq)
     {
         MHParseSequence pSeq = (MHParseSequence)this;
         if (n < 0 || n >= pSeq.Size)
         {
             Failure("Argument not found");
         }
         return(pSeq.GetAt(n));
     }
     else
     {
         Failure("Expected tagged value");
     }
     return(null); // To keep the compiler happy
 }
Пример #2
0
        // Get an argument with a specific tag.  Returns NULL if it doesn't exist.
        // There is a defined order of tags for both the binary and textual representations.
        // Unfortunately they're not the same.
        public MHParseNode GetNamedArg(int nTag)
        {
            MHParseSequence pArgs = null;

            if (m_nNodeType == PNTagged)
            {
                pArgs = ((MHPTagged)this).Args;
            }
            else if (m_nNodeType == PNSeq)
            {
                pArgs = (MHParseSequence)this;
            }
            else
            {
                Failure("Expected tagged value or sequence");
            }
            for (int i = 0; i < pArgs.Size; i++)
            {
                MHParseNode p = pArgs.GetAt(i);
                if (p != null && p.NodeType == PNTagged && ((MHPTagged)p).TagNo == nTag)
                {
                    return(p);
                }
            }
            return(null);
        }
Пример #3
0
        public MHParseNode GetSeqN(int n)
        {
            if (m_nNodeType != PNSeq)
            {
                Failure("Expected sequence");
            }
            MHParseSequence pSeq = (MHParseSequence)this;

            if (n < 0 || n >= pSeq.Size)
            {
                Failure("Argument not found");
            }
            return(pSeq.GetAt(n));
        }