Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RASTElement"/> class.
 /// </summary>
 /// <param name="nodeType">Type of the node.</param>
 public RASTElement(NodeType nodeType, RASTElement parent, NodeType nodeCategory)
 {
     m_nodeType     = nodeType;
     m_nodeCategory = nodeCategory;
     m_parent       = parent;
     m_serialNumber = m_serialNumberCounter++;
     m_label        = nodeType.ToString() + "_" + m_serialNumber;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the child to the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="child">The child.</param>
        /// <param name="pos">The position.</param>
        public virtual void AddChild(RASTElement child, ContextType context = ContextType.CT_NA, int pos = -1)
        {
            if (context == ContextType.CT_NA)
            {
                throw new Exception("ERROR!!! Invalid context type");
            }
            int contextIndex = RConfigurationSettings.m_contextTypeConfiguration[context].M_ContextIndex;

            AddChild(child, contextIndex, pos);
        }
Exemplo n.º 3
0
        public RASTComposite(NodeType nodeType, RASTElement parent,
                             NodeType nodeCategory = NodeType.NT_NA) : base(nodeType, parent, nodeCategory)
        {
            M_NumberOfContexts = RConfigurationSettings.m_nodeTypeConfiguration[nodeType].M_NumberOfContexts;

            // Instanciate the contextual IR
            m_descentands = new List <RASTElement> [M_NumberOfContexts];
            for (int j = 0; j < M_NumberOfContexts; j++)
            {
                m_descentands[j] = new List <RASTElement>();
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// AddChild method inserts a child at the given context to the specified location
 /// The location given by the pos parameter can take one of the following values
 /// 1) -1 to indicate the last element of the list
 /// 2) a positive integer indicating any position in the list where if it equals to
 ///    m_descentands[context].Count, it is placed at the end of the list as in option 1
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="child">The child.</param>
 /// <param name="pos">The position.</param>
 /// <exception cref="IndexOutOfRangeException">
 /// Error! Negative index in array reference
 /// or
 /// Error! Negative index in array reference
 /// </exception>
 protected override void AddChild(RASTElement child, int context, int pos = -1 /*insert last by default*/)
 {
     if (pos == -1)
     {
         m_descentands[context].Add(child);
     }
     else if (pos > -1)
     {
         if (pos <= m_descentands[context].Count)
         {
             m_descentands[context].Insert(pos, child);
         }
         else
         {
             throw new IndexOutOfRangeException("Error! Negative index in array reference");
         }
     }
     else
     {
         throw new IndexOutOfRangeException("Error! Negative index in array reference");
     }
 }
Exemplo n.º 5
0
 protected abstract void AddChild(RASTElement child, int context, int pos = -1 /*insert last by default*/);
Exemplo n.º 6
0
 public RASTLeaf(string literal, NodeType nodetype, RASTElement parent,
                 NodeType nodeCategory = NodeType.NT_LEAF) : base(nodetype, parent, nodeCategory)
 {
     m_TokenLiteral = literal;
     m_label       += "< " + m_TokenLiteral + " >";
 }