Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dafiliks/nex-lang
Nex Lang Compiler
https://github.com/dafiliks/nex-lang
backend compiler frontend
Last synced: 10 days ago
JSON representation
Nex Lang Compiler
- Host: GitHub
- URL: https://github.com/dafiliks/nex-lang
- Owner: dafiliks
- License: mit
- Created: 2024-10-22T15:21:34.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-01-02T03:07:16.000Z (about 1 month ago)
- Last Synced: 2025-01-02T03:34:53.593Z (about 1 month ago)
- Topics: backend, compiler, frontend
- Language: C++
- Homepage: https://dafiliks.com/
- Size: 22.5 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nex Lang
> [!NOTE]
> This project is currently in WIP.Nex Lang is an experimental (toy) programming language written in C++, that was made as a learning project. The purpose of this language is not to be the fastest or the most functional but to serve as an example of how a programming language is created.
I undertook this project as I was interested in how compilers work, and so far the experience has been rewarding and interesting. Although it was very tempting, I have decided to not continue using LLVM for code generation as I wanted to use this project to get better at reading and writing assembly code. I am trying to build this project entirely from scratch, therefore, most things will be found out through trial and error, so don't expect the implementation to be perfect.
# Example
This simple application showcases some features of Nex Lang.
```nex-lang
# main.nex#$ multiline
comment $## main function
fn main() {
# initialising variables
var foo = 200;
var bar = 600;# initialise a variable using maths expression
var x = 8 * 1 / 5 + 2;# infinite loop
set label;
go label;# exit with variable foo (exit code 200)
esc foo;
}#$ another
multiline
comment $## another function
fn test() {
# return a maths expression
ret 5 + 10 * 2;
}
```# Info
### Commands
Below, you can see the usage of the nex executable and some options.```
Nex: Usage: nex -o
--version Displays all version information
-o Specifies the file to dump asm code into
```### Assembly
Currently, Nex only outputs Intel x64 assembly. You can execute the assembly spat out by Nex using nasm.*Install commands for Arch Linux:*
```bash
sudo pacman -S nasm
```To execute the assembly:
```bash
nasm -felf64 out.asm
ld -o out out.o
```### Extention
`.nex` for obvious reasons.# Building
#### Linux:
Building Nex on Linux requires you to have CMake, Make, and GCC.*Install commands for Arch Linux:*
```bash
sudo pacman -S cmake base-devel
```To build Nex:
```bash
git clone https://github.com/dafiliks/nex-lang
mkdir nex-lang/build
cd nex-lang/build
cmake ..
make
# You can execute Nex with the commands below
cd compiler/src
./nex
```# Contributing
All contributions are welcome, so feel free to submit issues/pull requests. Coding style doesn't matter as long as naming is clear. Programming is art.
© David Filiks