Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

toylang

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toylang

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

ToyLang

Build Status Codecov

ToyLang is interpreted high-level fully OOP language with Python-like syntax and dynamic typing.

Complex is better than complicated.

As a multi-paradigm language, ToyLang supports object-oriented and imperative programming styles both.

Installation

$ gem install toylang

Usage

Run REPL:

toylang

or run file:

toylang your_code.tlg

Examples of code

# comment
println("Hello World")
"Hello World".println # Hello World

println(2 + 2 ** 5) # 34

def hello(name):
  "Hi, " + name + "!"

hello("Max").println # => Hi, Max!

a = 23
b = a + 2
println(b) # => 25

Hey = 5 # constant

if (2 > 1):
  println("Yeah!")
else:
  println("Something goes bad!")

if (false):
  print("Won't be printed")

Cycles:

a = 0
while (a != 3):
  println(a)
  a = a + 1
# => 0 1 2

OOP:

# class defination
class Klass:
  def my_method:
    true

# object creating
k = Klass.new
k.my_method.print # => true

# monkey patching
class Number:
  def ten:
    10

1.ten.println # => 10

class Number:
  def ten:
    11

1.ten.println # => 11

# inheritance
class Animal:
  def is_a_human:
    false
  def say:
    "..."

class Dog < Animal:
  def say:
    "Bark!"

dog = Dog.new
animal = Animal.new

println(animal.say)     # ...
println(dog.say)        # Bark!
println(dog.is_a_human) # false

Building

Pre-reqs

To build and run this app locally you will need a few things:

  • Install Ruby (tested on 2.6);
  • Using Racc as parser

Getting start

  • Clone the repository
git clone --depth=1 https://github.com/maxbarsukov/toylang.git
  • Install dependencies
cd toylang
bundle install
  • Run
./bin/toylang input.tlg
# or
./bin/toylang
  • RSpec
bundle exec rspec
  • Rubocop
bundle exec rubocop

Contributing

Bug 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.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Toylang project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 02 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc