Extended brainfuck interpreter

Author: s | 2025-04-24

★★★★☆ (4.2 / 2883 reviews)

command.and.conquer general

Download eXtended BrainFuck interpreter 1.0 - A tiny BrainFuck interpreter. eXtended BrainFuck interpreter is a command line utility that offers users an interpreter for the Brainfuck programming

free customizable soundboard

GitHub - campbellcole/brainfuck-extended: A Brainfuck interpreter

--> Java BrainFuck解释器Brainfuck只由八个简单的命令和一个指令指针组成。虽然它是完全图灵完备的,但它并不是为了实际使用,而是为了挑战和娱乐程序员。BrainFuck只由8个字符命令组成,这使得它的使用即使对于简单的任务也非常具有挑战性 –>命令增加数据指针(指向右边的下一个单元)。+命令增加(增加1)数据指针的字节。命令”-“使数据指针上的字节减少(减少一个)。.命令输出数据指针上的字节。命令接受一个字节的输入,将其值存储在数据指针的字节中。[- 如果数据指针上的字节为0,那么不要将指令指针向前移动到下一条指令,而是将其向前跳到匹配的]指令之后。]- 如果数据指针上的字节为非零,那么与其将指令指针向前移动到下一条命令,不如跳回匹配的[ 命令后的命令。(另外,]命令可以被翻译成无条件跳转到相应的[]命令,反之亦然;程序的行为是一样的,但由于不必要的重复搜索,运行速度会更慢。)[和]的匹配通常与括号一样:每个[正好匹配一个],反之亦然,[在前,两者之间不能有未匹配的[或]。由于BrainFuck只由这8个命令组成,为BrainFuck建立一个解释器是非常简单的。在这篇文章中,我们将建立一个简单的程序,将BrainFuck代码作为输入并产生所需的输出:我们将简单地接受BrainFuck代码作为一个字符串,并通过解析该字符串和检查每个字符的实际功能来产生输出:内存由一个字节类型的数组表示,模拟从0到65534的最大65535位的内存(65535是可以用无符号16位二进制数表示的最高数字)。变量ptr指的是内存数组的当前索引。在这篇文章中,我们不会讨论在BrainFuck中编写程序的细节。例子Input : Output : Hello World!Input : Output : GEEKS FOR GEEKSBrainFuck解释器的Java实现-import java.util.*; class BrainFuck{ private static Scanner ob = new Scanner(System.in); private static int ptr; // Data pointer // Max memory limit. It is the highest number which // can be represented by an unsigned 16-bit binary // number. Many computer programming environments // beside brainfuck may have predefined // constant values representing 65535. private static int length = 65535; // Array of byte type simulating memory of max // 65535 bits from 0 to 65534. private static byte memory[] = new byte[length]; // Interpreter function which accepts the code // a string parameter private static void interpret(String s) { int c = 0; // Parsing through each character of the code for (int i = 0; i moves the pointer to the right if (s.charAt(i) == '>') { if (ptr == length - 1)//If memory is full ptr = 0;//pointer is returned to zero else ptr ++; } // 0 || s.charAt(i) != ']') { if (s.charAt(i) == '[') c++; else if (s.charAt(i) == ']') c--; i ++; } } } // ] jumps back to the matching [ if the // cell under the pointer is nonzero else if (s.charAt(i) == ']') { if (memory[ptr] != 0) { i --; while (c > 0 || s.charAt(i) != '[') { if (s.charAt(i) == ']') c ++; else if (s.charAt(i) == '[') c --; i --; } } } } } // Driver code public static void main(String args[]) { System.out.println("Enter the code:"); String code = ob.nextLine(); System.out.println("Output:"); interpret(code); }}输出1Enter the code:--[+++++++>-->+>+>+---.>--..>+.->>.+++[.输出2Enter the code:++++++++++[>+++++++>++++++++>+++++.. Download eXtended BrainFuck interpreter 1.0 - A tiny BrainFuck interpreter. eXtended BrainFuck interpreter is a command line utility that offers users an interpreter for the Brainfuck programming Here are 19 public repositories matching this topic... Code Issues Pull requests This project focuses on understanding the language ecosystem Updated Oct 7, 2023 Python Code Issues Pull requests Discussions Multi-client Cross-platform Python Backdoor/Reverse Shell/RAT with AES Encryption Updated Jul 20, 2024 Python Code Issues Pull requests Tiny calculator interpreter with supporting Mathematical functions using Python. Updated Jul 24, 2020 Python Code Issues Pull requests A Discord bot that can interpret python code. Updated Mar 12, 2022 Python Code Issues Pull requests This is a discord bot that allows you to quickly calculate and graph math. Updated May 10, 2023 Python Code Issues Pull requests The Natscript interpreter, a custom programming language, with a natural English-like syntax. Updated Mar 3, 2025 Python Code Issues Pull requests 🈶 An Interpreter of the language Befunge written in Python Updated Dec 5, 2021 Python Code Issues Pull requests Python interpreter based on expressions and functions. The input and output of this interpreter will be through a web interface, although a command line interface is also provided. Updated Jan 28, 2023 Python Code Issues Pull requests A Python Interpreter written purely in Python Updated Jun 8, 2022 Python Code Issues Pull requests Updated Dec 13, 2020 Python Code Issues Pull requests An interactive python interpreter for your command line. Updated Apr 10, 2019 Python Code Issues Pull requests 一个用 python 实现的简单python解释器,分版本逐步实现一个简单的python解释器功能,适合初学者了解解释器的工作原理。 Updated Mar 14, 2025 Python Code Issues Pull requests Just what it sounds like, decorator that patches function bytecode to allow GOTO's *ROFL* Updated Apr 3, 2023 Python Code Issues Pull requests About Python's multithreading and GIL Updated Feb 7, 2025 Python Code Issues Pull requests Discussions A cool bot named BOSA-bot that will do a lot of general commands, and will have many new commands added through active development. Updated May 18, 2022 Python Code Issues Pull requests Developed a new scripting language in which we can visualize the data structures like Arrays, Stacks, Queues etc., and their performed operations. Updated Nov 15, 2020 Python Code Issues Pull requests PYON ROBOT - UI Test Automation with Robot Framework Updated Jun 16, 2021 Python Code Issues Pull requests A simple Python Interpreter for the Brainfuck Esoteric Language. Updated Sep 27, 2021 Python Code Issues Pull requests Interpretador da Linguagem Interpretada de Manipulação de Pilha (LIMPIL) Updated Feb 28, 2024 Python Improve this page Add a description, image, and links to the python-interpreter topic page so that developers can more easily learn about it. Curate this topic Add this topic to your repo To associate your repository with the python-interpreter topic, visit your repo's landing page and select "manage topics." Learn more

Comments

User1325

--> Java BrainFuck解释器Brainfuck只由八个简单的命令和一个指令指针组成。虽然它是完全图灵完备的,但它并不是为了实际使用,而是为了挑战和娱乐程序员。BrainFuck只由8个字符命令组成,这使得它的使用即使对于简单的任务也非常具有挑战性 –>命令增加数据指针(指向右边的下一个单元)。+命令增加(增加1)数据指针的字节。命令”-“使数据指针上的字节减少(减少一个)。.命令输出数据指针上的字节。命令接受一个字节的输入,将其值存储在数据指针的字节中。[- 如果数据指针上的字节为0,那么不要将指令指针向前移动到下一条指令,而是将其向前跳到匹配的]指令之后。]- 如果数据指针上的字节为非零,那么与其将指令指针向前移动到下一条命令,不如跳回匹配的[ 命令后的命令。(另外,]命令可以被翻译成无条件跳转到相应的[]命令,反之亦然;程序的行为是一样的,但由于不必要的重复搜索,运行速度会更慢。)[和]的匹配通常与括号一样:每个[正好匹配一个],反之亦然,[在前,两者之间不能有未匹配的[或]。由于BrainFuck只由这8个命令组成,为BrainFuck建立一个解释器是非常简单的。在这篇文章中,我们将建立一个简单的程序,将BrainFuck代码作为输入并产生所需的输出:我们将简单地接受BrainFuck代码作为一个字符串,并通过解析该字符串和检查每个字符的实际功能来产生输出:内存由一个字节类型的数组表示,模拟从0到65534的最大65535位的内存(65535是可以用无符号16位二进制数表示的最高数字)。变量ptr指的是内存数组的当前索引。在这篇文章中,我们不会讨论在BrainFuck中编写程序的细节。例子Input : Output : Hello World!Input : Output : GEEKS FOR GEEKSBrainFuck解释器的Java实现-import java.util.*; class BrainFuck{ private static Scanner ob = new Scanner(System.in); private static int ptr; // Data pointer // Max memory limit. It is the highest number which // can be represented by an unsigned 16-bit binary // number. Many computer programming environments // beside brainfuck may have predefined // constant values representing 65535. private static int length = 65535; // Array of byte type simulating memory of max // 65535 bits from 0 to 65534. private static byte memory[] = new byte[length]; // Interpreter function which accepts the code // a string parameter private static void interpret(String s) { int c = 0; // Parsing through each character of the code for (int i = 0; i moves the pointer to the right if (s.charAt(i) == '>') { if (ptr == length - 1)//If memory is full ptr = 0;//pointer is returned to zero else ptr ++; } // 0 || s.charAt(i) != ']') { if (s.charAt(i) == '[') c++; else if (s.charAt(i) == ']') c--; i ++; } } } // ] jumps back to the matching [ if the // cell under the pointer is nonzero else if (s.charAt(i) == ']') { if (memory[ptr] != 0) { i --; while (c > 0 || s.charAt(i) != '[') { if (s.charAt(i) == ']') c ++; else if (s.charAt(i) == '[') c --; i --; } } } } } // Driver code public static void main(String args[]) { System.out.println("Enter the code:"); String code = ob.nextLine(); System.out.println("Output:"); interpret(code); }}输出1Enter the code:--[+++++++>-->+>+>+---.>--..>+.->>.+++[.输出2Enter the code:++++++++++[>+++++++>++++++++>+++++..

2025-04-07
User7501

Here are 19 public repositories matching this topic... Code Issues Pull requests This project focuses on understanding the language ecosystem Updated Oct 7, 2023 Python Code Issues Pull requests Discussions Multi-client Cross-platform Python Backdoor/Reverse Shell/RAT with AES Encryption Updated Jul 20, 2024 Python Code Issues Pull requests Tiny calculator interpreter with supporting Mathematical functions using Python. Updated Jul 24, 2020 Python Code Issues Pull requests A Discord bot that can interpret python code. Updated Mar 12, 2022 Python Code Issues Pull requests This is a discord bot that allows you to quickly calculate and graph math. Updated May 10, 2023 Python Code Issues Pull requests The Natscript interpreter, a custom programming language, with a natural English-like syntax. Updated Mar 3, 2025 Python Code Issues Pull requests 🈶 An Interpreter of the language Befunge written in Python Updated Dec 5, 2021 Python Code Issues Pull requests Python interpreter based on expressions and functions. The input and output of this interpreter will be through a web interface, although a command line interface is also provided. Updated Jan 28, 2023 Python Code Issues Pull requests A Python Interpreter written purely in Python Updated Jun 8, 2022 Python Code Issues Pull requests Updated Dec 13, 2020 Python Code Issues Pull requests An interactive python interpreter for your command line. Updated Apr 10, 2019 Python Code Issues Pull requests 一个用 python 实现的简单python解释器,分版本逐步实现一个简单的python解释器功能,适合初学者了解解释器的工作原理。 Updated Mar 14, 2025 Python Code Issues Pull requests Just what it sounds like, decorator that patches function bytecode to allow GOTO's *ROFL* Updated Apr 3, 2023 Python Code Issues Pull requests About Python's multithreading and GIL Updated Feb 7, 2025 Python Code Issues Pull requests Discussions A cool bot named BOSA-bot that will do a lot of general commands, and will have many new commands added through active development. Updated May 18, 2022 Python Code Issues Pull requests Developed a new scripting language in which we can visualize the data structures like Arrays, Stacks, Queues etc., and their performed operations. Updated Nov 15, 2020 Python Code Issues Pull requests PYON ROBOT - UI Test Automation with Robot Framework Updated Jun 16, 2021 Python Code Issues Pull requests A simple Python Interpreter for the Brainfuck Esoteric Language. Updated Sep 27, 2021 Python Code Issues Pull requests Interpretador da Linguagem Interpretada de Manipulação de Pilha (LIMPIL) Updated Feb 28, 2024 Python Improve this page Add a description, image, and links to the python-interpreter topic page so that developers can more easily learn about it. Curate this topic Add this topic to your repo To associate your repository with the python-interpreter topic, visit your repo's landing page and select "manage topics." Learn more

2025-03-25
User6029

Lambda, accept HTTP request events and return HTTP responses. To work correctly, we will configure API Gateway. It will redirect all the requests to AWS Lambda and return responses to the user.Follow the same steps from CLI to create the brainfuck_aws application inside the workspace:Dependency definitionTo work with API Gateway and lambda, we should use the official lambda_http crate. It has all the required structures to work with them.We also need to serialize and deserialize all the inputs/outputs. We use serde and serde_json for that. Tokio is used to provide asynchronous I/O runtime for our application. Lastly, we use env_logger and log to provide logging functionality. The runtime will send them to Cloudwatch.[dependencies]brainfuck_interpreter = { path = '../brainfuck_interpreter' }lambda_http = "0.5"serde_json = "1.0"serde = "1.0"tokio = "1.0"env_logger = "0.9"log = "0.4"Application codeRequest and response typesOur request should contain the source code and the input:#[derive(Deserialize)]struct InterpreterRequest { source: String, input: OptionString>,}The response should return either the result of successful execution or an error message:#[derive(Serialize, Debug)]#[serde(rename_all = "lowercase")]enum InterpreterResponse { Success(String), Error(String),}Main codeDuring the startup, we should enable logging and start lambda runtime:#[tokio::main]async fn main() -> Result(), Error> { env_logger::init(); info!("Starting lambda function!"); let func = service_fn(func); lambda_http::run(func).await?; Ok(())}Lambda runtime will execute our func function every time on event fire. This function should process the request. Depending on the interpreter execution result, it will return either 200 OK with the stdout, or 400 BAD REQUEST with the error description:async fn func(event: Request) -> Resultimpl IntoResponse, Error> { debug!("Received request: {:?}", event); info!("Processing request!"); match process_request(event).await { Ok(result) => Ok(Response::builder() .status(200) .body(serde_json::to_string(&result)?)?), Err(error) => Ok(Response::builder().status(400).body(serde_json::to_string( &InterpreterResponse::Error(error.to_string()), )?)?), }}Before the execution, we should parse the payload. If it’s not a valid payload, we can return an error. Otherwise, we can start code parsing and execution. In case of any error’s inside the brainfuck library, we will return them; otherwise, we will return stdout:async fn process_request(request: Request) -> ResultInterpreterResponse, Error> { if let Some(request) = request.payload::InterpreterRequest>()? { debug!("Body is valid. Processing request"); let source = request.source; let input = request.input.unwrap_or(String::new()); let stdin = Box::new(input.as_bytes()); let result = match interpret(&source, stdin) { Ok(output) => InterpreterResponse::Success(output), Err(error) => InterpreterResponse::Error(error.to_string()), }; info!("Interpreter result: {:?}", result); Ok(result) } else { warn!("Can't process request. Invalid body"); Err("Invalid body")? }}Template definitionWe will use SAM (Serverless application mode) to simplify our deployment to AWS. SAM allows specifying only the function you need and required endpoints. Under the hood, it will create API Gateway, AWS Lambda, IAM Roles, Databases, etc.In this example, we need AWS Lambda that API Gateway will call. It will be called BrainfuckFunction, use x86_64 architecture and Amazon Linux 2 runtime. API Gateway will provide a POST /brainfuck endpoint that triggers AWS Lambda.AWSTemplateFormatVersion: '2010-09-09'Transform: AWS::Serverless-2016-10-31Resources: BrainfuckFunction: Type: AWS::Serverless::Function Properties: MemorySize:

2025-04-10
User2467

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters require './brainfuck' describe Brainfuck do describe '#eval' do describe '+' do it 'increments the memory location correctly' do brainfuck = Brainfuck.new brainfuck.eval('+') expect(brainfuck.memory[0]).to eq(1) brainfuck.eval('++') expect(brainfuck.memory[0]).to eq(3) brainfuck.eval('++++++') expect(brainfuck.memory[0]).to eq(9) end end describe '-' do it 'decrements the current memory location correctly' do brainfuck = Brainfuck.new brainfuck.eval('++++++++++') # increment by 10 expect(brainfuck.memory[0]).to eq(10) brainfuck.eval('--') expect(brainfuck.memory[0]).to eq(8) brainfuck.eval('---') expect(brainfuck.memory[0]).to eq(5) end end describe '>' do it 'increments the memory location' do brainfuck = Brainfuck.new brainfuck.eval('>+') expect(brainfuck.memory[1]).to eq(1) brainfuck.eval('>>>>++') expect(brainfuck.memory[5]).to eq(2) end end describe ' do it 'decrements the memory location' do brainfuck = Brainfuck.new brainfuck.eval('>) expect(brainfuck.memory[0]).to eq(1) brainfuck.eval('>>>>) expect(brainfuck.memory[0]).to eq(3) end end describe ',' do it 'reads a char and places it at the memory location in numeric form' do input = StringIO.new('ABCDEF') brainfuck = Brainfuck.new(input) brainfuck.eval(',') expect(brainfuck.memory[0]).to eq('A'.ord) brainfuck.eval('>,') expect(brainfuck.memory[1]).to eq('B'.ord) brainfuck.eval('>,') expect(brainfuck.memory[2]).to eq('C'.ord) brainfuck.eval(',,,') expect(brainfuck.memory[2]).to eq('F'.ord) end end describe '.' do it 'prints the char at the current memory location' do input = StringIO.new('ABCDEF') output = StringIO.new brainfuck = Brainfuck.new(input, output) brainfuck.eval('+'*65) expect(brainfuck.memory[0]).to eq('A'.ord) brainfuck.eval('.') output.rewind expect(output.getc).to eq('A') end end describe 'loops' do describe '[' do context 'if the current memory location is zero' do it 'jumps executes the code after the matching ] bracket' do brainfuck = Brainfuck.new brainfuck.eval('[[++++]]++') expect(brainfuck.memory[0]).to eq(2) brainfuck.eval('--[[++++]]++') expect(brainfuck.memory[0]).to eq(2) brainfuck.eval('--[++++]++++>[++++]++++') expect(brainfuck.memory[0]).to eq(4) expect(brainfuck.memory[1]).to eq(4) end end context 'if the current memory locatoin is not zero' do it 'executes the code right after' do brainfuck = Brainfuck.new brainfuck.eval('+[-]') expect(brainfuck.memory[0]).to eq(0) end end end describe ']' do context 'if the current memory location is not zero' do it 'jumps back to the code right after the matching [ bracket' do brainfuck = Brainfuck.new brainfuck.eval('++++[->+) expect(brainfuck.memory[0]).to eq(0) expect(brainfuck.memory[1]).to eq(4) end end end end describe 'hello world' do let(:hello_world) do '++++++++[>++++[>++>+++>+++>++>+>->>+[>.>---.+++++++..+++.>>.>+.>++.' end it 'prints "Hello World!"' do input = StringIO.new output = StringIO.new brainfuck = Brainfuck.new(input, output) brainfuck.eval(hello_world) output.rewind expect(output.gets).to eq("Hello World!\n") end end end end

2025-04-16
User2032

Handle errors and return the error message:curl -X POST -H "Content-Type: application/json" -d '{"source":",[.,"}' | jq{ "error": "Error parsing source: `Expected end of loop`"}curl -X POST -H "Content-Type: application/json" -d '{"INPUT":""}' | jq{ "error": "failed to parse payload from application/json missing field `source` at line 1 column 12\n"}You can also access AWS Cloudwatch to see the generated logs.START RequestId: b79d600c-3eb1-4623-9072-b19aefecb5b1 Version: $LATESTEND RequestId: b79d600c-3eb1-4623-9072-b19aefecb5b1REPORT RequestId: b79d600c-3eb1-4623-9072-b19aefecb5b1 Duration: 1.40 ms Billed Duration: 28 ms Memory Size: 128 MB Max Memory Used: 12 MB Init Duration: 26.36 ms START RequestId: 23023dfd-31dd-4b28-bbe3-ad52ef805d29 Version: $LATESTEND RequestId: 23023dfd-31dd-4b28-bbe3-ad52ef805d29REPORT RequestId: 23023dfd-31dd-4b28-bbe3-ad52ef805d29 Duration: 1.18 ms Billed Duration: 2 ms Memory Size: 128 MB Max Memory Used: 12 MB START RequestId: 42f09c1b-b33c-4b45-8ab3-47489ec4e7ee Version: $LATESTEND RequestId: 42f09c1b-b33c-4b45-8ab3-47489ec4e7eeREPORT RequestId: 42f09c1b-b33c-4b45-8ab3-47489ec4e7ee Duration: 1.05 ms Billed Duration: 2 ms Memory Size: 128 MB Max Memory Used: 13 MB It will not print any logs for us by default because info and debug logs are ignored. However, you can modify the behavior without redeploying the code!You should follow the steps:Open AWS Lambda.Open your Brainfuck function.Go to configuration.Open environment variables tab.Click edit.Enter RUST_LOG as a key and DEBUG as a value.Save.Now you should be able to see all the logs generated by our application.[2022-03-17T11:33:54Z INFO brainfuck_aws] Processing request![2022-03-17T11:33:54Z DEBUG brainfuck_aws] Body is valid. Processing request[2022-03-17T11:33:54Z INFO brainfuck_aws] Interpreter result: Success("hello")[2022-03-17T11:33:54Z DEBUG hyper::client::pool] reuse idle connection for ("http", 127.0.0.1:9001)[2022-03-17T11:33:54Z DEBUG hyper::proto::h1::io] flushed 283 bytes[2022-03-17T11:33:54Z DEBUG hyper::proto::h1::io] parsed 3 headers[2022-03-17T11:33:54Z DEBUG hyper::proto::h1::conn] incoming body is content-length (16 bytes)[2022-03-17T11:33:54Z DEBUG hyper::proto::h1::conn] incoming body completed[2022-03-17T11:33:54Z DEBUG hyper::client::pool] pooling idle connection for ("http", 127.0.0.1:9001)[2022-03-17T11:33:54Z DEBUG hyper::client::pool] reuse idle connection for ("http", 127.0.0.1:9001)[2022-03-17T11:33:54Z DEBUG hyper::proto::h1::io] flushed 109 bytesEND RequestId: 549acd63-0bf0-498c-896a-c18e82c9b53eREPORT RequestId: 549acd63-0bf0-498c-896a-c18e82c9b53e Duration: 1.62 ms Billed Duration: 31 ms Memory Size: 128 MB Max Memory Used: 13 MB Init Duration: 28.76 ms START RequestId: 2f28bf67-da9a-4a85-bd82-f901370e3fb0 Version: $LATEST[2022-03-17T11:33:55Z DEBUG hyper::proto::h1::io] parsed 7 headers[2022-03-17T11:33:55Z DEBUG hyper::proto::h1::conn] incoming body is chunked encodingSummaryThis article continues Brainfuck interpreter series. We implemented CLI and AWS Lambda applications that used the brainfuck_interpreter library from the previous tutorial. It presents to you that Rust is flexible, and the same code can be used anywhere!You can deploy AWS Lambda application easily with the help of SAM CLI. You can configure the behavior of your application by editing *environment variablesin yourLambda`. Of course, you can deploy your application manually, but be aware that you need to compile it to musl architecture because of the runtime.You can view the final code in my public repo.

2025-04-06

Add Comment