Antlr4.Semantics.SemanticPipeline.HasTypeOrMoreCommand C# (CSharp) Method

HasTypeOrMoreCommand() private method

private HasTypeOrMoreCommand ( [ r ) : bool
r [
return bool
        internal virtual bool HasTypeOrMoreCommand([NotNull] Rule r)
        {
            GrammarAST ast = r.ast;
            if (ast == null)
            {
                return false;
            }

            GrammarAST altActionAst = (GrammarAST)ast.GetFirstDescendantWithType(ANTLRParser.LEXER_ALT_ACTION);
            if (altActionAst == null)
            {
                // the rule isn't followed by any commands
                return false;
            }

            // first child is the alt itself, subsequent are the actions
            for (int i = 1; i < altActionAst.ChildCount; i++)
            {
                GrammarAST node = (GrammarAST)altActionAst.GetChild(i);
                if (node.Type == ANTLRParser.LEXER_ACTION_CALL)
                {
                    if ("type".Equals(node.GetChild(0).Text))
                    {
                        return true;
                    }
                }
                else if ("more".Equals(node.Text))
                {
                    return true;
                }
            }

            return false;
        }