breuleux / liso

Operator syntax for the Lisp family of languages (Racket implementation)
31 stars 4 forks source link

Liso

Liso is an alternative syntax for Lisp-like languages, implemented here for Racket.

Examples

fib[n] =
   @if n <= 1:
      n
      fib[n - 1] + fib[n - 2]

fib[30]

<=>

(= (fib n)
   (if (<= n 1)
       n
       (+ (fib (- n 1))
          (fib (- n 2)))))
(fib 30)

There are many more examples here, including examples of macros and operator macros.

Using

You can try out the first version by putting the following line at the beginning of a source file:

#lang planet breuleux/liso

For the bleeding edge version, just download the code somewhere and then put this at the beginning:

#lang reader "/path/to/liso/lang/reader.rkt"

Then, execute as follows:

racket file.liso

Highlights

Precedence rules

precedence

Rules

+ Rule       + O-expression              + S-expression
| Operator   | x <operator> y            | (<operator> x y)
|            | x <op> y <op> z           | (<op> x y z)
|            | x <op1> y <op2> z         | (<op1>_<op2> x y z) (op1 != op2)
| Apply      | x y                       | (apply x y)
|            | x y z                     | (apply (apply x y) z)
| List       | []                        | (list)
|            | [x, ...]                  | (list x ...)
| Apply+List | x[y, ...]                 | (x y ...)
| Group      | {x}                       | x
|            | {x, y, ...}               | (begin x y ...)
| Arrow      | x => y                    | (x y) (for all x)
| Contro     | @K : x                    | (K x)
|            | @K x : y                  | (K x y)
|            | @K x, y : {a, b, c}       | (K (begin x y) a b c)
| Sexp       | (...)                     | (...)

Aliases

+ Usual syntax         + Equivalent operator
| @define spec: body   | spec = body
| @lambda args: body   | args -> body
| @set! var: value     | var := value
| @quote: expr         | ..expr
| @quasiquote: expr    | .expr
| @unquote: expr       | ^expr
| expt[x, y]           | x ** y
| cons[x, y]           | x :: y
| string-append[x, y]  | x ++ y
| not[x == y]          | x /= y
| or[a, b, c]          | a || b || c
| and[a, b, c]         | a && b && c
| not[x]               | ! x