public static Function parseTraversalFunctionFromContext(final GremlinParser.TraversalFunctionContext context) {
        if (context.traversalT() != null) {
            return TraversalEnumParser.parseTraversalEnumFromContext(T.class, context.traversalT());
        } else if (context.traversalColumn() != null)
            return TraversalEnumParser.parseTraversalEnumFromContext(Column.class, context.traversalColumn());
        else {
            throw new GremlinParserException("Unrecognized enum for traversal function");
        }
    }
Parsing of {@link Direction} requires some special handling because of aliases (from/to).
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/TraversalEnumParser.java