{"id":14974082,"url":"https://github.com/shuber/pg_brainfuck","last_synced_at":"2026-02-23T12:56:30.893Z","repository":{"id":66255113,"uuid":"197502809","full_name":"shuber/pg_brainfuck","owner":"shuber","description":"plpgsql brainfuck implementation","archived":false,"fork":false,"pushed_at":"2019-07-18T03:53:34.000Z","size":2,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-27T04:26:54.872Z","etag":null,"topics":["brainfuck","interpreter","plpgsql","postgresql","sql"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shuber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-07-18T03:15:28.000Z","updated_at":"2021-07-06T23:25:00.000Z","dependencies_parsed_at":"2023-02-20T18:45:30.198Z","dependency_job_id":null,"html_url":"https://github.com/shuber/pg_brainfuck","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shuber/pg_brainfuck","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuber%2Fpg_brainfuck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuber%2Fpg_brainfuck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuber%2Fpg_brainfuck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuber%2Fpg_brainfuck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuber","download_url":"https://codeload.github.com/shuber/pg_brainfuck/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuber%2Fpg_brainfuck/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29743662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["brainfuck","interpreter","plpgsql","postgresql","sql"],"created_at":"2024-09-24T13:49:55.698Z","updated_at":"2026-02-23T12:56:30.877Z","avatar_url":"https://github.com/shuber.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg_brainfuck\n\n* https://en.wikipedia.org/wiki/Brainfuck\n* https://esolangs.org/wiki/Brainfuck_implementations\n\n```sql\n-- Hello, World!\nselect brainfuck('+[--\u003e-[\u003e\u003e+\u003e-----\u003c\u003c]\u003c--\u003c---]\u003e-.\u003e\u003e\u003e+.\u003e\u003e..+++[.\u003e]\u003c\u003c\u003c\u003c.+++.------.\u003c\u003c-.\u003e\u003e\u003e\u003e+.');\n\n-- test from stdin\nselect brainfuck(',[.,]', 'test from stdin'::bytea);\nselect brainfuck(',[.[-],]', 'test from stdin'::bytea);\nselect brainfuck(',[\u003e,]\u003c[.\u003c]', 'nidts morf tset'::bytea);\n```\n\n```sql\ncreate or replace function brainfuck(\n  in program text,\n  in stdin bytea default ''::bytea,\n  out stdout text\n) as $$\n  declare\n    commands text[] := regexp_split_to_array(program, '');\n    commands_size int := array_upper(commands, 1);\n\n    cells int[] := array[]::int[];\n    jumps int[] := array[]::int[];\n    stack int[] := array[]::int[];\n\n    depth int;\n    index int := 1;\n    pointer int := 0;\n    read int := 0;\n    subindex int;\n  begin\n    while index \u003c= commands_size loop\n      case commands[index]\n      when '\u003e' then\n        pointer = pointer + 1;\n      when '\u003c' then\n        pointer = pointer - 1;\n      when '+' then\n        cells[pointer] = coalesce(cells[pointer], 0) + 1;\n        cells[pointer] = coalesce(nullif(cells[pointer], 256), 0);\n      when '-' then\n        cells[pointer] = coalesce(cells[pointer], 0) - 1;\n        cells[pointer] = coalesce(nullif(cells[pointer], -1), 255);\n      when '.' then\n        continue when coalesce(cells[pointer], 0) = 0;\n        stdout = coalesce(stdout, '') || chr(cells[pointer]);\n      when ',' then\n        begin\n          cells[pointer] = get_byte(stdin, read);\n          read = read + 1;\n        exception when array_subscript_error then\n          index = index + 1;\n        end;\n      when ']' then\n        if array_length(stack, 1) \u003e 0 then\n          subindex = stack[array_upper(stack, 1)];\n          stack = array_remove(stack, subindex);\n          jumps[subindex] = index;\n          index = subindex - 1;\n        end if;\n      when '[' then\n        if coalesce(cells[pointer], 0) != 0 then\n          stack = array_append(stack, index);\n        elsif jumps[index] is not null then\n          index = jumps[index];\n        else\n          depth = 1;\n          index = index + 1;\n          subindex = index;\n\n          while subindex \u003c= commands_size loop\n            case commands[subindex]\n            when '[' then depth = depth + 1;\n            when ']' then depth = depth - 1;\n            else end case;\n\n            if depth = 0 then\n              jumps[index] = subindex;\n              index = subindex;\n              exit;\n            end if;\n\n            subindex = subindex + 1;\n          end loop;\n        end if;\n      else end case;\n\n      index = index + 1;\n    end loop;\n  end;\n$$ language plpgsql immutable;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuber%2Fpg_brainfuck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuber%2Fpg_brainfuck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuber%2Fpg_brainfuck/lists"}