Skip to content

General purpose programming language.

License

Notifications You must be signed in to change notification settings

andreas-jonsson/saurus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This project has been discontinued.

Saurus is a dynamic, lightweight, general purpose programming language. The VM is written in portable C and can be easily embedded in another C or C++ program. The language is simple, powerful and dynamic in a fashion familiar to most programmers.

Tweets by @saurus_org

Examples

A fibonacci function written in Saurus.

# Fibonacci function
fibonacci = (n) ->
    if n < 3
        1
    else
        rec(n - 1) + rec(n - 2)
    ;

# Print 8 fibonacci numbers
for n = 1..8
    io.print(n "=" fibonacci(n))
> saurus fibo.su
1	=	1
2	=	1
3	=	2
4	=	3
5	=	5
6	=	8
7	=	13
8	=	21

Mix Saurus with C code.

hello_from_saurus = () ->
    io.print("Hello from Saurus!")
    ;

hello_from_c = cfun '''
    puts("Hello from C!");
'''

hello_from_saurus()
hello_from_c()

cdec '''
    int main(int argc, char *argv[]) {
        su_state *s = su_init(NULL);
        su_libinit(s);

        ___saurus(s);
        su_call(s, 0, 0);

        su_close(s);
        return 0;
    }
'''
> saurus -c hello.su hello.c
> gcc -lsaurus hello.c -o hello
> ./hello
Hello from Saurus!
Hello from C!

Non blocking multithreading in Saurus.

accounts = global({a = 0 b = 10})

# This function verify concurrency.
check = () ->
    g = @accounts
    assert(g.a + g.b == 10 "Race condition!")
    if g.b > 0
        rec()
    ;

# Transfer N amount from account B to account A.
transfer = (n) ->
    # This function could be called multiple times
    # with the same argument, on the same thread.
    mutate = (g) -> {
            a = g.a + n
            b = g.b - n
        }
        ;

    process.sync(accounts mutate)
    ;

# Spawn 4 separate threads to do the work.
process.async(check)
process.async(transfer 3)
process.async(transfer 5)
process.async(transfer 2)
> saurus async.su

We recommend using Atom with the language-saurus package for writing Saurus code.

Support & Documentation

Our wiki contains basic information about the standard-library and built-in functions. More sample code can be found here. If you need help or have a question you can use the issue tracker and tag your issue with the lable question. For discussions we recommend joining our Join the chat at https://gitter.im/andreas-t-jonsson/saurus

Current build status:

Linux (Clang): Build Status

Windows (MSVC): Build status

License

Saurus is released under the MPL-2.0 licence. (Summarized by tldrlegal.com.)

Acknowledgement

SLRE (Cesanta Software)

Clojure (Rich Hickey)

Lua (PUC-Rio)

InstallBuilder (BitRock)

About

General purpose programming language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published