G Programming Language
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Jake Wakeling 283533183a Enable the CONFIGURE_DEPENDS CMake glob flag 6 months ago
doc Use AST nodes in symbol table directly 8 months ago
examples Remove excessive test sources 8 months ago
src Add warning level configuration 7 months ago
.gitignore meta: Add .vscode to gitignore 1 year ago
BuildUNIX.sh meta: Add base project files 2 years ago
CHANGELOG meta: Remove OMKOV prefix from header guards 1 year ago
CMakeLists.txt Enable the CONFIGURE_DEPENDS CMake glob flag 6 months ago
LICENCE meta: Relicense to MIT 9 months ago
README.md Update todo list in README 8 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