flang is a functional language for data mangling.
It compiles to C, so it's 100% compatible with it and can import any library you need that's written in that language.
The typesystem is lossly type, because it exists unsafe_cast
, but it's
strong type if you don't use it. unsafe_cast
is here to be compatible
with C way of doing things, not flang best practices.
Under development, do not use it production.
The syntax is rather stable.
Wants to help?! Awesome! First install Clang(3.6+)/GCC (5.4+)
- Clang is default because has better error messages and ASAN
- clang-format is neede to PR, everything is formatted with it.
Notes about GCC
- GCC only work with static linking... PR welcome!
- To allow GCC i hace to disable c11 and move to gnu99. PR welcome!
flang depends on
- string.c and here how to install string.c from git
- libuv and here how to install libuv from git
- [bison] I use 3.0.4 older may work. how to install bison from sources
- [flex] I use 3.0.4 older may work. how to install flex from sources
There are some sh
(s) that helps you in the development.
sh run.sh [--gcc] [--clang]
# build grammar & execute rerun.sh
sh rerun.sh [--gcc] [--clang]
# build flang and run something, this is mainly what you have to do
# to develop, after this write a test
# if you modify the parser grammar (BISON) use run.sh next time
sh test.sh [--gcc] [--clang]
# build grammar & execute retest.sh
sh retest.sh [--gcc] [--clang]
# make check: run all test, everything must pass, no skip, no flaky
sh format.sh
# This is the only requisite to merge
# use clang-format to give all the project the same/consistent style
MSVS users. Replicate the sh above with some bat/ps1 file (piece of cake!) and don't forget to PR :)
parser -> typesystem -> codegen (print) -> compile c code
Flang is divided into a few libraries that can be swap with your custom implementation if needed.
Functions to create and manipulate AST
Functions to parse files/string into AST with flang syntax.
Use Bison/Flex.
Functions to validate and transform AST. At the end, everything has a type and can be safely codegen.
Functions to output a C file from AST.
NOTE flang_try_1_llvm branch has an experimental LLVM codegen, that it's deprecated due the real complexity of having to deal with so many low level staff. C compilers do that for us now.
see LICENSE file