### Introduction

Back in 1997 I decided, more or less for the hell of it, to design and implement a programming system. Mercat, nee Micron, is that language, and this is it.

Mercat is not really useful for anything much. It is, on the other hand, an excellent example of how to implement a self-hosted recursive-descent-parsed language and virtual machine. The code is --- I hope --- reasonably easy to understand, and I think the overall design is quite elegant.

Features include:

• Garbage collection
• Portable binary files
• C-like syntax
• Associative arrays as a primitive type
• Real strings
• Easily expandable through a simple, fast system call interface
• Self-hosted; the compiler and assembler are written in Mercat
• Text screen interface through ncurses

Supported platforms:

• DOS, 16-bit (compiled with Borland C)
• DOS, 32-bit (compiled with DJGPP)
• Linux
• Any other Posix system

Here's some code, taken from one of the example programs, a full-screen editor.

function void MenuInitialise
{
int i;
int j;
int x := 1;
int w;
string label;

{
x := x + 2 + w;
{
if (sizeof(label) > w)
w := sizeof(label);
}
}
}


### So you want to give Mercat a try

Because Mercat is portable, the bulk of the code is provided as platform-independent .mo files. All you need is an interpreter for your system. Therefore, you will need:
core_030.zip 102 kB

The core Mercat code, version 0.3.0.

plus one of these, depending on your platform:

dos16030.zip 42 kB

DOS 16-bit run-time binaries for version 0.3.0. Because this runs entirely in real mode, memory is extremely limited, but it will recompile the compiler.

dos32030.zip 46 kB

DOS 32-bit run-time binaries for version 0.3.0.

linux030.zip 16 kB

Linux-ELF-glibc run-time binaries for version 0.3.0.

If you don't have any of those platforms, or want to rebuild the run-time from source, then you'll want this:

posix030.zip 40 kB

Posix run-time sources for version 0.3.0. Will build any version.

Example programs and documentation are provided in the core file.

One of the main interesting features of mercat is the bootstrap compiler, which is a full recursive-descent compiler written in... awk. Yes, really. It actually works reasonably well, although it does stretch the limits of what the language can do. For convenience, therefore, here's a direct download.

com.awk.txt 29 kB

The awk bootstrap compiler (with a .txt extension so it'll display in your web browser).

If you are of a historical bent, you might be interested in the prior Mercat version, 0.2.1.