Skip to content

Commit 0f1cf6a

Browse files
committed
first commit
0 parents  commit 0f1cf6a

34 files changed

+36338
-0
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
jobs:
7+
build:
8+
strategy:
9+
matrix:
10+
os: ["ubuntu-latest"]
11+
runs-on: ${{ matrix.os }}
12+
13+
steps:
14+
- name: Checkout ${{ github.event.repository.name }}
15+
uses: actions/checkout@v2
16+
17+
- name: Build ${{ github.event.repository.name }}
18+
run: make init
19+
20+
- name: make self
21+
run: |
22+
make self
23+
make self
24+
make self
25+
time make self

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.o
2+
*.out
3+
main
4+
ibuc
5+
ibu
6+
save

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM --platform=linux/x86_64 ubuntu:latest
2+
3+
RUN apt-get update && \
4+
apt-get -y install sudo && \
5+
sudo apt-get -y install build-essential && \
6+
sudo apt-get -y install git && \
7+
sudo apt-get -y install vim && \
8+
sudo apt-get -y install man && \
9+
sudo apt-get -y install manpages-dev && \
10+
apt-get install -y strace
11+
12+
VOLUME /root/env
13+
WORKDIR /root/env
14+

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2023 Ibuki Yoshida
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.

Makefile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
SHELL = /bin/bash
3+
.SHELLFLAGS = -o pipefail -c
4+
5+
.DEFAULT_GOAL := init
6+
7+
.PHONY: up
8+
up:
9+
docker compose up -d
10+
11+
.PHONY: down
12+
down:
13+
docker compose down
14+
15+
.PHONY: ibulang
16+
ibulang:
17+
docker compose exec ibulang bash
18+
19+
.PHONY: init
20+
init:
21+
as -o bootstrap/ibu.o bootstrap/ibu.s
22+
as -o bootstrap/tokenizer.o bootstrap/tokenizer.s
23+
as -o bootstrap/parser.o bootstrap/parser.s
24+
as -o bootstrap/codegen.o bootstrap/codegen.s
25+
as -o bootstrap/preprocessor.o bootstrap/preprocessor.s
26+
as -o bootstrap/linux-syscall.o bootstrap/linux-syscall.s
27+
as -o bootstrap/std.o bootstrap/std.s
28+
as -o lib/runtime.o lib/runtime.s
29+
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
30+
31+
.PHONY: self
32+
self:
33+
./ibuc src/ibu.ibu | as - -o src/ibu.o
34+
./ibuc src/tokenizer/tokenizer.ibu | as - -o src/tokenizer.o
35+
./ibuc src/parser/parser.ibu | as - -o src/parser.o
36+
./ibuc src/codegen/codegen.ibu | as - -o src/codegen.o
37+
./ibuc src/preprocessor/preprocessor.ibu | as - -o src/preprocessor.o
38+
./ibuc lib/linux-syscall/linux-syscall.ibu | as - -o lib/linux-syscall.o
39+
./ibuc lib/std/std.ibu | as - -o lib/std.o
40+
as -o lib/runtime.o lib/runtime.s
41+
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
42+
43+
.PHONY: update_bootstrap
44+
update_bootstrap:
45+
./ibuc src/ibu.ibu > bootstrap/ibu.s
46+
./ibuc src/tokenizer/tokenizer.ibu > bootstrap/tokenizer.s
47+
./ibuc src/parser/parser.ibu > bootstrap/parser.s
48+
./ibuc src/codegen/codegen.ibu > bootstrap/codegen.s
49+
./ibuc src/preprocessor/preprocessor.ibu > bootstrap/preprocessor.s
50+
./ibuc lib/linux-syscall/linux-syscall.ibu > bootstrap/linux-syscall.s
51+
./ibuc lib/std/std.ibu > bootstrap/std.s
52+
53+
.PHONY: clean
54+
clean:
55+
rm *.o ibuc bootstrap/*.o src/*.o lib/*.o
56+

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<h1>The Ibu programming language</h1>
2+
3+
[Changelog]() |
4+
[Docs](docs/docs.md) |
5+
[ドキュメント](docs/docs_jp.md)
6+
7+
[![CI](https://github.com/v420v/ibu/actions/workflows/ci.yml/badge.svg)](https://github.com/v420v/ibu/actions/workflows/ci.yml)
8+
9+
- No strict type checker
10+
- No C-like pointer arithmetic
11+
- No function-like macros
12+
- No `break`, `continue` stmt. Use `goto`
13+
- Allows `13 <= age < 20` instead of `13 <= age && age < 20`
14+
- Variable length args `func(...)` can be accessed with built-in variables `argc i64` and `argv *i64`
15+
- The compiler is written in itself
16+
- Default args don't have to be on the end (WIP)
17+
18+
```go
19+
#include "std/header.ibu"
20+
21+
func main() i32 {
22+
let age i32 = 19;
23+
24+
if 13 <= age < 20 {
25+
printf("Teen-ager\n");
26+
}
27+
28+
return 0;
29+
}
30+
```
31+
32+
## Installing the Language
33+
```zsh
34+
$ git clone [email protected]:v420v/ibu.git
35+
$ cd ibu
36+
$ make up
37+
$ make ibulang
38+
$ make init
39+
```
40+
41+
## How to Use the Compiler
42+
A simple example compile and run hello world
43+
```zsh
44+
$ ./ibuc main.ibu | as - -o main.o
45+
$ as -o lib/runtime.o lib/runtime.s
46+
$ ./ibuc lib/linux-syscall/linux-syscall.ibu | as - -o lib/linux-syscall.o
47+
$ ./ibuc lib/std/std.ibu | as - -o lib/std.o
48+
$ ld -o main main.o lib/runtime.o lib/linux-syscall.o lib/std.o
49+
$ ./main
50+
```
51+
52+
[documentation](docs/docs.md)
53+
54+
[documentation[日本語版]](docs/docs_jp.md)

0 commit comments

Comments
 (0)