IB (Indentation Branching) is a transpiler which 'turns everything into python', it is my frankenstein, so seams I might aswell write some documentation to explain some of my madness.
I used to have a very old german mechanical keyboard, which was missing 'alt-gr', making it unable to type '{}' on the iso layout.
While mapping keys was possible in some cases, I wanted to be able to write C on any machine, so I decided I would try to make a program which would generate the braces for me, the indentation implied where I wanted them anyhow, so on a lazy afternoon I wrote IB for C, and have since been expanding it onto other syntactics.
The following rules are in use in some form in all languages, although as indicated by the quotes some concepts have ambiguious meanings
Indentation is 'scoping'.
->
{
->
}
Each line not followed by scoping is 'terminated'
print("one")
if (1)
print("two")
print("one");
if (1)
{
print("two");
}
A line doesn't end if its last charcter is '\'.
print("three" \
"four" )
print("three" \
"four" );
A line ends when a comment is opened.
print("five") // prints number
print("five"); // prints number
IB was originally only intended for and is written in C, while the base concepts allow you to already write pretty clean C, IB brings some quality of life improvements
Scopes which are opened by a line ending with '=' are lists and each line inside is terminated with a ',', the list itself is also terminated.
int nums[] =
1
2
3
int nums[] =
{
1,
2,
3
};
The same rule applies to enums.. which turns out to be a nightmare, as enums only stick out because of the keyword enum, which IB parses for.
Both Structs and classes fuction like a ordinary scope, but they are terminated.
struct Point
int x
int y
struct Point
{
int x;
int y;
};
One exception is if your struct is an inline typedef.
typedef struct Point
int x
int y
pt
typedef struct Point
{
int x;
int y;
}
pt;
Ib syntax tends to look better with a smaller tabsize, it is also strongly recommended to use actual tabs instead of spaces, although it does support them, any improper indentation will cause failure.
au! BufRead,BufNewFile *.c.ib setfiletype c
au! BufRead,BufNewFile *.cpp.ib setfiletype cpp
set tabstop=4
set shiftwidth=4
set list
set listchars=tab:>\ ,space:.
- gentoo my ebuild repo
- arch AUR my pkgbuild repo
$ make bootstrap
(root) $ make install