{"id":13714021,"url":"https://github.com/stefanovazzocell/ToyLanguage","last_synced_at":"2025-05-07T00:34:39.151Z","repository":{"id":155750445,"uuid":"528699159","full_name":"stefanovazzocell/ToyLanguage","owner":"stefanovazzocell","description":"A brainf**k interpreter with extensions","archived":false,"fork":false,"pushed_at":"2022-08-31T00:33:43.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-03T23:29:32.138Z","etag":null,"topics":["brainfuck","brainfuck-interpreter","go","golang","interpreter","networking"],"latest_commit_sha":null,"homepage":"","language":"Go","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/stefanovazzocell.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}},"created_at":"2022-08-25T04:54:24.000Z","updated_at":"2022-12-02T17:18:50.000Z","dependencies_parsed_at":"2024-05-18T01:57:56.647Z","dependency_job_id":"ef171785-101e-4323-ab8a-2c129c82d361","html_url":"https://github.com/stefanovazzocell/ToyLanguage","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/stefanovazzocell%2FToyLanguage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanovazzocell%2FToyLanguage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanovazzocell%2FToyLanguage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanovazzocell%2FToyLanguage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanovazzocell","download_url":"https://codeload.github.com/stefanovazzocell/ToyLanguage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224551123,"owners_count":17330074,"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":["brainfuck","brainfuck-interpreter","go","golang","interpreter","networking"],"created_at":"2024-08-02T23:01:50.254Z","updated_at":"2024-11-14T01:30:27.603Z","avatar_url":"https://github.com/stefanovazzocell.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# Toy Language\n\nThis is an interpreter for a superset of [BrainF**k](https://en.wikipedia.org/wiki/Brainfuck) implemented in Go.\n\n## Usage\n\nBuild the command line tool with `make build` then try to run a bf program using `tl run /path/to/source` (ex: `tl run samples/helloWorld.bf`.)\n\nYou can also run tests and benchmarks with `make test` (~85% coverage of `/src`) and `make bench` (~30% coverage of `/src`). The base instructions and parser is almost 100% covered, the missing code coverage comes from the network extension.\n\n## Design\n\nThis language has a byte memory array in which it stores data.\n\nThe program interacts with the memory array using a pointer and can perform basic operations one cell at the time.\n\n## Commands\n\nThe base language syntax is a superset of that of BrainFuck.\n\n### Basic\n\n| Character | Description |\n|-----------|-------------|\n| `\u003e` | Increment the data pointer |\n| `\u003c` | Decrement the data pointer |\n| `+` | Increment (by one) the byte at the data pointer |\n| `-` | Decrement (by one) the byte at the data pointer |\n| `.` | Output the value at the data pointer |\n| `,` | Accept one byte of input, store it at the data pointer |\n| `[` | If the data pointer byte is zero, jump to the next corresponding `]` |\n| `]` | If the data pointer byte is non-zero, jump to the previous corresponding `[` |\n\n### Extensions\n\nTo enable a given extensions you must add at the beginning of your file `tl:` followed by a `:`-separated list of extension codes.\n\n#### Networking\n\nThe network extension (code: `net`) enables support for basic TCP communication.\nThis extensions listens for connections on `0.0.0.0` and can send data to `127.0.0.1` on ports ranging from `42000` to `42255`.\n\nThis extension operates in 3 states internally:\n\n- `idle`: not connected anywhere.\n- `listening`: the user requested a byte from the network.\n- `connected`: the user requested a flush of the send queue OR our listener received a connection. In this state the package can send/receive data.\n\nThe send cache is emptied when a port is set (`@`) or when we switch to the `listening` state.\nData is received when the status is `connected`, the receive cache is empty, and the user has requested a byte from the network.\nTimeouts default to 5 seconds and apply to the send `;` and receive `?` commands, internal timeouts might be different.\nThe best way to close a connection is set the port again.\n\nFurther notes:\n\n- To connect two computers remotely it is suggested use netcat to forward the connection (ex: `nc -k -l {port} | nc {remote} {port}`).\n- A successful send is not a guarantee that the receiver got the entire message, if you want that you must write that logic in your code... fun!\n\n| Character | Description |\n|-----------|-------------|\n| `*` | Set the timeout to 0.1 seconds times the data pointer byte. If 0 will attempt send (`;`) / receive (`?`) operations until successful |\n| `@` | Sets the port to `42000` + the data pointer byte |\n| `^` | Adds a byte to the send queue. |\n| `;` | Sends to `127.0.0.1:{port}` the data in the send queue in up-to 1024 byte packets. Sets the current byte to 0 is successful, 1 otherwise. |\n| `?` | Save a recived byte from `0.0.0.0:{port}` to the data pointer. |\n\n## Samples\n\nSome brainfuck code samples are provided in the `/samples` folder.\n\nNote that the repo license might not apply to externally sourced samples as some come from the [Wikipedia page](https://en.wikipedia.org/wiki/Brainfuck#Examples) for this language.\n\n## Future Updates\n\nHere's a list of potential future improvements in non-particular order:\n\n- [build] Offer WASM build\n- [debugging] Have a debugging interface to print out detailed error logs\n- [tooling:state] More APIs to get access to internal program states\n- [tooling:optimizer] Introduce basic code analysis and optimization\n- [convert:go] Offer to convert to a simple Go program\n- [convert:js] Offer conversion to JavaScript\n- [extension:Color] Introduce terminal colors (`~`)\n- [extension:MemLoad] APIs to load file into memory and save memory to file (`{`, `}`)\n- [extension:External] Extend beyond this library: allows the user to register callbacks (`_`)\n- [extension:MaxData] Extend the data \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanovazzocell%2FToyLanguage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanovazzocell%2FToyLanguage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanovazzocell%2FToyLanguage/lists"}