Tool for braceless, whitespace sensitive C syntax

后端 未结 8 2458
灰色年华
灰色年华 2021-01-04 17:57

I\'m writing some C at the moment and because I like whitespace sensitive syntax, I\'d like to write it like this:

#include 

int main(void)
          


        
8条回答
  •  星月不相逢
    2021-01-04 18:22

    PythoidC is a braceless C language http://pythoidc.googlecode.com

    c.include(c.h.stdio) 
    c.include(c.h.stdlib) 
    
    int fib(int n): 
        if (n<=2): 
            return 1 
        else:
            return fib(n-1) + fib(n-2) 
    
    int main(int argc, char **argv): 
        int n //C style annotation 
        n=c.stdlib.atoi(argv[1]) 
        c.stdio.printf('fibonacci(%d)=%d\n', n, fib(n))
    

    PythoidC automatically generates the following C code:

    int fib(int n){ 
        if (n<=2){ 
            return 1;} 
        else{ 
            return fib(n-1) + fib(n-2);}} 
    
    int main(int argc, char **argv){ 
        int n ;//C style annotation 
        n=atoi(argv[1]); 
        printf("fibonacci(%d)=%d\n", n, fib(n)); 
    } 
    

提交回复
热议问题