Crate phile [] [src]

This library provides the programmatic interface for the PHiLe Compiler and Domain-Specific Language. The crate is composed of several modules, each of which roughly corresponds to a single step in the compilation pipeline:

  • lexer performs lexical analysis and tokenization.
  • parser performs higher-level syntactic analysis and outputs an…
  • ast, an Abstract Syntax Tree.
  • sqirgen takes the AST and typechecks it, then emits…
  • sqir, the Schema and Query Intermediate Representation, PHiLe IR.
  • sqiropt will take the raw SQIR and optimize it, so that it can be fed into…
  • dalgen, which is the back-end that generates the actual DAL code.
  • util contains miscellaneous helper types and functions.
  • error contains type definitions for uniformly describing syntactic, semantic, and internal compiler errors.

Depending on how you are willing to use PHiLe, you may be looking for…

  • The Tutorial. This gets you started quickly and painlessly with writing schemas and queries in PHiLe's domain-specific language.
  • The Examples. Check out these code snippets if you learn easier by example.
  • The Reference. Search through this document if you are already familiar with the basics and you are now looking for the details of a specific feature.
  • Manpage-style docs for philec, if you want to deep dive into the invocation of the PHiLe CLI compiler.

Modules

ast

This module contains types for building Abstract Syntax Trees (ASTs). ASTs describe the syntactic structure of PHiLe programs. Defined here are various kinds of AST nodes that the parser module emits from a sequence of tokens produced by the lexer module. AST nodes, like tokens, contain source location data in order to easily map them to the original source code.

dalgen

DALGen, the backend of the PHiLe compiler. This is the part that generates actual code in your programming language of choice for a Database Abstraction Layer from optimized SQIR.

error

This module defines types for representing possible errors that may be generated during the compilation of some PHiLe source code. It also provides useful macros for reporting errors in a way that is consistent across modules.

lexer

This module contains type definitions and functions for breaking up unstructured source text into lexemes and tokens. It also provides types for mapping tokens to their original location within the source code in a human-readable manner.

parser

This module provides a function, parse(), for building an Abstract Syntax Tree out of a flat sequence of Tokens, itself generated by the lexer module. The module depends on the ast module for providing the emitted node types.

sqir

Defines SQIR, the Schema and Query Intermediate Representation. SQIR is the intermediate language of PHiLe, on which optimizations are performed. SQIR is also the starting point of code generation for database abstraction layers.

sqirgen

This module provides functionality to convert an Abstract Syntax Tree into PHiLe's intermediate language, SQIR (short for Schema and Query Intermediate Representation).

sqiropt

This module provides facilities for optimizing PHiLe programs in SQIR format.

util

The util module provides various useful helper functions, types and macros, used extensively throughout the PHiLe source tree. Generic reference-counted smart pointers, string manipulation specific to the syntax of PHiLe, and commonly-used constants are all part of this file.