private static String replaceVariables(final String gremlin) {
        // convert lambda vars to closures as they will be ignored by the test suite
        return gremlin.replace("relations", "\"relations\"").
                replace("places.size()", "6").
                replace("places", "\"places\"").
                replace("ids", "\"ids\"").
                replace("vRexsterJob1", "\"rj1\"").
                replace("vBlueprintsJob1", "\"bj1\"").
                replace("weightFilter.clone()", "{it}").
                replace("weightFilter", "{it}").
                replace("vBob", "\"bob\"").
                replace("vMarko", "\"marko\"").
                replace("vPeter", "\"peter\"").
                replace("vStephen", "\"stephen\"").
                replace("maps", "[:]").
                replace("v1", "new Vertex(1,\"vertex\")").
                replace("v2", "new Vertex(2,\"vertex\")").
                replace("input.head()", "\"head\"").
                replace("input.tail().size()", "6").
                replace("input.tail()", "\"tail\"").
                replace("System.out.&println", "{it}").
                replace("persons", "\"persons\"").
                replace("marko.value('age')", "11").
                replace("seedStrategy", "new SeedStrategy(seed: 99999)").
                replace(".getClass()", "").
                replace("result.toArray()", "4").
                replace("vA.value('amount')", "0.0").
                replace("vA", "\"vA\"");
    }
Variables can't be parsed by the grammar so they must be replaced with something concrete.
gremlin-language/src/main/java/org/apache/tinkerpop/gremlin/language/corpus/DocumentationReader.java