Пример #1
0
        /** Return label alt or return name of rule */
        public virtual string GetContextName()
        {
            CodeBlockForOuterMostAlt alt = GetOuterMostAltCodeBlock();

            if (alt != null && alt.altLabel != null)
            {
                return(alt.altLabel);
            }
            return(enclosingRuleRunction.name);
        }
Пример #2
0
        /** Add decl to struct ctx for rule or alt if labeled */
        public virtual void AddContextDecl(string altLabel, Decl.Decl d)
        {
            CodeBlockForOuterMostAlt alt = d.GetOuterMostAltCodeBlock();

            // if we found code blk and might be alt label, try to add to that label ctx
            if (alt != null && altLabelCtxs != null)
            {
                //System.Console.WriteLine(d.name + " lives in alt " + alt.alt.altNum);
                AltLabelStructDecl altCtx;
                if (altLabel != null && altLabelCtxs.TryGetValue(altLabel, out altCtx))
                {
                    // we have an alt ctx
                    //System.Console.WriteLine("ctx is " + altCtx.name);
                    altCtx.AddDecl(d);
                    return;
                }
            }
            ruleCtx.AddDecl(d); // stick in overall rule's ctx
        }
Пример #3
0
 public virtual void SetCurrentOuterMostAlternativeBlock(CodeBlockForOuterMostAlt currentOuterMostAlternativeBlock)
 {
     this.currentOuterMostAlternativeBlock = currentOuterMostAlternativeBlock;
 }
Пример #4
0
 public virtual CodeBlockForAlt Alternative(Alternative alt, bool outerMost)
 {
     CodeBlockForAlt blk = @delegate.Alternative(alt, outerMost);
     if (outerMost)
     {
         currentOuterMostAlternativeBlock = (CodeBlockForOuterMostAlt)blk;
     }
     foreach (CodeGeneratorExtension ext in extensions)
         blk = ext.Alternative(blk, outerMost);
     return blk;
 }