Skip to main content

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

(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/extern function 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 (python depends 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

gofra-0.0.2.tar.gz (44.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gofra-0.0.2-py3-none-any.whl (73.7 kB view details)

Uploaded Python 3

File details

Details for the file gofra-0.0.2.tar.gz.

File metadata

  • Download URL: gofra-0.0.2.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.7 Darwin/24.6.0

File hashes

Hashes for gofra-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a1e340f687358eaab506e8d8a6033053179d8c9655ef85af3e331620482817f8
MD5 60ca2c8e94c4edca1f8bf80f8d6fa6d8
BLAKE2b-256 6632c39ef6605ad20b98767b8a3826751b65d6355142efa95fe7b829dde0997c

See more details on using hashes here.

File details

Details for the file gofra-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: gofra-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 73.7 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

Hashes for gofra-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c85dbb97291112a8d1a652b5dd7183cc81b7c6b49c6010cffeea879d2a088944
MD5 3d7a3af863a67bb90fc116ad91437f1e
BLAKE2b-256 77c353b1bc7826c8ab8c996327cf61518f5a00ff0307d25c234d628f8d4b4012

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page