(Back to main page)

Asterix

Asterix (named after the cartoon character) is a low-level programming language with basic integer arithmetic, memory access, functions, and variables, with a syntax that resembles the Backus-Naur Form (BNF) and compiler/parser-generator languages like Yacc. It has syntactic sugar for input parsing and output generation.

The language is implemented as a compiler to amd64 (a.k.a. x86_64) machine code. It was not bootstrapped in C, but using a predecessor called prox2 which is briefly described on the (meta-)compiler project page.

In Asterix, functions and “grammar rules” are the same thing. Its statements and expressions somewhat resemble “semantic actions” from conventional parser generators, but can also specify arbitrary conditions to be “matched”. Control flow is defined by BNF-like sequence, alternation, and repetition forms.

For example, here is a function (used in the Asterix compiler) that looks for an ASCII digit and returns the corresponding numeric value:

digit : c =
    c=[0-9] { c - '0' }
  | c=[A-Z] { c - '7' }
  | c=[a-z] { c - 'W' } ;

It should not be confused with an actual parser generator. There is no reference to any kind of formalism and all code is compiled linearly without optimization or any significant analysis.

Like prox2 and its predecessors, Asterix takes significant inspiration from a compiler-writing language published in 1964 called “META II”.

Asterix is free software (free as in freedom), and may be modified and/or redistributed in accordance with the GNU Lesser General Public License (LGPL), version 3 or later.

2021-12-07 — 2 small changes:

Links:

Old versions (tarballs with source code only):

(Back to main page)