示例#1
0
        protected PegNode LessNodeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
        {
            if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
                if (parentOrCreated == null)
                    return new LessPegRootNode(id, src_);
                else
                    return new LessPegNode(parentOrCreated, id, GetRoot());

            return null;
        }
示例#2
0
 PegNode PrimitiveValueNodeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
 {
     if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
     {
         return(new PrimitiveValueNode(parentOrCreated, id));
     }
     else
     {
         return(null);
     }
 }
示例#3
0
 PegNode LengthNodeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
 {
     if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
     {
         return(new LengthNode(parentOrCreated, id));
     }
     else
     {
         ((LengthNode)parentOrCreated).lengthValue_ = top.length;
         return(null);
     }
 }
示例#4
0
 PegNode TagNodeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
 {
     if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
     {
         return(new TagNode(parentOrCreated, id));
     }
     else
     {
         ((TagNode)parentOrCreated).tagValue_ = top.tag;
         return(null);
     }
 }
示例#5
0
 void AddTreeNode(int nId, PegTree.AddPolicy newAddPolicy, Creator createNode, ECreatorPhase ePhase)
 {
     if (bMute_) return;
     if (tree.root_ == null)
     {
         tree.root_ = tree.cur_ = createNode(ePhase, tree.cur_, nId);
     }
     else if (tree.addPolicy == PegTree.AddPolicy.eAddAsChild)
     {
         tree.cur_ = tree.cur_.child_ = createNode(ePhase, tree.cur_, nId);
     }
     else
     {
         tree.cur_ = tree.cur_.next_ = createNode(ePhase, tree.cur_.parent_, nId);
     }
     tree.addPolicy = newAddPolicy;
 }
示例#6
0
 protected PegNode DefaultNodeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
 {
     if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
         return new PegNode(parentOrCreated, id);
     else return null;
 }
示例#7
0
     PegNode PrimitiveValueNodeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
     {
        if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
        {
            return new PrimitiveValueNode(parentOrCreated, id);
        }
        else
       {
         return null;
       }
 }
示例#8
0
	    PegNode LengthNodeCreator(ECreatorPhase phase,PegNode parentOrCreated, int id)
        {
            if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete){
                return new LengthNode(parentOrCreated, id);
            }else{
                ((LengthNode)parentOrCreated).lengthValue_ = top.length;
                return null;
            }
        }
示例#9
0
	    PegNode TagNodeCreator(ECreatorPhase phase,PegNode parentOrCreated, int id)
        {
            if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete){
                return new TagNode(parentOrCreated, id);
            }else{
                ((TagNode)parentOrCreated).tagValue_ = top.tag;
                return null;
            }
        }
        protected PegNode TRepetitionCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
        {
            if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
                return new TRange(parentOrCreated, id);
            else if (phase == ECreatorPhase.eCreationComplete)
            {

                TRange n = parentOrCreated as TRange;
                if (n.child_ != null)
                {
                    switch (n.child_.id_)
                    {
                        case (int)EPegGrammar.option_symbol:
                            n.lower = 0;
                            n.upper = 1;
                            return n;
                        case (int)EPegGrammar.star:
                            n.lower = 0;
                            n.upper = Int32.MaxValue;
                            return n;
                        case (int)EPegGrammar.plus:
                            n.lower = 1;
                            n.upper = Int32.MaxValue;
                            return n;
                        case (int)EPegGrammar.lower_limit:
                            if (n.child_.child_ != null)
                            {
                                PegNode lowerLimit = n.child_.child_;
                                if (n.child_.next_ == null)
                                {
                                    n.child_.next_ = n.child_.Clone();
                                    n.child_.next_.id_ = (int)EPegGrammar.upper_limit;
                                }
                                else
                                {
                                    Debug.Assert(n.child_.next_.id_ == (int)EPegGrammar.optional_upper_limit);
                                    if (n.child_.next_.child_ == null) /*no upper limit has been specified*/
                                    {
                                        n.child_.next_ = MakeUpperNumericLimit(n.child_,Int32.MaxValue);
                                    }
                                    else
                                    {   //remove node optional_upper_limit'
                                        Debug.Assert(n.child_.next_.child_.id_ == (int)EPegGrammar.upper_limit);
                                        n.child_.next_ = n.child_.next_.child_;
                                    }
                                }
                                PegNode upperLimit = n.child_.next_.child_;
                                SetLimit(lowerLimit, ref n.lower, ref n.lowerInto);
                                SetLimit(upperLimit, ref n.upper, ref n.upperInto);
                                return n;

                            }
                            Debug.Assert(false);
                            return null;
                        default: Debug.Assert(false);
                            return null;
                    }
                }
                return parentOrCreated;
            }
            else
            {
                Debug.Assert(false);
                return null;
            }
        }
        protected PegNode TBitRangeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
        {
            if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
                return new TRange(parentOrCreated, id);
            else if (phase == ECreatorPhase.eCreationComplete)
            {
                TRange n = parentOrCreated as TRange;
                if (n.child_ != null)
                {
                    switch (n.child_.id_)
                    {
                        case (int)EPegGrammar.lower_limit:
                            if (n.child_.child_ != null)
                            {
                                PegNode lowerLimit = n.child_.child_;
                                PegNode upperLimit = n.child_.next_ != null ? n.child_.next_.child_ : null;
                                SetLimit(lowerLimit, ref n.lower, ref n.lowerInto);
                                if (upperLimit != null) SetLimit(upperLimit, ref n.upper, ref n.upperInto);
                                else
                                {
                                    n.upper = n.lower;
                                    n.upperInto = n.lowerInto;
                                }
                                return n;

                            }
                            Debug.Assert(false);
                            return null;
                        default: Debug.Assert(false);
                            return null;
                    }
                }
                return parentOrCreated;
            }
            else
            {
                Debug.Assert(false);
                return null;
            }
        }
 protected PegNode QuoteNodeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
 {
     if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
         return new MultiLineDblQuoteNode(parentOrCreated, id);
     else if (phase == ECreatorPhase.eCreationComplete)
     {
         Debug.Assert(parentOrCreated.id_ == (int)EPegGrammar.multiline_double_quote_literal);
         StringBuilder s = new StringBuilder();
         for (PegNode dblQuotedContent = parentOrCreated.child_; dblQuotedContent != null; dblQuotedContent = dblQuotedContent.next_)
         {
             Debug.Assert(dblQuotedContent.id_ == (int)EPegGrammar.dbl_quoted_content);
             s.Append(dblQuotedContent.GetAsString(src_));
         }
         MultiLineDblQuoteNode n = (MultiLineDblQuoteNode)parentOrCreated;
         n.quoted_ = s.ToString();
         return parentOrCreated;
     }
     else
     {
         Debug.Assert(false);
         return null;
     }
 }
 protected PegNode DefaultNodeCreator(ECreatorPhase phase, PegNode parentOrCreated, int id)
 {
     if (phase == ECreatorPhase.eCreate || phase == ECreatorPhase.eCreateAndComplete)
         return new PegNode(parentOrCreated, id);
     else
     {
         if (parentOrCreated.match_.posEnd_ > maxpos_)
             maxpos_ = parentOrCreated.match_.posEnd_;
         return null;
     }
 }