Disclaimer: This is a personal side-project
Compass 🧭 is a small programming language with strong inpiration from Esterel. It is a synchronous programming language meant to build finite state machines easily for your C code.
Unlike Esterel, Compass is very bare bones and uses a rather trivial compilation process, which can lead to very different behaviours for code that looks similar.
The ABRO code example adapted for Compass looks like:
module abro(input A, input B, input R, output O)
each R seq {
par {
await A;
await B;
};
emit O;
}
endmodule
The Compass compiler is distributed as a Python source package. To install it, one can run:
# Fetch the source code
git clone https://github.com/roadelou/compass.git
# Go into the repository
cd compass
# Install the python package
pip3 install .A PyPi package is also available for the compiler, and it can be installed with pip3 install roadelou-compass 🎉
Once the compiler is installed, it can be used from the terminal through the compass command. Basic usage is:
# This will output a C file called abro_compass.c
compass abro.cmps
# To compile the header file to use the C code
compass --lang header abro.cmps
# To compile a CLI interface to test the module
compass --lang debug abro.cmpsSome examples of the language can be found in the examples folder.
Compass Builder is a small tool provided by the package to automate the compilation of projects with submodules. It takes a JSON file describing the project as input and outputs a Makefile to automate the compilation of the project.
💡 For an example JSON description of a project, see cascade_abro.json.
Basic usage of compass-builder is:
# Creates a Makefile from the description given in project.json
compass-builder project.json MakefileThe version of compass in the repository supports:
inputandoutputsignalslocalvariableseach,par,seq,awaitandemitstatements- Conditional tests with
if,elif,elseandendif - The ability to use submodules within a module with the
externandsubmodulekeywords - Many C-inspired operators for expressions, including bitwise, arithmetic and boolean operators
; operator should only be used to separate several statements in a list of statements, i.e. only in seq and par blocks. The last ; is optional by the way.
| Field | Value |
|---|---|
| 📝 Contributors | roadelou |
| 📧 Contacts | |
| 📅 Creation Date | 2021-03-12 |
| 💡 Language | Markdown Document |