|
2 months ago | |
---|---|---|
doc | 3 months ago | |
examples | 2 months ago | |
src | 2 months ago | |
.gitignore | 10 months ago | |
BuildUNIX.sh | 1 year ago | |
CHANGELOG | 10 months ago | |
CMakeLists.txt | 3 months ago | |
LICENCE | 4 months ago | |
README.md | 2 months ago |
README.md
The G Programming Language
A modern alternative to C intended to be fast, simple, and pleasant. Influenced by C, C++, Odin, Rust, and Zig.
Note that at present, G is highly unstable and will certainly change.
Example
import "std:io";
main :: proc() -> s32 {
io.print("Hello, World!\n");
return 0;
}
Note that this example will not currently compile.
Usage
G is being developed on x86-64 Linux, and is untested elsewhere.
Dependencies
- CMake >= 3.14, to build
- LLVM, to build
- Clang, for linking compiled object files
Building
To build the G compiler on UNIX, run BuildUNIX.sh
.
Running
See
./bin/g --help
for program options.
Once the compiler is itself compiled, it can compile sources into object files
by running ./bin/g FILES
, where FILES is replaced with a list of G source
files to compile. At present, errors may not be correctly reported and the
compiler may just die if any are encountered.
For example, to compile the main.g example file, run
./bin/g examples/main.g
clang llvm.o
The first command will produce two files, llvm.bc and llvm.o, the bc file is LLVM IR bitcode, and can be decompiled to LLVM IR using llvm-dis, and the o file is an object file that can be linked into an executable with the second command. The second command will output an executable file, a.out by default.
Todo
Not all todo items will necesarilly be implemented
- Implement procedure declarations
- Implement procedure calls
- Implement variable declarations
- Implement variable assignments
- Implement integers
- Implement reals
- Implement arrays
- Implement expression parsing
- Implement expression code generation
- Implement the type type
- Implement multiple return values
- Implement defer
- Implement errdefer
- Implement if and else
- Implement for
- Implement generics of some kind
- Implement module definition
- Implement module use
- ...
- Re-write compiler in G
Meta
Copyright (C) 2021, Jakob Wakeling
MIT Licence