Fluffy Language

The fluffy language is a toy language designed around the libfirm intermediate representation library. The language supports the typical low-level constructions known from C and combines them with modern generic programming techniques. It also features a plugin system which allows to extend the parser and lexer.

Download

Features

Code sample

Fluffy syntax is based on python/haskell style indentation rules (but with a saner handling when tabs and spaces are mixed). Along with some elements known from pascal, sather and theortical informatics (<- is the assignment operator). Below is a solver for the n-queens problem written in fluffy:

var row : int*

func myabs(i : int) : int:
    if i < 0:
        return -i
    return i

func place_ok(i : int) : bool:
    var j <- 0

    while j < i:
        if row[j] = row[i] || myabs(row[i]-row[j]) = (i-j):
            return false
        j <- j + 1
    
    return true

func solve(n : int) : int:
    var c   <- 0
    var res <- 0

    row    <- cast<int*> malloc(sizeof<int> * n)
    row[0] <- -1

    while c >= 0:
        row[c] <- row[c] + 1
        while (row[c] < n) && (!place_ok(c)):
            row[c] <- row[c] + 1

        if row[c] < n:
            if c = n-1:
                res <- res + 1
            else:
                c      <- c + 1
                row[c] <- -1
        else:
            c <- c - 1
    free(row)

    return res

export main
func main(argc : int, argv : byte**) : int:
    var n <- 8
    if argc > 1:
        n <- atoi(argv[1])
    printf("The %d-queens problem has %d solutions.\n", n, solve(n))
    return 0

Author and Contact

fluffy was designed and implemented by Matthias Braun (matze -AT- braunis DOT de).