@Override
    public Void visitTraversalCardinality(final GremlinParser.TraversalCardinalityContext ctx) {
        // handle the enum style of cardinality if there are no parens otherwise is the function call.
        if (ctx.LPAREN() != null && ctx.RPAREN() != null) {
            final int idx = ctx.K_CARDINALITY() != null ? 2 : 0;
            final String txt = ctx.getChild(idx).getText();
            appendExplicitNaming(txt, getCardinalityFunctionClass());
            appendStepOpen();
            visit(ctx.genericLiteral());
            appendStepClose();
        } else {
            appendExplicitNaming(ctx.getText(), "Cardinality");
        }

        return null;
    }
A Gremlin to Gremlin translator. Makes no changes to input except:
<ul>
    <li>Normalizes whitespace</li>
    <li>Normalize numeric suffixes to lower case</li>
    <li>Makes anonymous traversals explicit with double underscore</li>
    <li>Makes enums explicit with their proper name</li>
</ul>
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/translator/TranslateVisitor.java