Compare commits
42 commits
Author | SHA1 | Date | |
---|---|---|---|
|
5c5ae8d710 | ||
|
71ee7374d0 | ||
|
6e3aced0ba | ||
|
0c8ad457f2 | ||
|
58f7a69015 | ||
|
684b555c1e | ||
|
05cf63c3cd | ||
|
687975a746 | ||
|
33b7c4c91d | ||
|
18e3f48693 | ||
|
3853af5aa2 | ||
|
a38d5c0ce2 | ||
|
dfcca1aca3 | ||
|
0dea1c877e | ||
|
885ea69d9c | ||
|
083fa53de2 | ||
|
c78074943f | ||
|
a05dc6f133 | ||
|
ba3759733c | ||
7876ce27f7 | |||
353d0310f3 | |||
|
26eb4527a2 | ||
251d88a178 | |||
|
33d7fbae74 | ||
|
2da9c144d7 | ||
|
2a19d38f8a | ||
|
a0a7c7ce7a | ||
|
d5812f6383 | ||
|
c0b95c6af1 | ||
|
2fbaee3121 | ||
b4b362c2bb | |||
|
71d8b18c8c | ||
666869ae44 | |||
|
6c85eb5e20 | ||
af08c57e99 | |||
|
f1d6c0d699 | ||
7fb674cecc | |||
20bbca848e | |||
8bb91af353 | |||
20811ba4aa | |||
b842aa669c | |||
|
5b8011c6c5 |
20
.github/workflows/test.yml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
name: test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Build
|
||||||
|
run: cargo build
|
||||||
|
- name: Run tests
|
||||||
|
run: cargo test
|
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "archpackage/bfy"]
|
||||||
|
path = archpackage/bfy
|
||||||
|
url = ssh://aur@aur.archlinux.org/bfy.git
|
7
.mergify.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
pull_request_rules:
|
||||||
|
- name: Automatic merge on approval
|
||||||
|
conditions:
|
||||||
|
- "#approved-reviews-by>=1"
|
||||||
|
actions:
|
||||||
|
merge:
|
||||||
|
method: merge
|
10
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bfy"
|
name = "bfy"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Anas Elgarhy <anas.elgarhy.dev@gmail.com>"]
|
authors = ["Anas Elgarhy <anas.elgarhy.dev@gmail.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -31,12 +31,12 @@ exclude = [
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.0.14", features = ["derive", "color", "cargo", "wrap_help", "suggestions"] }
|
clap = { version = "4.3.2", features = ["derive", "color", "cargo", "wrap_help", "suggestions"] }
|
||||||
log = "0.4.17"
|
log = "0.4.18"
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = "0.5.0"
|
||||||
colored = "2.0.0"
|
colored = "2.0.0"
|
||||||
# no-panic = "0.1.16"
|
# no-panic = "0.1.16"
|
||||||
console = "0.15.2"
|
console = "0.15.7"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "1.3.0"
|
pretty_assertions = "1.3.0"
|
||||||
|
|
198
README-ar.md
Normal file
|
@ -0,0 +1,198 @@
|
||||||
|
<p align="center">
|
||||||
|
|
||||||
|
<img alt="brainfuc*k interpreter" src="./assets/cover.png" width="100%" />
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
# ممترجم بسيط وREPL للغة brainfu*k مكتوب باللغة Rust🦀
|
||||||
|
#### *اقرأ هذا في لغات أخرى.*
|
||||||
|
[EN English](README.md)
|
||||||
|
## المميزات
|
||||||
|
-مترجم بسيط وREPL للغة brainfu*k مكتوب باللغة Rust 💫
|
||||||
|
- تشغيل brainfuc * k رمز مباشر من REPL🚀
|
||||||
|
- دعم أحرف UTF-8 بما في ذلك الرموز التعبيرية 😍 (اختياري)
|
||||||
|
- يمكنك التحكم في حجم المصفوفة 📏
|
||||||
|
|
||||||
|
## تثبيت
|
||||||
|
|
||||||
|
- من crates.io:
|
||||||
|
```shell
|
||||||
|
cargo install bfy
|
||||||
|
```
|
||||||
|
- من aur:
|
||||||
|
```shell
|
||||||
|
yay -S bfy
|
||||||
|
```
|
||||||
|
|
||||||
|
## الخيارات والحجج
|
||||||
|
<details>
|
||||||
|
<summary>جدول الخيارات</summary>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>اختيار</th>
|
||||||
|
<th>وصف</th>
|
||||||
|
<th>إفتراضي</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><code>-h</code>, <code>--help</code></td>
|
||||||
|
<td>طباعة معلومات المساعدة</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-V</code>, <code>--version</code></td>
|
||||||
|
<td>يطبع معلومات الإصدار</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-f</code>, <code>--features</code></td>
|
||||||
|
<td>
|
||||||
|
الميزات الإضافية للتمكين<br/>
|
||||||
|
القيم الممكنة:
|
||||||
|
<ul>
|
||||||
|
<li>no-reverse-value:<br/>
|
||||||
|
إذا كانت القيمة تريد إنقاص القيمة وكانت القيمة 0 ، فلا تعين القيمة على 255 ، وإلا قلل القيمة. <br/>
|
||||||
|
إذا كانت القيمة تريد زيادة القيمة وكانت القيمة 255 ، فلا تقم بتعيين القيمة على 0 ، وإلا قم بزيادة القيمة. الاسم المستعار هو:
|
||||||
|
"nrv"
|
||||||
|
</li>
|
||||||
|
<li>reverse-pointer:<br/>
|
||||||
|
إذا كان المؤشر في نهاية المصفوفة ، فاضبط المؤشر على 0 ، وإلا قم بزيادة المؤشر. <br/>
|
||||||
|
إذا كان المؤشر في بداية المصفوفة ، فاضبط المؤشر على نهاية المصفوفة ، وإلا قلل المؤشر. الاسم المستعار هو: `rp`
|
||||||
|
</li>
|
||||||
|
<li>allow-utf8:<br/>
|
||||||
|
اسمح باستخدام أحرف utf8 (32 بت) ، وإلا فلن يُسمح إلا باستخدام أحرف 8 بت. <br/>
|
||||||
|
استخدم هذه الميزة بحذر لأنها تزيد حجم الخلية من 8 بت إلى 32 بت. <br/>
|
||||||
|
كما يسمح لك باستخدام الرموز التعبيرية في كود مخادعك: D ، هذا إذا استطعت
|
||||||
|
حافظ على عقلك حتى تتمكن من الوصول إلى قيمتها الرقمية :). <br/>
|
||||||
|
يمكن لـ "u32" في الصدأ تخزين القيم من 0 إلى 4294967295 فقط ، لكننا
|
||||||
|
يمكن فقط استخدام 0 إلى 1114111 (0x10FFFF) في الوقت الحالي. الاسم المستعار هو: `utf8`
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
<td>غير متوفر</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-a</code>, <code>--array-size</code></td>
|
||||||
|
<td>حجم المصفوفة</td>
|
||||||
|
<td>30000</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>-w</code>, <code>--without-tiles</code></td>
|
||||||
|
<td>لا تقم بطباعة المربعات (مثل رمز الخروج واسم الملف وما إلى ذلك)</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>مساعدة خيار الإخراج</summary>
|
||||||
|
|
||||||
|
```shell
|
||||||
|
bfy --help
|
||||||
|
```
|
||||||
|
```text
|
||||||
|
Brainfu*k interpreter and REPL written in Rust
|
||||||
|
|
||||||
|
Usage: bfy [OPTIONS] [SOURCE]
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
[SOURCE]
|
||||||
|
The brainfuck source code file to run (if not will be entered in REPL mode)
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-f, --features <FEATURES>
|
||||||
|
Possible values:
|
||||||
|
- no-reverse-value:
|
||||||
|
If the value is you want decrement the value and the value is 0, don't set the value to 255, otherwise decrement the value. If the
|
||||||
|
value is you want increment the value and the value is 255, don't set the value to 0, otherwise increment the value. The alias are:
|
||||||
|
`nrv`
|
||||||
|
- reverse-pointer:
|
||||||
|
If the pointer at the end of the array, set the pointer to 0, otherwise increment the pointer. If the pointer at the beginning of the
|
||||||
|
array, set the pointer to the end of the array, otherwise decrement the pointer. The alias are: `rp`
|
||||||
|
- allow-utf8:
|
||||||
|
Allow the use of utf8 characters (32 bit), otherwise only 8 bit characters are allowed. Use this feature with caution because it
|
||||||
|
increases the cell size from 8 bits to 32 bits. It also allow you to use the emoji in your brainfuck code :D, This is if you can
|
||||||
|
preserve your mind so that you can access their digital value :). The `u32` in rust can only store values from 0 to 4294967295, but we
|
||||||
|
can only use 0 to 1114111 (0x10FFFF) for now. The alias are: `utf8`
|
||||||
|
|
||||||
|
-a, --array-size <ARRAY_SIZE>
|
||||||
|
The brainfuck array size
|
||||||
|
|
||||||
|
[default: 30000]
|
||||||
|
|
||||||
|
-w, --without-tiles
|
||||||
|
Dont print the tiles (e.g. exit code, file name, etc)
|
||||||
|
|
||||||
|
-h, --help
|
||||||
|
Print help information (use `-h` for a summary)
|
||||||
|
|
||||||
|
-V, --version
|
||||||
|
Print version information
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### أمثلة
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bfy test_code/hello_world.bf
|
||||||
|
```
|
||||||
|
```text
|
||||||
|
Hello world!
|
||||||
|
Successfully ran brainfuck source code from file: test_code/hello_world.bf
|
||||||
|
Exiting with code: 0
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bfy -w test_code/hello_world.bf
|
||||||
|
```
|
||||||
|
```text
|
||||||
|
Hello world!
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bfy test_code/print_hi_yooo.bf
|
||||||
|
```
|
||||||
|
```text
|
||||||
|
Hi yoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Successfully ran brainfuck source code from file: test_code/print_hi_yooo.bf
|
||||||
|
Exiting with code: 0
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bfy -w test_code/print_hi_yooo.bf
|
||||||
|
```
|
||||||
|
```text
|
||||||
|
Hi yoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bfy test_code/like_cat.bf
|
||||||
|
```
|
||||||
|
![output](./screenshots/like_cat_output.png)
|
||||||
|
> ملاحظة: الإخراج ليس هو نفسه الإصدار الحالي للمترجم الفوري ، ولكنه مماثل لإخراج المترجم الفوري عندما أكتب الكود.
|
||||||
|
|
||||||
|
## REPL
|
||||||
|
```bash
|
||||||
|
bfy # REPL mode
|
||||||
|
```
|
||||||
|
![print @ and A in the repl](./screenshots/repl_print_at_and_A_0.1.0.png)
|
||||||
|
|
||||||
|
## لكى يفعل
|
||||||
|
- [ ] أضف المزيد من الاختبارات
|
||||||
|
- [ ] أضف المزيد من الأمثلة
|
||||||
|
- [ ] قم بإنشاء منسق brainfu * k
|
||||||
|
- [ ] أضف تمييز بناء الجملة في REPL
|
||||||
|
- [ ] أضف الإكمال التلقائي في REPL
|
||||||
|
- [ ] دعم ميزة حجم الصفيف الديناميكي
|
||||||
|
|
||||||
|
## مصادر
|
||||||
|
- [Brainfuck in Wikipedia](https://en.wikipedia.org/wiki/Brainfuck)
|
||||||
|
- [Programming in Brainfuck](http://cydathria.com/bf/brainfuck.html)
|
||||||
|
- [Brainfuck: An Eight-Instruction Turing-Complete Programming Language](http://www.muppetlabs.com/~breadbox/bf)
|
||||||
|
- [brainfuck-visualizer](https://github.com/usaikiran/brainfuck-visualizer)
|
||||||
|
- [Basics of BrainFuck](https://gist.github.com/roachhd/dce54bec8ba55fb17d3a)
|
||||||
|
- [An elegant programming language: Brainfuck](https://www.neperos.com/article/raqehg6b24ceadba)
|
11
README.md
|
@ -5,6 +5,15 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
# brainfuc*k interpreter: a simple brainfuc*k interpreter and REPL writen in rust 🦀
|
# brainfuc*k interpreter: a simple brainfuc*k interpreter and REPL writen in rust 🦀
|
||||||
|
#### *Read this in other languages.*
|
||||||
|
|
||||||
|
[AR Arabic-العربية](README-ar.md)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- Run brainfuc*k code from a file 💫
|
||||||
|
- Run brainfuc*k live code from the REPL 🚀
|
||||||
|
- Support utf-8 characters including emojis 😍 (optional)
|
||||||
|
- You can control in the array size 📏
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
@ -188,4 +197,4 @@ bfy # REPL mode
|
||||||
- [Brainfuck: An Eight-Instruction Turing-Complete Programming Language](http://www.muppetlabs.com/~breadbox/bf)
|
- [Brainfuck: An Eight-Instruction Turing-Complete Programming Language](http://www.muppetlabs.com/~breadbox/bf)
|
||||||
- [brainfuck-visualizer](https://github.com/usaikiran/brainfuck-visualizer)
|
- [brainfuck-visualizer](https://github.com/usaikiran/brainfuck-visualizer)
|
||||||
- [Basics of BrainFuck](https://gist.github.com/roachhd/dce54bec8ba55fb17d3a)
|
- [Basics of BrainFuck](https://gist.github.com/roachhd/dce54bec8ba55fb17d3a)
|
||||||
- [An elegant programming language: Brainfuck](https://www.neperos.com/article/raqehg6b24ceadba)
|
- [An elegant programming language: Brainfuck](https://www.neperos.com/article/raqehg6b24ceadba)
|
||||||
|
|
14
archpackage/.SRCINFO
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
pkgbase = bfy
|
||||||
|
pkgdesc = brainfuc*k interpreter: a simple brainfuc*k interpreter and REPL writen in rust 🦀🤪
|
||||||
|
pkgver = 0.1.1
|
||||||
|
pkgrel = 1
|
||||||
|
url = https://github.com/anas-elgarhy/bfy
|
||||||
|
arch = x86_64
|
||||||
|
license = MIT
|
||||||
|
makedepends = cargo
|
||||||
|
provides = bfy
|
||||||
|
replaces = bfy
|
||||||
|
source = bfy-0.1.1.tar.gz::https://static.crates.io/crates/bfy/bfy-0.1.1.crate
|
||||||
|
sha256sums = 7994e9b500c63e09e5ee47e72b5654c84a2130c968256cebb687fce94ec6c55b
|
||||||
|
|
||||||
|
pkgname = bfy
|
|
@ -1,6 +1,6 @@
|
||||||
# Maintainer: Anas Elgarhy <anas.elgarhy.dev@gmail.com>
|
# Maintainer: Anas Elgarhy <anas.elgarhy.dev@gmail.com>
|
||||||
pkgname=bfy
|
pkgname=bfy
|
||||||
pkgver=0.1.0
|
pkgver=0.1.1
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
epoch=
|
epoch=
|
||||||
pkgdesc="brainfuc*k interpreter: a simple brainfuc*k interpreter and REPL writen in rust 🦀🤪"
|
pkgdesc="brainfuc*k interpreter: a simple brainfuc*k interpreter and REPL writen in rust 🦀🤪"
|
||||||
|
@ -38,3 +38,4 @@ package() {
|
||||||
cd "$pkgname-$pkgver"
|
cd "$pkgname-$pkgver"
|
||||||
sudo install -Dm0755 -t "/usr/bin/" "target/release/$pkgname"
|
sudo install -Dm0755 -t "/usr/bin/" "target/release/$pkgname"
|
||||||
}
|
}
|
||||||
|
sha256sums=('7994e9b500c63e09e5ee47e72b5654c84a2130c968256cebb687fce94ec6c55b')
|
||||||
|
|
1
archpackage/bfy
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 56d11304b639b13de32b5bc850da6bd719bbc3a8
|
BIN
assets/cover.jpg
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 38 KiB |
BIN
assets/cover.png
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 79 KiB |
6
renovate.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:base"
|
||||||
|
]
|
||||||
|
}
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 92 KiB |
4
test_code/1000_to_100_counter.bf
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
++++++++++>>>>>+>>>+>>>+>+>>+[>++++++[-<[<<++++++++<]>>>[>>>]<<]<[<<.<]>>>[>>>]<
|
||||||
|
<++++++[-<[<<--------<]>>>[>>>]<<]<[<<<]<<.>>>>>[[-]<+<[->>+<<]>>[[-<<+>>]<->]<[
|
||||||
|
>+>>]<<<[-]>>>>]>>>[-<+>]<[->+<<<+>>]<<<<-[->+<]>[[-<+>]>+<]<<[<<+++++++++<]>>>[
|
||||||
|
>>>]<<<]<++++++[-<++++++>]<++.
|
6
test_code/fibonacci.bf
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
>++++++++++>+>+[
|
||||||
|
[+++++[>++++++++<-]>.<++++++[>--------<-]+<<<]>.>>[
|
||||||
|
[-]<[>+<-]>>[<<+>+>-]<[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
|
||||||
|
[>+<-[>+<-[>+<-[>[-]>+>+<<<-[>+<-]]]]]]]]]]]+>>>
|
||||||
|
]<<<
|
||||||
|
]
|