How many times have you created quick and dirty script to generate C tables, parameterized code, etc. ?

Did the script ended up messy?

Is there a better way?

I've tried quite a lot of solutions but none of them worked really well and because of that I've decided to create a templating engine based on Python specialized for generating source code.

Example input that generates table of prime numbers:

#ifndef PRIMES_H
#define PRIMES_H

@ from math import sqrt
@ max_prime = 1000

unsigned int primes[] = {
[@for](/users/for) i in range(3, max_prime+1,2)
@ is_prime = True
@ for j in range(3, int(sqrt(i)))
@  if i % j == 0
@   is_prime = False
@  endif
@ endfor
@ if is_prime
        {{ i }},
@ endif

#endif /* PRIMES_H */

What is this useful for? There are number of use cases. One of the ideas is to generate syscall testcases from high level descriptions (a bit similar to what trinity does, but far more complete).

I already have a proof of concept ready, but it's far from complete solution.

Looking for hackers with the skills:

Nothing? Add some keywords!

This project is part of:

Hack Week 11



  • metan
    about 6 years ago by metan | Reply

    Git repo with initial code is at

  • metan
    about 6 years ago by metan | Reply

    Language description, howto, tests and example code are available in the git repository.

    Packages are in obs at:

    And the language and implementation seems to be good enough for 1.0.0 release.

Similar Projects

This project is one of its kind!