The Xreate programming language
Xreate Compiler Internals

Table of Contents


In a nutshell, xreate::XreateManager is the entry point of the Xreate compiler API for clients to start off by instantiating it.

xreate::XreateManager's responsibility is a control over internal compiler's workflow consisting of steps as follows:

Build and run

For build instructions and examples see Build and Run.


The Xreate grammar located in two files in a COCO parser generator's format:


xreate::AST represents the Xreate's syntax tree. It's produced by Scanner and Parser themselves generated by the Coco generator.

Internal passes

Once xreate::AST is built, xreate::XreateManager runs number of passes as a preparation for reasoning (see xreate::TranscendLayer) and compilation (see xreate::CompilePass).

There is xreate::Attachments to address a need of communication between various passes and stages. Passes may store additional pieces of information as AST node attachments for future use by consequent passes. Ultimately, all accumulated this way data is used to facilitate, enhance and refine the compilation process.

Currently there is a number of passes available, among them are:

Each pass either implements xreate::IPass interface or inherits xreate::AbstractPass as a more convenient wrapper. xreate::PassManager is the base class to manage passes and xreate::XreateManager inherits xreate::PassManager to control builtin passes.


xreate::TranscendLayer is a wrapper over an external ASP reasoner (currently Clasp). Previously executed passes' output is collected(see xreate::IAnalysisReport, analysis/utils.h) to compose a logic program in Clasp reasoner's ASP syntax format. See xreate::TranscendLayer for more details.

Clients may implement xreate::IQuery interface to to access Clasp reasoner's solutions. There is number of existing queries, such as:

Also, currently a number of analyses are performed bypassing ASP reasoner:


xreate::CompilePass iterates over xreate::AST tree to produce bytecode using additional data supplied by previous passes(via xreate::Attachments) along with data accessed via queries (xreate::IQuery) from the external Clasp reasoner. Bytecode is generated using LLVM infrastructure represented by xreate::LLVMLayer. There is a number of classes focused on particular compilation aspects, among them are: