Skip to content

sadderchris/partiql-ir-generator

 
 

Repository files navigation

PartiQL IR Generator

PIG is a compiler framework, domain modeling tool and code generator for tree data structures such as ASTs (Abstract Syntax Tree), database logical plans, database physical plans, and other intermediate representations. Using PIG, the developer concisely defines the structure of a tree by specifying named constraints for every node and its attributes.

PIG is mature, but its API and the API of the generated Kotlin code is under active development and may change.

PIG Generator PIG Runtime License CI Build

About

Check out the wiki! — PartiQL IR Generator Wiki

Usage

There are two components of PIG to be aware of

Both are available in Maven Central, and it is recommended that you use the same version for both of them.

Gradle

There are plans to make a Gradle plugin for PIG but one has not been completed yet.

Without the aforementioned plugin, the best way to use pig with gradle is:

  • Add a dependency on PIG in your project's buildSrc/build.gradle file. This will make the API of PIG available to all other build.gradle files in your project. (Example)
  • Add a dependency on PIG's runtime library in your project.
    (Example)
  • Add a custom task that uses PIG's internal APIs. (Example)
  • Make sure your custom task executes before the compileKotlin task. (Example)

Other Build Systems

If you are not using Gradle, it will be necessary to invoke PIG via the command line.

At build time and before compilation of your application or library, the following should be executed:

pig \
    -u <type universe.ion> \
    -t kotlin \ 
    -n <namespace> \ 
    -o path/to/package/<output file>
  • <type universe.ion>: path to the Ion text file containing the type universe
  • <output file>: path to the file for the generated code
  • <namespace>: the name used in the package statement at the top of the output file

Execute: pig --help for all command-line options.

Obtaining the PIG Executable

To obtain the pig executable:

  • Clone this repository.
  • Check out the tag of the release you wish to utilize, e.g. git checkout v0.4.0
  • Execute ./gradlew assemble

After the build completes, the pig executable and dependencies will be located in pig/build/distributions/pig/pig-x.y.z.[tar.gz|zip].

Finally, make sure that the version of the partiql-ir-generator-runtime library that you are using corresponds to the version of the executable.

Verify this with the --version command line option of PIG.

License

This project is licensed under the Apache-2.0 License.

About

PartiQL I.R. Generator (P.I.G.)

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 98.0%
  • FreeMarker 2.0%