Skip to content
/ cct Public

A Python based templating language designed for generating source code.

License

Notifications You must be signed in to change notification settings

metan-ucw/cct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

          _/_/_/    _/_/_/  _/_/_/_/_/
       _/        _/            _/
      _/        _/            _/
     _/        _/            _/
      _/_/_/    _/_/_/      _/


Fast and efficient Python based templating
language designed for generating source code.


Usage: cct [-E] [-ilevel] [-Idir(s)] [-v] [-o outfile] file.c.t

-E stops at first phase, leaves python script
-i sets indenntation depth, default is 4
-I adds include search pats
-o sets output file name
-v sets verbose mode
-h prints help


Some example inputs:

To generate a table of prime numbers
--------------------------------------------
#ifndef PRIMES_H
#define PRIMES_H

@ from math import sqrt
@ max_prime = 1000

unsigned int primes[] = {
        2,
@ 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
@             break
@     if is_prime:
        {{ i }},
@     end
@ end
};

#endif /* PRIMES_H */
-------------------------------------------

To generate simple box image filter
-------------------------------------------
@ def sum(arr):
{{ arr }}_out[x][y] = 0;
@     for i in ['- 1', '+ 0', '+ 1']:
@         for j in ['- 1', '+ 0', '+ 1']:
{{ arr }}_out[x][y] += {{ arr }}[x {{ i }}][y {{ j }}];
@         end
@     end
{{ arr }}_out[x][y] /= 9;
@ end

for (x = 1; x < w - 1; x++) {
	for (y = 1; y < h - 1; y++) {
		{@ sum('R') @}
		{@ sum('G') @}
		{@ sum('B') @}
	}
}
-------------------------------------------

About

A Python based templating language designed for generating source code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published