@Override
    public Void visitTraversalPredicate(final GremlinParser.TraversalPredicateContext ctx) {
        switch(ctx.getChildCount()) {
            case 1:
                // handle simple predicate
                visit(ctx.getChild(0));
                break;
            case 5:
                // handle negate of P
                visit(ctx.getChild(0));
                sb.append(".").append(processGremlinSymbol("negate")).append("()");
                break;
            case 6:
                // handle and/or predicates
                final int childIndexOfParameterOperator = 2;
                final int childIndexOfCaller = 0;
                final int childIndexOfArgument = 4;

                visit(ctx.getChild(childIndexOfCaller));
                sb.append(".").append(processGremlinSymbol(ctx.getChild(childIndexOfParameterOperator).getText())).append("(");
                visit(ctx.getChild(childIndexOfArgument));
                sb.append(")");
                break;
        }
        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