partiql / partiql-ir-generator

PartiQL I.R. Generator (P.I.G.)
Apache License 2.0
24 stars 7 forks source link
generator ion nanopass partiql

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

plugins {
    id 'pig-gradle-plugin'
}

sourceSets {
    main {
        pig {
            // in addition to the default 'src/main/pig'
            srcDir 'path/to/type/universes'
        }
    }
    test {
        pig {
            // in addition to the default 'src/test/pig'
            srcDir 'path/to/test/type/universes'
        }
    }
}

pig {
  target = 'kotlin' // required
  namespace = ... // optional
  template = ... // optional
  outDir = 'build/generated-sources/pig/' // default
}

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>

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

Obtaining the PIG Executable

To obtain the pig executable:

After the build completes, the pig executable and dependencies will be located in ./pig/build/install/pig/bin/pig.

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.