@Override
    public Void visitKeyword(final GremlinParser.KeywordContext ctx) {
        final String keyword = ctx.getText();

        // translate differently based on the context of the keyword's parent.
        if (ctx.getParent() instanceof GremlinParser.MapKeyContext) {
            // if the keyword is a key in a map, then it's a string literal essentially
            handleStringLiteralText(keyword);
        } else {
            // in all other cases it's used more like "new Class()"
            sb.append(keyword).append(" ");
        }

        return null;
    }
A base class for visitors that translate Gremlin AST nodes to Gremlin strings.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/translator/AbstractTranslateVisitor.java