{"id":19765076,"url":"https://github.com/azhovan/brainfuck","last_synced_at":"2026-05-14T10:40:24.887Z","repository":{"id":57653824,"uuid":"226705125","full_name":"Azhovan/brainfuck","owner":"Azhovan","description":"A brain fuck interpreter implementation with Golang","archived":false,"fork":false,"pushed_at":"2019-12-19T08:00:07.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-11T00:09:59.951Z","etag":null,"topics":["brain-fuck-interpreter","brainfuck","golang","interpreter","lexer","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Azhovan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-08T17:29:57.000Z","updated_at":"2020-03-02T19:32:14.000Z","dependencies_parsed_at":"2022-08-26T06:41:53.844Z","dependency_job_id":null,"html_url":"https://github.com/Azhovan/brainfuck","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Azhovan%2Fbrainfuck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Azhovan%2Fbrainfuck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Azhovan%2Fbrainfuck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Azhovan%2Fbrainfuck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Azhovan","download_url":"https://codeload.github.com/Azhovan/brainfuck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241096310,"owners_count":19908960,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brain-fuck-interpreter","brainfuck","golang","interpreter","lexer","parser"],"created_at":"2024-11-12T04:16:34.956Z","updated_at":"2026-05-14T10:40:24.857Z","avatar_url":"https://github.com/Azhovan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\nPackage `brainfuck` implements a brain fuck interpreter.\n\n#### Basics\nInterpreting occurs in three steps. \n\nFirst, the `Lexer` breaks up a stream of code\npoints (runes) into tokens.\n\nThese tokens represent the basic units of brain fuck syntax tree, such as whitespace, identifiers (like: \u003e \u003c + - . ,) and loops ( [ ] ).\n\nEach scan returns a single token.\n\ntypes: \n```go \n\tIllegalToken       \n\tLeftToken             // \u003c\n\tRightToken            // \u003e\n\tPlusToken             // +\n\tMinusToken            // -\n\tPrintToken            // .\n\tReadToken             // ,\n\tLeftBracketToken      // [\n\tRightBracketToken     // ]\n\tWhitespaceToken      \n\t\n```\n\n- The second step is to feed these tokens into the parser which creates the abstract syntax tree (AST) based on\nthe context of the tokens. below you will see a simple AST.\n\n```go\n{\n    {t:Token{Tok:MinusToken, Value:\"-\"}, c:1},\n    {t:Token{Tok:LeftBracketToken, Value:\"[\"}, c:7},\n    {t:Token{Tok:MinusToken, Value:\"-\"}, c:2},\n    {t:Token{Tok:LeftBracketToken, Value:\"[\"}, c:5},\n    {t:Token{Tok:PlusToken, Value:\"+\"}, c:1},\n    {t:Token{Tok:RightBracketToken, Value:\"]\"}, c:3},\n    {t:Token{Tok:MinusToken, Value:\"-\"}, c:2},\n    {t:Token{Tok:RightBracketToken, Value:\"]\"}, c:1},\n}\n```\n- The last step is to execute the produced instructions in step two by interpreter.\n\nAbstract syntax tree, is very simple but not flat. The first level is simply contains\nidentifiers (like: \u003e \u003c + - . ,). The second level contains the loops and it's internal\nblocks ( which can contains identifiers and loop block again), etc.\n\n#### How to use\n\n\t// create new io.Reader from inputs\n\tcode := strings.NewReader(\"----[----\u003e+\u003c]\u003e++.+.+.+.\")\n\t\n\t// initialize the Parser with input\n\tparser := brainfuck.NewParser(code)\n\t\n\t// Standards interface to io\n\tinput := new(bytes.Buffer)\n\toutput := new(bytes.Buffer)\n\t\n\t// initialize the machine\n\tbfm := brainfuck.NewInterpreter(input, output, parser)\n\t\n    // Store the result in output interface \n\t_ = bfm.Run()\n\t\n\t// print the result \n\tfmt.Println (output.String())\n\t\n#### How to run tests\n\nTo run all tests in the root of the project run `go test ./...` command.\n\n#### \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazhovan%2Fbrainfuck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazhovan%2Fbrainfuck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazhovan%2Fbrainfuck/lists"}