Antlr4.Tool.Ast.GrammarAST.GetFirstDescendantWithType C# (CSharp) 메소드

GetFirstDescendantWithType() 공개 메소드

public GetFirstDescendantWithType ( Antlr types ) : Antlr.Runtime.Tree.CommonTree
types Antlr
리턴 Antlr.Runtime.Tree.CommonTree
        public virtual CommonTree GetFirstDescendantWithType(Antlr.Runtime.BitSet types)
        {
            if (types.Member(Type))
                return this;
            if (Children == null)
                return null;
            foreach (object c in Children)
            {
                GrammarAST t = (GrammarAST)c;
                if (types.Member(t.Type))
                    return t;
                CommonTree d = t.GetFirstDescendantWithType(types);
                if (d != null)
                    return d;
            }
            return null;
        }

Same methods

GrammarAST::GetFirstDescendantWithType ( int type ) : Antlr.Runtime.Tree.CommonTree

Usage Example

예제 #1
0
        public LabelElementPair(Grammar g, GrammarAST label, GrammarAST element, int labelOp)
        {
            this.label = label;
            this.element = element;
            // compute general case for label type
            if (element.GetFirstDescendantWithType(tokenTypeForTokens) != null)
            {
                if (labelOp == ANTLRParser.ASSIGN)
                    type = LabelType.TOKEN_LABEL;
                else
                    type = LabelType.TOKEN_LIST_LABEL;
            }
            else if (element.GetFirstDescendantWithType(ANTLRParser.RULE_REF) != null)
            {
                if (labelOp == ANTLRParser.ASSIGN)
                    type = LabelType.RULE_LABEL;
                else
                    type = LabelType.RULE_LIST_LABEL;
            }

            // now reset if lexer and string
            if (g.IsLexer())
            {
                if (element.GetFirstDescendantWithType(ANTLRParser.STRING_LITERAL) != null)
                {
                    if (labelOp == ANTLRParser.ASSIGN)
                        type = LabelType.LEXER_STRING_LABEL;
                }
            }
        }
All Usage Examples Of Antlr4.Tool.Ast.GrammarAST::GetFirstDescendantWithType