Beispiel #1
0
        /** If you label a rule reference, you can access that rule's
         *  return values as well as any predefined attributes.
         */
        public override Attribute GetAttribute(string name)
        {
            AttributeScope rulePropertiesScope =
                RuleLabelScope.grammarTypeToRulePropertiesScope[(int)Grammar.type];

            if (rulePropertiesScope.GetAttribute(name) != null)
            {
                return(rulePropertiesScope.GetAttribute(name));
            }

            if (referencedRule.ReturnScope != null)
            {
                return(referencedRule.ReturnScope.GetAttribute(name));
            }
            return(null);
        }
Beispiel #2
0
        /** Return the scope containing name */
        public virtual AttributeScope GetAttributeScope(string name)
        {
            AttributeScope scope = GetLocalAttributeScope(name);

            if (scope != null)
            {
                return(scope);
            }
            if (ruleScope != null && ruleScope.GetAttribute(name) != null)
            {
                scope = ruleScope;
            }
            return(scope);
        }
Beispiel #3
0
        /** Return the set of keys that collide from
         *  this and other.
         */
        public virtual HashSet <object> Intersection(AttributeScope other)
        {
            if (other == null || other.Count == 0 || Count == 0)
            {
                return(null);
            }
            HashSet <object> inter = new HashSet <object>();

            foreach (Attribute attr in attributes)
            {
                string key = attr.Name;
                if (other.GetAttribute(key) != null)
                {
                    inter.Add(key);
                }
            }
            if (inter.Count == 0)
            {
                return(null);
            }
            return(inter);
        }
Beispiel #4
0
        /** Get the arg, return value, or predefined property for this rule */
        public virtual AttributeScope GetLocalAttributeScope(string name)
        {
            AttributeScope scope = null;

            if (ReturnScope != null && ReturnScope.GetAttribute(name) != null)
            {
                scope = ReturnScope;
            }
            else if (ParameterScope != null && ParameterScope.GetAttribute(name) != null)
            {
                scope = ParameterScope;
            }
            else
            {
                AttributeScope rulePropertiesScope =
                    RuleLabelScope.grammarTypeToRulePropertiesScope[(int)Grammar.type];
                if (rulePropertiesScope.GetAttribute(name) != null)
                {
                    scope = rulePropertiesScope;
                }
            }
            return(scope);
        }
Beispiel #5
0
 /** Return the set of keys that collide from
  *  this and other.
  */
 public virtual HashSet<object> Intersection( AttributeScope other )
 {
     if ( other == null || other.Count == 0 || Count == 0 )
     {
         return null;
     }
     HashSet<object> inter = new HashSet<object>();
     foreach ( Attribute attr in _attributes )
     {
         string key = attr.Name;
         if ( other.GetAttribute( key ) != null )
         {
             inter.Add( key );
         }
     }
     if ( inter.Count == 0 )
     {
         return null;
     }
     return inter;
 }