G

G Programming Language
git clone http://git.omkov.net/G
Log | Tree | Refs | README | Download

G/README.md (101 lines, 2.7 KiB) -rw-r--r-- download

0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
# The G Programming Language

A modern alternative to **C** intended to be simple, fast, and pleasant.
Influenced by **C**, **Go**, **Odin**, **Zig**, and others.

Note that at present, **G** is highly unstable and will certainly change.

## Example

```g
print :: proc(s: string) {
	#syscall(uint(1), sint(1), cstring(s), len(s));
	return;
}

main :: proc() u8 {
	print("Hello, World!\n");
	return 0;
}
```

## Usage

**G** is being developed on x86-64 Linux, and is untested elsewhere.

### Dependencies

- A C23 capable compiler, to build
- CMake >= 3.21, to build
- LLVM, to build
- Clang, for `_start()` and linking (optional)

### Building

To build the **G** compiler, from the project root, run `make build`.

### 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

```sh
./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 and sometimes I am pretty
> liberal with what justifies crossing something off

- [x] Implement variables
- [x] Implement procedures
- [x] Implement booleans
- [x] Implement integers
- [x] Implement reals
- [x] Implement pointers
- [x] Implement arrays
- [ ] Implement variable length arrays (?)
- [ ] Implement structs
- [ ] Implement unions
- [x] Implement expressions
- [x] Implement type casting
- [ ] Implement type casting to pointers and arrays
- [ ] Improve type inference and implicit casting
- [ ] Implement the `type` type (?)
- [ ] Implement the `error` type
- [ ] Implement the `string` type properly
- [ ] Implement labels and `goto`
- [x] Implement `if` and `else`
- [x] Implement `for`
- [ ] Implement `break` and `continue`
- [ ] Implement `defer`
- [ ] Implement `errdefer` (?)
- [ ] Implement variadic procedure arguments
- [x] Implement syscalls
- [ ] Implement generics of some kind
- [ ] Implement module definition
- [ ] Implement module use
- [ ] Implement foreign code calling
- [ ] Optional types using `?` prefix (?)
- [ ] Error or types using `!` prefix (?)
- ...
- [ ] Re-write compiler in **G**

## Meta

Copyright (C) 2024, Jakob Wakeling  
All rights reserved.