什么是 brainfuck-compiler
Brainfuck 是一种极为简单的编程语言,它由 a, b, x, y, z, ., +, -, <, > 十个基本操作组成。 Brainfuck 语言本身并没有指定特定的语义含义,只是一种非常基础的程序设计语言。
而 brainfuck-compiler 就是一个可以将 brainfuck 代码编译成 JavaScript 代码的 npm 包。在此,我们将会学习并掌握如何使用它。
安装 npm 包
首先,我们需要安装 node.js。请在命令行上输入以下代码:
---- --
如果您已经安装了 node.js,那么接下来您需要安装 npm 包,如下所示:
--- ------- ------------------
使用 brainfuck-compiler
在安装好 brainfuck-compiler 后,您就可以将 brainfuck 代码编译成 JavaScript 代码了。使用只需要两行代码:
----- -- - ------------------------------ ----- ------ - -------------------------------------------------------------------------------------------------------------------------
jsCode 里面就是编译完成的 JavaScript 代码。一个简单的示例可以这样:
----- -- - ------------------------------ ----- ------ - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- --- - --- - --- - --------- --------- -------------- - --- ----------- ---------------------- ------- --------- --- --------- ------------------------------------------------------------------------------------------------ ---- ------- -------------------------------- -- ------------------ --- --------- --------- -- ----------------------------------------------------------------------------------------------------------------------------------------------------------------- -- -------- ------ ------------ ----- ---- -- -------------------------------------- ------------- -- ------------------ --------------- --- ----- ---------- ------- --------- ----- ---- --- -- ----- --- ----- ---- --- ----- ----------- ----- ------------------- ----- --- --- --- -- ----------- ----------- --- --- ------ ---- - ----- ---- ----------------- ----- --- ----------------------------- ------------------------------ ------- ----- ----- -------------------------------------- ------- ----- -------- ------ ---------------- ------------------------- ------------------ --- -- ------------------------------------------------------------------------------ ---------- -----------------------------------------------------------------------------------------------------------------------------