GetPredefinedScope() public method

public GetPredefinedScope ( LabelType ltype ) : AttributeDict
ltype LabelType
return AttributeDict
Beispiel #1
0
        /** $x.y, x can be surrounding rule, token/rule/label ref. y is visible
         *  attr in that dictionary.  Can't see args on rule refs.
         */
        public virtual Attribute ResolveToAttribute(string x, string y, ActionAST node)
        {
            if (tokenRefs.ContainsKey(x) && tokenRefs[x] != null)
            {
                // token ref in this alt?
                return(rule.GetPredefinedScope(LabelType.TOKEN_LABEL).Get(y));
            }

            if (ruleRefs.ContainsKey(x) && ruleRefs[x] != null)
            {
                // rule ref in this alt?
                // look up rule, ask it to resolve y (must be retval or predefined)
                return(rule.g.GetRule(x).ResolveRetvalOrProperty(y));
            }

            LabelElementPair anyLabelDef = GetAnyLabelDef(x);

            if (anyLabelDef != null && anyLabelDef.type == LabelType.RULE_LABEL)
            {
                return(rule.g.GetRule(anyLabelDef.element.Text).ResolveRetvalOrProperty(y));
            }
            else if (anyLabelDef != null)
            {
                AttributeDict scope = rule.GetPredefinedScope(anyLabelDef.type);
                if (scope == null)
                {
                    return(null);
                }

                return(scope.Get(y));
            }
            return(null);
        }