@Override
    public Void visitTraversalSource(final GremlinParser.TraversalSourceContext ctx) {
        // replace "g" with whatever the user wanted to use as the graph traversal source name
        sb.append(graphTraversalSourceName);

        // child counts more than 1 means there is a step separator and a traversal source method
        if (ctx.getChildCount() > 1) {
            if (ctx.getChild(0).getChildCount() > 1) {
                appendStepSeparator();
                visitTraversalSourceSelfMethod((GremlinParser.TraversalSourceSelfMethodContext) ctx.getChild(0).getChild(2));
            }
            appendStepSeparator();
            visitTraversalSourceSelfMethod((GremlinParser.TraversalSourceSelfMethodContext) ctx.getChild(2));
        }
        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