// gets or creates a ReferenceExp which has the specified name.
 public ReferenceExp GetOrCreate( string name )
 {
     ReferenceExp exp = (ReferenceExp)namedPatterns[name];
     if(exp==null)
     namedPatterns[name] = exp = new ReferenceExp(name);
     return exp;
 }
        // gets or creates a ReferenceExp which has the specified name.
        public ReferenceExp GetOrCreate(string name)
        {
            ReferenceExp exp = (ReferenceExp)namedPatterns[name];

            if (exp == null)
            {
                namedPatterns[name] = exp = new ReferenceExp(name);
            }
            return(exp);
        }
Exemple #3
0
 public void OnRef(ReferenceExp exp)
 {
     if (recurseRefExp)
     {
         exp.exp.Visit(this);
     }
     else
     {
         writer.Write("{%");
         writer.Write(exp.name);
         writer.Write("}");
     }
 }
 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 );
            }
            }
        }
 public Expression OnRef( ReferenceExp exp )
 {
     return exp.exp.Visit(this);
 }
 public void OnRef( ReferenceExp exp )
 {
     if(recurseRefExp) {
     exp.exp.Visit(this);
     } else {
     writer.Write("{%");
     writer.Write(exp.name);
     writer.Write("}");
     }
 }