GithubHelp home page GithubHelp logo

ao's Introduction

AO

AO, pronouncing as A-O, is a tiny interpreter language.

It supports:

  • JSON as primitive types: null, true, false, 0, 1.0, "string", [1, 2], {"key": "value"}.
  • Assignment: x = 1.
  • Function: double = f (a) { return a * a }.
  • Arithmetic: +, -, *, /, %, <<, >>, &, |, ~.
  • Comparison: ==, !=, >, >=, <, <=.
  • Logical: and, or, not.
  • Error handling: value or error = a_function_might_raise_error()

Getting Started

Due to its early stage, it's not appropriate to publish a release. If you want to get an AO executable, please read Develop to compile interpreter for now.

A Glance of AO

All builtin types are JSON based values, expect Function. No class, no struct, no trait, no interface, no ..., etc.

a = 1
b = 1.0
c = null
d = true
e = false
f = "hello world"
g = [1, 2, 3]
h = {"key": "value"}

Control flow is very traditional.

a = 1
b = 2
c = 3

if a <= b and b <= c {
    print "a, b, c are increasing."
} elif a >= b and b >= c {
    print "a, b, c are decreasing."
} else {
    print "a, b, c are in random order."
}

while c <= 0 {
    print c
    c = c - 1
}

while true {
    print "loop"
}

Defining function is just yet another assignment.

i = f (j) {
    return j * 2
}

j = i(24)
print j

Function can be closure.

g = f (m) {
    return f(n) {
        return m + n
    }
}

plus42 = f(42)
print plus42(42)

Catch errors.

badfunction = f () {
    raise("It can be any type, str, int, object, etc.")
    # It never returns 1 here.
    return 1
}

value or error = badfunction()

Develop

To build ao binary, you will need to install Python 2.7, virtualenv and rpython:

$ virtualenv venv
$ source venv/bin/activate
$ pip install rpython

# disable jit.
$ rpython targetao.py

# enable jit.
$ rpython -Ojit targetao.py

Contribute

The AO Philosophy:

  • Simplicity.
    • AO aims to provie simple syntax so that new learners can quickly start learning programming.
    • No matter what a mess the implementation is, keep the interface simple.
  • Correctness.
    • Make it right. Fix the bug if we catch one. :)
  • Battery-included.
    • Softwares are meant to solve problems. AO ships with a set of handy libraries.

License

AO comes with MIT license.

ao's People

Contributors

soasme avatar

Watchers

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