Antlr3.Tool.Grammar.GetLabels C# (CSharp) Method

GetLabels() public method

public GetLabels ( HashSet rewriteElements, LabelType labelType ) : HashSet
rewriteElements HashSet
labelType LabelType
return HashSet
        public virtual HashSet<string> GetLabels( HashSet<GrammarAST> rewriteElements, LabelType labelType )
        {
            HashSet<string> labels = new HashSet<string>();
            foreach ( GrammarAST el in rewriteElements )
            {
                if ( el.Type == ANTLRParser.LABEL )
                {
                    string labelName = el.Text;
                    Rule enclosingRule = GetLocallyDefinedRule( el.enclosingRuleName );
                    if (enclosingRule == null)
                        continue;

                    LabelElementPair pair = enclosingRule.GetLabel( labelName );
                    /*
                    // if tree grammar and we have a wildcard, only notice it
                    // when looking for rule labels not token label. x=. should
                    // look like a rule ref since could be subtree.
                    if ( type==TREE_PARSER && pair!=null &&
                         pair.elementRef.getType()==ANTLRParser.WILDCARD )
                    {
                        if ( labelType==WILDCARD_TREE_LABEL ) {
                            labels.add(labelName);
                            continue;
                        }
                        else continue;
                    }
                     */
                    // if valid label and type is what we're looking for
                    // and not ref to old value val $rule, add to list
                    if ( pair != null && pair.type == labelType &&
                         !labelName.Equals( el.enclosingRuleName ) )
                    {
                        labels.Add( labelName );
                    }
                }
            }
            return labels;
        }
Grammar