@Override
    public Object visitTraversalTerminalMethod_next(final GremlinParser.TraversalTerminalMethod_nextContext ctx) {
        final GremlinLang bc = this.traversal.asAdmin().getGremlinLang();
        if (ctx.getChildCount() == 3) {
            bc.addStep("next");
        } else {
            // the 3rd child is integer value
            final int childIndexOfParamaterAmount = 2;
            bc.addStep("next", Integer.decode(ctx.getChild(childIndexOfParamaterAmount).getText()));
        }

        return bc;
    }
{@inheritDoc}

Traversal terminal method next step
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TerminalMethodToBytecodeVisitor.java