A Stack-based compiled programming language
Project description
Gofra Programming Language
Gofra is an native stack based programming language.
Language follows reverse polish notation (examples can be found below)
Language is in development stage and mostly made for fun and research so don't expect a lot and try to test or implement your own idea
Table of content
- Hello world example
- Compatibility
- Features
- Installation
- Examples
- Language overview
- Command Line Interface
- Milestones and planned features
Hello world example
(For now, language is mostly bare-metal so in this example there is raw sc_write syscall and file descriptor usage)
include "std.gof"
func void main
FD_STD_OUT "Hello, World!\n" sc_write drop
end
Compatibility
Language currently have codegenS only for:
- AARCH64 MacOS (Darwin)
- x86_64 Linux
Features
- Native (codegen assembly)
- Type safety (Validates stack usage and tries to infer types so you wont mess up)
- Mostly self explanation errors (Tries to help you and correct your intentions)
- Optimizer (DCE, CF, Helps optimize resulting assembly for codegen so your default usage will not be overwhelmed by language)
- FFI with
global/externfunction modifers (there is CLI flags to emit an library/object file) - Simple CLI for working with language (simple toolkit)
Installation
- Clone this repo
- Install latest Python version
- Navigate to root directory
- Run
python -m gofra --help(pythondepends on your installation of Python)
Examples
Examples may be found inside ./examples directory
Language overview
As language is stack based so your basic action is to put something on a stack, like 2 2 will push 2 and then another 2 on stack so stack underneath will look like [2, 2]
If you want to operate on that numbers you may do something like 3 2 + which is same as 3 + 2 in other language or default math. Underneath this will mean: push 3 on stack -> push 2 on stack -> take 2 elements from stack -> sum them -> push result back. Stack after that will become [5]
Conditionals is also a bit controversial:
1 2 == if
...
end
which is same as other languages:
if (1 == 2){
...
}
(You can follow previous math example for checking stack manipulation)
For writing a bit more complex programs you may want to use macros and includes: Macros is an collection of tokens (like functions in other languages) but does not have an object-like system they just an way to not write same logic (for now) So, this code:
macro multiply_by_2
2 *
end
4 multiply_by_2
at compilation stage will be converted into simple 4 2 * (tokens expanded)
For importing some file (same as macros system but for files) you can use import "file.gof"
Milestones and planned features
- Standard library with not only syscall mapping
- Stability improvements
- Support for x86_64 Windows
- More examples
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gofra-0.0.1.tar.gz.
File metadata
- Download URL: gofra-0.0.1.tar.gz
- Upload date:
- Size: 43.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.7 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7f7e38adb66c54413dc4024e1a9e2b09e13abbcc093f1f047a3c076a8102ef2
|
|
| MD5 |
1d9ac9254929906d4f90beb65c1c2763
|
|
| BLAKE2b-256 |
2f3e594d29af6941685b008315c003e4f0b20303bb47b4c7e8ee715f49e73d9f
|
File details
Details for the file gofra-0.0.1-py3-none-any.whl.
File metadata
- Download URL: gofra-0.0.1-py3-none-any.whl
- Upload date:
- Size: 73.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.7 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3401b699228b130987937db722f16cd36c9bbd3942437e0012316778cf040062
|
|
| MD5 |
4f1ffa6c9362803f614b4649c18e25e6
|
|
| BLAKE2b-256 |
e437f2ca7f590066a49089ef9c0c3af2726f487bf1e0bdac2041ba900af94b51
|