Welcome to my alic journey. In my previous acwj journey, I developed a self-compiling compiler for a subset of the C language. In this project, I want to design a simple procedural language and build a compiler for it.
alic stands for "a language inspired by C". It's going to look quite a lot like C. I also want to be able to use the existing C library, so alic has to be ABI compatible with C. But I want to try out some new language ideas and see if they work or not.
For details of what alic looks like, see the docs/ directory, especially the overview of alic. Then look at the example programs in the tests and examples directories in the most recent part.
In this journey I'm going to have fewer, bigger chunks of development than I did with acwj. Here are the parts of the alic journey so far:
- Part 1: Built-in Types and Simple Expressions
- Part 2: Simple Control Statements
- Part 3: A Start on Functions
- Part 4: Function Arguments & Parameters, and Function Calls
- Part 5: A Hand-Written Lexer and Parser
- Part 6: More Work on Functions
- Part 7: A Start on Pointers, A C Pre-Processor and Semantic Errors
- Part 8: Opaque Types, Type Aliases, Enumerated Values
- Part 9: Adding Structs and Unions
- Part 10: Adding Exceptions
- Part 11: More C Features
- Part 12: Arrays, Finally
- Part 13: Rewriting the alic Compiler in alic
- Part 14: Adding
const
andcast()
to alic - Part 15: Some More Loop Constructs
- Part 16: Associative Arrays
- Part 17: Strings in Switch, Function Pointers, Iterator Functions and Regular Expressions
- Part 18: Adding Some ADA-isms to alic
- Part 19: A
string
Type and Some Bug Fixes - Part 20: N-Dimensional Arrays
- Part 21: Local Struct/Array Initialisation
If you just want to see the language features in alic which make it different than C, then skips parts 1-5 and 13 and read the other parts! Also read the overview of alic which covers the differences between C and alic.
I'm developing the compiler on a Devuan Linux box, but if you have a Linux box with a C compiler then you should be fine. You will need to download, compile and install:
Then you should be able to do a $ make
in each part to build the executable called alic
.
There are a bunch of example test programs in the tests/
directory in each part. At the top level of each part, do a $ make test
to go into this directory and run the runtests
script. This checks the output of each file to ensure it runs correctly, or checks that the compiler dies with the correct fatal error.
In the cina/
directory in Parts 13 and up you will find the alic compiler written in the alic language itself. To build this, at the top level of Part 13 (for example) do a $ make triple
. This will:
- Build the compiler using the C source code, producing the alic executable
- Build the compiler using the alic source code, producing the cina/alica executable
- Build the compiler using the cina/alica executable and the alic source code, producing the cina/alicia executable.