{"id":15288100,"url":"https://github.com/aionescu/oplang","last_synced_at":"2025-04-13T06:32:10.537Z","repository":{"id":38845561,"uuid":"225973800","full_name":"aionescu/oplang","owner":"aionescu","description":"Stack-based esoteric programming language","archived":false,"fork":false,"pushed_at":"2025-01-31T07:46:42.000Z","size":246,"stargazers_count":18,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-12T18:52:25.657Z","etag":null,"topics":["compiler","esoteric-language","haskell","stack-based"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aionescu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2019-12-04T23:11:04.000Z","updated_at":"2025-02-24T02:29:54.000Z","dependencies_parsed_at":"2023-12-28T02:37:51.256Z","dependency_job_id":"f10157ee-083e-45da-adcc-2cc87d9439cf","html_url":"https://github.com/aionescu/oplang","commit_stats":{"total_commits":119,"total_committers":1,"mean_commits":119.0,"dds":0.0,"last_synced_commit":"059b689d2268535d8db2391134cd96312239103f"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aionescu%2Foplang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aionescu%2Foplang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aionescu%2Foplang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aionescu%2Foplang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aionescu","download_url":"https://codeload.github.com/aionescu/oplang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248674660,"owners_count":21143760,"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":["compiler","esoteric-language","haskell","stack-based"],"created_at":"2024-09-30T15:44:07.750Z","updated_at":"2025-04-13T06:32:09.971Z","avatar_url":"https://github.com/aionescu.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oplang\n\n[![Hackage](https://img.shields.io/hackage/v/oplang?style=for-the-badge)](https://hackage.haskell.org/package/oplang)\n\nOpLang is a stack-based esoteric programming language based on [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck).\n\n## Installing\n\nThe compiler is available on [Hackage](https://hackage.haskell.org/package/oplang), and can be installed via [cabal](https://www.haskell.org/cabal/) (which can itself be installed via [ghcup](https://www.haskell.org/ghcup/)).\n\n```sh\ncabal install oplang\n```\n\n## Usage\n\nTo compile and run an OpLang program, use:\n\n```sh\noplang code.op\n./code.out\n```\n\nFor a list of available command-line options, use `oplang --help`.\n\n## Building from source\n\nPrerequisites:\n\n* `GHC` \u003e=9.2\n* `cabal` \u003e=3.6\n\n(Both can be installed via [ghcup](https://www.haskell.org/ghcup/))\n\nTo build the project, use `cabal build`.\n\nTo run the project locally (without installing), use `cabal run . -- \u003cargs\u003e`.\n\n## Language features\n\nOpLang is a strict superset of Brainfuck.\n\nIts main improvement is the addition of user-defined operators, which are analogous to user-defined functions in languages like C or Python.\n\nThe \"memory tape\" in OpLang is specific to each operator invocation (akin to the stack frames of functions in C), and there is a separate \"stack\" which persists across operator invocations.\n\nEach cell in the tape(s) and stack is 1 byte, and overflow/underflow is allowed.\n\nThe default sizes of the stack and of memory tapes is 4KB. These defaults can be individually modified via command-line arguments.\n\n### Syntax\n\nOpLang has 10 built-in operators, 8 of which are the Brainfuck operators, with the same semantics:\n\n* `+`: Increment the current cell\n* `-`: Decrement the current cell\n* `\u003c`: Move the current cell pointer to the left\n* `\u003e`: Move the current cell pointer to the right\n* `,`: Read a character from stdin and store its ASCII value in the current cell\n* `.`: Interpret the current cell as an ASCII character and print it to stdout\n* `[`: Begin a loop (i.e. if the value at the current cell is zero, jump to the next `]`)\n* `]`: End a loop (i.e. if the value at the current cell is non-zero, jump to the previous `[`)\n\nAnd 2 of them are new operators that modify the stack:\n\n* `;`: Pop a value from the stack and store it into the current cell\n* `:`: Push the value of the current cell onto the stack\n\nAn OpLang program consists of a series of custom operator definitions, followed by the \"toplevel\" (similar to a `main()` function in other languages).\n\nAn operator definition consists of the operator's name, followed by the operator's body, enclosed in `{`/`}`.\n\nSingle-line comments are supported, and are introduced by the `#` character.\n\nHere's a simple program that reads a character from stdin, adds 3 to it, and prints it back:\n\n```oplang\na { ; +++ : }\n,: a ;.\n```\n\nFor more example programs, see the [examples](examples/) directory.\n\n## Compiler architecture\n\nThe compiler works by translating the input OpLang source into C, and then compiling that using the system's C compiler. To use a different C compiler, set the `CC` environment variable.\n\nThe compiler uses an intermediate representation (which can be shown with the `--dump-ir` option) on which it performs a number of optimizations, generating C code that is much smaller and faster than a direct translation would yield.\n\n## License\n\nThis repository is licensed under the terms of the GNU General Public License v3.\n\nFor more details, see [the license file](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faionescu%2Foplang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faionescu%2Foplang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faionescu%2Foplang/lists"}