{"id":15439109,"url":"https://github.com/maxbarsukov/toylang","last_synced_at":"2025-03-28T06:30:14.053Z","repository":{"id":59157860,"uuid":"443542580","full_name":"maxbarsukov/toylang","owner":"maxbarsukov","description":"🧸 Toy Language with OOP and Python-like syntax","archived":false,"fork":false,"pushed_at":"2022-01-02T13:11:53.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T19:48:31.124Z","etag":null,"topics":["interpreter","oop-languages","programming-language","ruby","ruby-interpreter"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/toylang","language":"Ruby","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/maxbarsukov.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-01T13:17:40.000Z","updated_at":"2023-06-21T07:30:40.000Z","dependencies_parsed_at":"2022-09-13T20:10:18.428Z","dependency_job_id":null,"html_url":"https://github.com/maxbarsukov/toylang","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbarsukov%2Ftoylang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbarsukov%2Ftoylang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbarsukov%2Ftoylang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbarsukov%2Ftoylang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxbarsukov","download_url":"https://codeload.github.com/maxbarsukov/toylang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245984164,"owners_count":20704787,"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":["interpreter","oop-languages","programming-language","ruby","ruby-interpreter"],"created_at":"2024-10-01T19:02:35.550Z","updated_at":"2025-03-28T06:30:14.028Z","avatar_url":"https://github.com/maxbarsukov.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ToyLang\n\n[![Build Status](https://github.com/maxbarsukov/toylang/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/maxbarsukov/toylang/actions/workflows/main.yml)\n[![Codecov](https://codecov.io/gh/maxbarsukov/toylang/branch/master/graph/badge.svg?token=9L8Y4N4KKW)](https://codecov.io/gh/maxbarsukov/toylang)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/maxbarsukov/toylang)\n\n![Gem Version](https://img.shields.io/gem/v/toylang)\n![Gem Downloads](https://img.shields.io/gem/dt/toylang)\n\n***ToyLang*** is interpreted high-level fully OOP language with *Python-like* syntax and dynamic typing.\n\n \u003e Complex is better than complicated.\n\nAs a multi-paradigm language, ***ToyLang*** supports object-oriented and imperative programming styles both.\n\n- As in Python, blocks of code are delimited **by** their **indentation**.\n- Classes are declared with the `class` keyword.\n- Methods can be defined anywhere using the `def` keyword.\n- If a method takes no arguments, *parenthesis can be skipped*, like in\n**Ruby**.\n- The *last value evaluated in a method is its return value*.\n- ***Everything is an object***.\n\n## Installation\n\n    $ gem install toylang\n\n## Usage\n\nRun REPL:\n```bash\ntoylang\n```\n\nor run file:\n```bash\ntoylang your_code.tlg\n```\n\n## Examples of code\n\n```python\n# comment\nprintln(\"Hello World\")\n\"Hello World\".println # Hello World\n\nprintln(2 + 2 ** 5) # 34\n\ndef hello(name):\n  \"Hi, \" + name + \"!\"\n\nhello(\"Max\").println # =\u003e Hi, Max!\n\na = 23\nb = a + 2\nprintln(b) # =\u003e 25\n\nHey = 5 # constant\n\nif (2 \u003e 1):\n  println(\"Yeah!\")\nelse:\n  println(\"Something goes bad!\")\n\nif (false):\n  print(\"Won't be printed\")\n```\n\nCycles:\n```python\na = 0\nwhile (a != 3):\n  println(a)\n  a = a + 1\n# =\u003e 0 1 2\n```\n\nOOP:\n```python\n# class defination\nclass Klass:\n  def my_method:\n    true\n\n# object creating\nk = Klass.new\nk.my_method.print # =\u003e true\n\n# monkey patching\nclass Number:\n  def ten:\n    10\n\n1.ten.println # =\u003e 10\n\nclass Number:\n  def ten:\n    11\n\n1.ten.println # =\u003e 11\n\n# inheritance\nclass Animal:\n  def is_a_human:\n    false\n  def say:\n    \"...\"\n\nclass Dog \u003c Animal:\n  def say:\n    \"Bark!\"\n\ndog = Dog.new\nanimal = Animal.new\n\nprintln(animal.say)     # ...\nprintln(dog.say)        # Bark!\nprintln(dog.is_a_human) # false\n```\n\n## Building\n\n### Pre-reqs\n\nTo build and run this app locally you will need a few things:\n\n- Install [Ruby](https://www.ruby-lang.org/en/) *(tested on **2.6**)*;\n- Using [Racc](https://github.com/ruby/racc) as parser\n\n### Getting start\n\n- Clone the repository\n```bash\ngit clone --depth=1 https://github.com/maxbarsukov/toylang.git\n```\n- **Install dependencies**\n```bash\ncd toylang\nbundle install\n```\n- **Run**\n```bash\n./bin/toylang input.tlg\n# or\n./bin/toylang\n````\n- **RSpec**\n```bash\nbundle exec rspec\n```\n- **Rubocop**\n```bash\nbundle exec rubocop\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/maxbarsukov/toylang. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/maxbarsukov/toylang/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Toylang project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/maxbarsukov/toylang/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbarsukov%2Ftoylang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxbarsukov%2Ftoylang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbarsukov%2Ftoylang/lists"}