Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/breuleux/liso
Operator syntax for the Lisp family of languages (Racket implementation)
https://github.com/breuleux/liso
Last synced: 9 days ago
JSON representation
Operator syntax for the Lisp family of languages (Racket implementation)
- Host: GitHub
- URL: https://github.com/breuleux/liso
- Owner: breuleux
- Created: 2014-01-04T23:39:07.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-16T23:54:03.000Z (almost 11 years ago)
- Last Synced: 2024-10-18T18:56:28.539Z (28 days ago)
- Language: Racket
- Size: 262 KB
- Stars: 31
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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](https://github.com/breuleux/liso/tree/master/liso/examples),
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
----------* It is a pure operator syntax, a particular implementation of what I
call "o-expressions". I made o-expressions for a new programming
language that I am designing, so they were not designed to work with
Lisp-like languages. However, I believe that they are a competent
alternative to s-expressions, so there is no harm trying.* The syntax cannot be customized from within itself: operator
priority is predetermined, even for custom operators.* It is general and homoiconic. All syntactic elements behave the same
in all contexts, they have no associated semantics, and they reduce
to extremely regular structures.* It *does* support macros. In fact, you can use Racket's macro system
without any changes to their underlying logic. See
[here](https://github.com/breuleux/liso/blob/master/liso/examples/macros.liso)
for example.Precedence rules
----------------![precedence](https://raw.github.com/breuleux/liso/master/doc/liso_priority.png)
Rules
-----+ Rule + O-expression + S-expression
| Operator | x y | ( x y)
| | x y z | ( x y z)
| | x y z | (_ 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