Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mgrdich/forthcompiler
A basic Compiler for Gforth written in Go
https://github.com/mgrdich/forthcompiler
assembly assembly-x86 compiler forth-like golang
Last synced: 2 days ago
JSON representation
A basic Compiler for Gforth written in Go
- Host: GitHub
- URL: https://github.com/mgrdich/forthcompiler
- Owner: Mgrdich
- Created: 2023-11-23T17:49:11.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-01-04T15:08:25.000Z (10 months ago)
- Last Synced: 2024-10-11T18:11:58.486Z (26 days ago)
- Topics: assembly, assembly-x86, compiler, forth-like, golang
- Language: Go
- Homepage:
- Size: 1.17 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GForth Compiler
minor GForth compiler written in Go.Supported Architectures
* `x64`GForth functionalities can be checked https://learnxinyminutes.com/docs/forth/
### How to build the compiler
* Install `Go` version <= 1.21.1
* run `make`It will build the forth compiler that is written with `Go`.
It gives you an executable with the name `mf`.### How to test the language
* `mf ./samples/test1.mf` it will compile this file and give you and executable with the same name `test1`
* Then run it `./test1`### What's to Come
* More functionality in the language
* More Parameters in the CLI
* Writing test suitesHappy Forthing
### Supported Operations
Take each line as a clean slate
* Stack push Eg: `1 2 3`
* Stack print `1 2 3` -> `<3> 1 2 3 ok`
* Stack Pop and print `1 2 3 .` -> `3 ok`
* Arithmetic Operation Addition `1 2 + .` -> `3 ok`
* Arithmetic Operation Subtraction `1360 23 - .` -> `1337 ok`
* Arithmetic Operation Multiplication `6 7 * .` -> `42 ok`
* Keyword Operation Negation `99 negate .` -> `-99 ok`
* Keyword Operation Absolute `-99 abs .` -> `99 ok`
* Keyword Operation Maximum `52 26 max .` -> `52 ok`
* Keyword Operation Minimum `52 26 min .` -> `26 ok`
* Keyword Operation Duplication `3 dup .s` -> `<2> 3 3 ok`
* Keyword Operation Swap `3 5 swap .s` -> `<2> 5 3 ok`
* Keyword Operation Rotate `6 5 4 rot .s` -> `<3> 4 5 6 ok`
* Keyword Operation Nip `6 5 4 nip .s` -> `<2> 6 4 ok`
* Keyword Operation Tuck `1 2 3 4 tuck .s` -> `<5> 1 2 4 3 4 ok`
* Keyword Operation Over `1 2 3 4 over .s` -> `<5> 1 2 3 4 3 ok`