Skip to content

Building AST Binaries

mahills edited this page May 2, 2013 · 1 revision

If you are going to look at the same systems repeatedly, or if the system takes a long time to parse, it can be helpful to parse it once and then write a binary representation of the AST to disk.

If the system in question is one of the corpus systems, and the location of the corpus is configured correctly, building the binary-serialized ASTs is already supported. Just issue the following commands:

import lang::php::util::Utils;
buildBinaries();

Additional versions exist to just build specific binaries. For instance, to build the AST for Drupal 7.14 and save it to disk, run this instead:

buildBinaries("Drupal", "7.14");

All binaries are saved into parsedDir, defined in module lang::php::util::Config.

If the system is not part of the corpus, it can also be parsed and serialized with another variant of the buildBinaries call:

buildBinaries("MySystem", "MyVersion", |file:///path/to/system|);

If the system does not have a specific version, just make one up -- for instance, if this is the current version of a system checked out from GitHub, just say something like Current or Head.

To load the system, do the following:

pt = loadBinary("Drupal", "7.14");

This will work regardless of whether the system is part of the corpus or not, since all binaries are created in the same location. If this was not part of the corpus, but was instead a system you downloaded, just make sure to use the same system and version names.

Clone this wiki locally