Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
v420v committed Oct 21, 2024
0 parents commit 2c352f0
Show file tree
Hide file tree
Showing 34 changed files with 36,613 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
push:
branches: [main]
jobs:
build:
strategy:
matrix:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout ${{ github.event.repository.name }}
uses: actions/checkout@v2

- name: Build ${{ github.event.repository.name }}
run: make init

- name: make self
run: |
make self
make self
make self
time make self
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.o
*.out
main
ibuc
ibu
save
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM --platform=linux/x86_64 ubuntu:latest

RUN apt-get update && \
apt-get -y install sudo && \
sudo apt-get -y install build-essential && \
sudo apt-get -y install git && \
sudo apt-get -y install vim && \
sudo apt-get -y install man && \
sudo apt-get -y install manpages-dev && \
apt-get install -y strace

VOLUME /root/env
WORKDIR /root/env

7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2023 Ibuki Yoshida

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
56 changes: 56 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

SHELL = /bin/bash
.SHELLFLAGS = -o pipefail -c

.DEFAULT_GOAL := init

.PHONY: up
up:
docker compose up -d

.PHONY: down
down:
docker compose down

.PHONY: ibulang
ibulang:
docker compose exec ibulang bash

.PHONY: init
init:
as -o bootstrap/ibu.o bootstrap/ibu.s
as -o bootstrap/tokenizer.o bootstrap/tokenizer.s
as -o bootstrap/parser.o bootstrap/parser.s
as -o bootstrap/codegen.o bootstrap/codegen.s
as -o bootstrap/preprocessor.o bootstrap/preprocessor.s
as -o bootstrap/linux-syscall.o bootstrap/linux-syscall.s
as -o bootstrap/std.o bootstrap/std.s
as -o lib/runtime.o lib/runtime.s
ld -o ibuc bootstrap/ibu.o bootstrap/tokenizer.o bootstrap/parser.o bootstrap/codegen.o bootstrap/preprocessor.o bootstrap/linux-syscall.o bootstrap/std.o lib/runtime.o

.PHONY: self
self:
./ibuc src/ibu.ibu | as - -o src/ibu.o
./ibuc src/tokenizer/tokenizer.ibu | as - -o src/tokenizer.o
./ibuc src/parser/parser.ibu | as - -o src/parser.o
./ibuc src/codegen/codegen.ibu | as - -o src/codegen.o
./ibuc src/preprocessor/preprocessor.ibu | as - -o src/preprocessor.o
./ibuc lib/linux-syscall/linux-syscall.ibu | as - -o lib/linux-syscall.o
./ibuc lib/std/std.ibu | as - -o lib/std.o
as -o lib/runtime.o lib/runtime.s
ld -o ibuc src/tokenizer.o src/parser.o src/codegen.o src/preprocessor.o src/ibu.o lib/std.o lib/runtime.o lib/linux-syscall.o

.PHONY: update_bootstrap
update_bootstrap:
./ibuc src/ibu.ibu > bootstrap/ibu.s
./ibuc src/tokenizer/tokenizer.ibu > bootstrap/tokenizer.s
./ibuc src/parser/parser.ibu > bootstrap/parser.s
./ibuc src/codegen/codegen.ibu > bootstrap/codegen.s
./ibuc src/preprocessor/preprocessor.ibu > bootstrap/preprocessor.s
./ibuc lib/linux-syscall/linux-syscall.ibu > bootstrap/linux-syscall.s
./ibuc lib/std/std.ibu > bootstrap/std.s

.PHONY: clean
clean:
rm *.o ibuc bootstrap/*.o src/*.o lib/*.o

54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<h1>The Ibu programming language</h1>

[Changelog]() |
[Docs](docs/docs.md) |
[ドキュメント](docs/docs_jp.md)

[![CI](https://github.com/v420v/ibu/actions/workflows/ci.yml/badge.svg)](https://github.com/v420v/ibu/actions/workflows/ci.yml)

- No strict type checker
- No C-like pointer arithmetic
- No function-like macros
- No `break`, `continue` stmt. Use `goto`
- Allows `13 <= age < 20` instead of `13 <= age && age < 20`
- Variable length args `func(...)` can be accessed with built-in variables `argc i64` and `argv *i64`
- The compiler is written in itself
- Default args don't have to be on the end (WIP)

```go
#include "std/header.ibu"

func main() i32 {
let age i32 = 19;

if 13 <= age < 20 {
printf("Teen-ager\n");
}

return 0;
}
```

## Installing the Language
```zsh
$ git clone git@github.com:v420v/ibu.git
$ cd ibu
$ make up
$ make ibulang
$ make init
```

## How to Use the Compiler
A simple example compile and run hello world
```zsh
$ ./ibuc main.ibu | as - -o main.o
$ as -o lib/runtime.o lib/runtime.s
$ ./ibuc lib/linux-syscall/linux-syscall.ibu | as - -o lib/linux-syscall.o
$ ./ibuc lib/std/std.ibu | as - -o lib/std.o
$ ld -o main main.o lib/runtime.o lib/linux-syscall.o lib/std.o
$ ./main
```

[documentation](docs/docs.md)

[documentation[日本語版]](docs/docs_jp.md)
Loading

0 comments on commit 2c352f0

Please sign in to comment.