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
Comments

over 9 years ago by metan  Reply
Language description, howto, tests and example code are available in the git repository.
Packages are in obs at:
https://build.opensuse.org/package/show/home:metan/cct
And the language and implementation seems to be good enough for 1.0.0 release.
Similar Projects
This project is one of its kind!