Пример #1
0
        protected void MemorizeReference(ReferenceExp exp)
        {
            RefParseInfo pi = (RefParseInfo)refParseInfos[exp];

            if (pi == null)
            {
                refParseInfos[exp] = pi = new RefParseInfo();
            }
            pi.MemorizeReference(reader);
        }
 protected void MemorizeReference( ReferenceExp exp )
 {
     RefParseInfo pi = (RefParseInfo)refParseInfos[exp];
     if(pi==null)
     refParseInfos[exp] = pi = new RefParseInfo();
     pi.MemorizeReference(reader);
 }
        protected virtual void CombineReferenceExp(
				ReferenceExp r, Expression body, string combine )
        {
            if( redefiningRefExps.ContainsKey(r) ) {
            // this pattern is currently being redefined.
            redefiningRefExps[r] = true;
            return;	// ignore the value
            }

            RefParseInfo pi = (RefParseInfo)refParseInfos[r];
            if(pi==null)	refParseInfos[r] = pi = new RefParseInfo();

            if( pi.Combine!=null && combine!=null && pi.Combine!=combine ) {
            // error: inconsistent combine method
            ReportError( ERR_INCONSISTENT_COMBINE, r.name );
            pi.Combine = null;
            return;
            }
            if( combine==null ) {
            if( pi.HeadDefined )
                // error: multiple heads
                ReportError( ERR_MULTIPLE_HEADS, r.name );
            pi.HeadDefined = true;
            combine = pi.Combine;
            } else {
            pi.Combine = combine;
            }

            if( r.exp==null )
            r.exp = body;
            else {
            if(combine=="interleave")	r.exp = Builder.CreateInterleave( r.exp, body );
            else
            if(combine=="choice")		r.exp = Builder.CreateChoice( r.exp, body );
            else {
                // error: invalid combine value
                ReportError( ERR_INVALID_COMBINE, combine );
            }
            }
        }
Пример #4
0
        protected virtual void CombineReferenceExp(
            ReferenceExp r, Expression body, string combine)
        {
            if (redefiningRefExps.ContainsKey(r))
            {
                // this pattern is currently being redefined.
                redefiningRefExps[r] = true;
                return;         // ignore the value
            }

            RefParseInfo pi = (RefParseInfo)refParseInfos[r];

            if (pi == null)
            {
                refParseInfos[r] = pi = new RefParseInfo();
            }

            if (pi.Combine != null && combine != null && pi.Combine != combine)
            {
                // error: inconsistent combine method
                ReportError(ERR_INCONSISTENT_COMBINE, r.name);
                pi.Combine = null;
                return;
            }
            if (combine == null)
            {
                if (pi.HeadDefined)
                {
                    // error: multiple heads
                    ReportError(ERR_MULTIPLE_HEADS, r.name);
                }
                pi.HeadDefined = true;
                combine        = pi.Combine;
            }
            else
            {
                pi.Combine = combine;
            }

            if (r.exp == null)
            {
                r.exp = body;
            }
            else
            {
                if (combine == "interleave")
                {
                    r.exp = Builder.CreateInterleave(r.exp, body);
                }
                else
                if (combine == "choice")
                {
                    r.exp = Builder.CreateChoice(r.exp, body);
                }
                else
                {
                    // error: invalid combine value
                    ReportError(ERR_INVALID_COMBINE, combine);
                }
            }
        }