Add Missing Brackets

lua-users home
wiki

Add Missing Brackets

This is C code with many "{}();" characters missing.

#include <stdio.h>

int main  int argc, char **argv
    int i
    char name[]="Anchor"
    printf  "%s is C.\n",name
    for  i=5;i--;
        printf  "%i\n",i
    
    printf  "done!\n"
    return 0
Pretend to program in Python or Lua while actually writing in C (and possibly PHP, Java, D, C++). If code is indented, a free GPL program called "Anchor" (located on Freshmeat.net) automatically adds missing brackets.

Anchor is written in C and flex is needed to compile it. A challenging exercise would be to port it to Lua.

The commands are simple to add to .SciTEUser.properties

file.patterns.cpp=$(file.patterns.cpp);*.anch
source.files=$(source.files);*.anch
command.go.*.anch=anch -run $(FileNameExt)
command.compile.*.anch=anchor $(FileNameExt)|gcc -xc -&&./a.out
Now remember to save the Anchor projects with the ".anch" extension.

Also integrates with Tinycc compiler (TCC) to create runnable C scripts.


RecentChanges · preferences
edit · history
Last edited January 22, 2015 5:01 am GMT (diff)