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 PRIMESH #define PRIMESH

@ from math import sqrt @ max_prime = 1000

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

#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


  • over 7 years ago: pluskalm liked this project.
  • over 7 years ago: osukup liked this project.
  • over 7 years ago: ebischoff liked this project.
  • over 7 years ago: metan started this project.
  • over 7 years ago: metan originated this project.

  • Comments

    Similar Projects

    This project is one of its kind!