Skip to content

YINZI71415/cfile

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cfile

A python C code generator.

Usage:

>>> import cfile as C
>>> hello = C.cfile('hello.c')
>>> hello.code.append(C.sysinclude('stdio.h'))
>>> hello.code.append(C.blank())
>>> hello.code.append(C.function('main', 'int',).add_param(C.variable('argc', 'int')).add_param(C.variable('argv', 'char', pointer=2)))
>>> body = C.block(innerIndent=3)
>>> body.append(C.statement(C.fcall('printf').add_arg(r'"Hello World!\n"')))
>>> body.append(C.statement('return 0'))
>>> hello.code.append(body)
>>> print(str(hello))

#include <stdio.h>

int main(int argc, char **argv)
{
   printf("Hello World!\n");
   return 0;
}

Prerequisites

Python 3

About

A python C code generator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%