NOTICE: This repository contains a compiler front-end that is in the early stages of development. Its buggy, incomplete, and hard to work with. Use it at your own risk!
Requite is a statically typed systems programming langauge with an orthogonal syntax. It has been in development since June 2024. Look in the test_sources folder for example source code files.
[import "std"];
[function [main], ()[signed_integer],
std.print(line="hello, world");
];
The requitec compiler is an LLVM front-end application written in C++. All source code for the front-end is contained within this repository. While language specific functionality is handled within this project, all back-end functionality related to generating machine code for specific target machines is handled by LLVM.
The requitec front-end compiles source files in 6 stages.
- Validation - In the validation stage, the raw source file text is checked for Unicode errors and unsupported characters.
- Tokenization - In the tokenization stage, raw source file text is seperated into a list of tokens that correlate to different lexemes.
- Parsing - In the parsing stage, the list of tokens emitted by the tokenizer are parsed into an Abstract-Syntax Tree (AST) structure that represents Requite code in a format that is efficient for the compiler to manipulate.
- Situation - In the situation stage, the compiler performs a pre-order traversal in order to do error checking and modification of the AST. This stage is important because it greatly simplifies later stages.
- Evaluation - In the evaluation stage, the compiler traverses the outermost scopes of Requite source files and builds symbol tables of global symbols. Symbols are lazily evaluated, and only the kind and name of each symbol is recorded at this stage unless more work is necessary to fully build out all tables. Then, all symbols in the source file are evaluated fully. When generating source files, Requite Intermediate Representation (RQIR) is built, which is used for symbolic execution. Symbols in imported source files are lazily evaluated.
- IR Building - In the building stage, the symbol tables and RQIR are used to build LLVM Intermediate Representation (IR).
To try requitec for yourself, you need to compile this project. The only dependency required is LLVM. LLVM development builds are not distributed for Windows, so you must either use a release build or compile LLVM yourself. This repository is designed to help with setup, but some skill with CMake and package management is required.
The requitec compiler can be controlled from the command line. It is easy to set up a project using Makefiles. You can see an example here.
| Option / Flag | Description | Required | Default |
|---|---|---|---|
<input file> |
Path to the input source file (positional argument) | Yes | |
--no-comment |
Do not add comments to output files | No | false |
-o <output file> |
Path to the output build file | Yes | |
-I <dir> |
Import directories (can be specified multiple times) | No | |
--emit <mode> |
Choose the type of target to build (see below) | No | object |
The --emit option supports the following modes:
tokens: Output CSV token dataparsed: Output intermediate Requite source code after parsingsituated: Output intermediate Requite source code after situatingsymbols: Output a markup language file listing user symbolsir: Output an LLVM IR source fileassembly: Output an assembly source fileobject: Output an object file (default)