LIL Scripting Language

LIL Scripting Language


LIL, or little interpretted language, is a scripting language that somewhat resembles TCL. The language is easy to embed into other programs, as it only conists of a small C and header file.

The homepage of LIL can be found at

Most of the documentation for syntax and API can be found here:

Syntax Examples

Hello world:

print hello world

Function starts with the first word, arguments follow. Arguments are words separated by spaces.

Arithmetic is done with expr. Bitwise operations work! It seems attention to operator precedence is also here as well.

print [expr 4 + 4 * 2]
print [1 << 4]

A new function starts at each line break by default. Alternatively, semi-colons can be used to have multiple function calls on one line.

# print hi there on two lines
print hi
print there

# same thing, but put the calls on one line
print hi ;print there

# break up function into lines
print hi \

func foo {a b} {print $a $b}

Variables are set with set.

set x 4; print $x

API Usage Examples

Here's a really quick "hello world" API example I made:

#include <stdlib.h>
#include <stdio.h>
#include "lil.h"

static lil_value_t foo(lil_t lil, size_t argc, lil_value_t *argv)
    printf("hello from C!\n");
    printf("nargs: %ld\n", argc);
    return NULL;

int main(int argc, char *argv[])
    lil_t lil;
    lil_value_t val;

    lil = lil_new();

    val = lil_parse(lil, "print hello there!\n", 19, 0);

    lil_register(lil, "foo", foo);

    val = lil_parse(lil, "foo 1.234\n", 10, 0);

    return 0;

home | index