3个版本
0.1.2 | 2023年7月16日 |
---|---|
0.1.1 | 2022年10月13日 |
0.1.0 | 2022年10月13日 |
在 编程语言 中排名第126
每月下载量25次
57KB
1.5K SLoC
brainfuc
用其他语言阅读此内容。
功能
- 从文件中运行brainfuc
- 从REPL中运行brainfuc
- 支持utf-8字符,包括emoji 😍(可选)
- 您可以控制数组的大小 📏
安装
- 从crates.io
cargo install bfy
- 从aur
yay -S bfy
选项和参数
选项表
选项
描述
默认
-h
, --help
打印帮助信息
-V
, --version
打印版本信息
-f
, --features
要启用的额外功能
可能值
- no-reverse-value
如果要减小的值且该值为0,则不要将值设置为255,否则减去该值。
如果要增加的值且该值为255,则不要将值设置为0,否则增加该值。别名:`nrv`
- reverse-pointer
如果指针在数组的末尾,则将指针设置为0,否则增加指针。
如果指针在数组的开始,则将指针设置为数组的末尾,否则减少指针。别名:`rp`
- allow-utf8
允许使用utf8字符(32位),否则只允许8位字符。
使用此功能时请谨慎,因为它将单元格大小从8位增加到32位。
它还允许您在Brainfu*k代码中使用emoji :D,这是如果您可以保持清醒,以便可以访问它们的数字值 :)
Rust中的`u32`只能存储从0到4294967295的值,但我们现在只能使用0到1114111 (0x10FFFF)。别名:`utf8`
n/a
-a
, --array-size
数组大小
30000
-w
, --without-tiles
不打印瓦片(例如退出代码、文件名等)
帮助选项输出
bfy --help
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
示例
bfy test_code/hello_world.bf
Hello world!
Successfully ran brainfuck source code from file: test_code/hello_world.bf
Exiting with code: 0
bfy -w test_code/hello_world.bf
Hello world!
bfy test_code/print_hi_yooo.bf
Hi yoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Successfully ran brainfuck source code from file: test_code/print_hi_yooo.bf
Exiting with code: 0
bfy -w test_code/print_hi_yooo.bf
Hi yoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!
bfy test_code/like_cat.bf

注意:输出与当前解释器版本不同,但它与我在编写代码时的解释器输出相同。
REPL
bfy # REPL mode

待办事项
- 添加更多测试
- 添加更多示例
- 创建Brainfuck格式化工具
- 在REPL中添加语法高亮
- 在REPL中添加自动完成功能
- 支持动态数组大小功能
资源
cargo install bfy
yay -S bfy
选项表
选项 | 描述 | 默认 |
---|---|---|
-h , --help |
打印帮助信息 | |
-V , --version |
打印版本信息 | |
-f , --features |
要启用的额外功能 可能值
|
n/a |
-a , --array-size |
数组大小 | 30000 |
-w , --without-tiles |
不打印瓦片(例如退出代码、文件名等) |
帮助选项输出
bfy --help
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
bfy test_code/hello_world.bf
Hello world!
Successfully ran brainfuck source code from file: test_code/hello_world.bf
Exiting with code: 0
bfy -w test_code/hello_world.bf
Hello world!
bfy test_code/print_hi_yooo.bf
Hi yoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!Successfully ran brainfuck source code from file: test_code/print_hi_yooo.bf
Exiting with code: 0
bfy -w test_code/print_hi_yooo.bf
Hi yoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!
bfy test_code/like_cat.bf

注意:输出与当前解释器版本不同,但它与我在编写代码时的解释器输出相同。
bfy # REPL mode

依赖项
~6–19MB
~228K SLoC