Giter Club home page Giter Club logo

uro's Introduction

Uroboros (uro)

Uro is a compiled, loosely-typed, branchless toy programming language which is designed to easily implement a self-hosted compiler.

The bare-minimum features will be implemented in the language itself, while extra tools needed to easily create a self-hosted compiler (e.g. a regex parser) are created in the standard library.

Quirks

  • There are only strings, integers, booleans, dictionaries and functions
  • Classes and objects are dictionaries
    • Methods are just key-value pairs where the value is a function
  • If-statements are dictionaries
    • {True: do_true, False: do_false}[1+1==2]()
    • This means that uro is a branchless programming language
  • There are no lists
    • A list could be implemented as a dictionary with integer keys
    • A linked list can be implemented as a set of objects (dictionaries)
  • Any feature beyond the bare minimum needed for the compiler will be written in uro
  • The stage-1 compiler (uro0) will compile to x86-64 assembly, uro might use LLVM-IR.

Roadmap

The development of this language will be in stages:

Reached Version Name Description Language
โŒ› 0.1.0 uro0 A compiler for the bare-minimum language. Python
๐Ÿ›‘ < 1.0.0 std A standard library. Uro0
๐Ÿ›‘ 1.0.0 uro The self-hosted compiler. Uro0
๐Ÿ›‘ > 1.0.0 uro New language features. Uro
Icon Meaning
๐Ÿ›‘ Hasn't started
โŒ› In progress
โœ… Done

Example syntax

import std

# The standard library could contain functions like `new`, which act as OOP helpers:
#
#  > ## copy - creates a deep copy of a dictionary
#  > copy = fn (obj) {
#  >     new_obj = {};
#  >
#  >     # `for` gives keys of a dictionary or characters from a string
#  >     for key in obj {
#  >         new_obj[key] = obj[key];
#  >     };
#  >
#  >     return new_obj;
#  > };
#  >
#  > ## new - Initializes an object
#  > new = fn (class, kwargs) {
#  >     obj = copy(class);
#  >     obj['_init'](obj, kwargs);
#  >     return obj;
#  > };
#  >
#  > ## if - Executes a function if a condition is True
#  > if = fn (cond, func) {
#  >     return { True: func }[cond]();
#  > };
#

## Person - A Person does this and that
# :params:
#   name - The name of the person
Person = {
    '_init': fn (self, kwargs) {
        self['name'] = kwargs['name'];
        self['species'] = 'Human';
    },
    'greet': fn (self) {
        printf("Hi, fellow {a}! I'm {b}!\n", {a: self['species'], b: self['name']});
    },
};


bob = new(Person, {'name': 'Bob'});

if (bob['species'] == 'Human', fn () {
    bob['greet'](bob);  # => 'Hi, fellow Human! I'm Bob!\n'
});

uro's People

Contributors

nootr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.