Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ktravis/lark
An odd dynamic programming language, interpreted by Python
https://github.com/ktravis/lark
Last synced: about 2 months ago
JSON representation
An odd dynamic programming language, interpreted by Python
- Host: GitHub
- URL: https://github.com/ktravis/lark
- Owner: ktravis
- Created: 2015-10-19T11:53:34.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-09T12:22:57.000Z (about 9 years ago)
- Last Synced: 2023-03-25T11:18:00.075Z (almost 2 years ago)
- Language: Python
- Size: 44.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lark
Language running on python -- everything is a value, whatever that means.
## Features
- python interoperability
- reference counting (not complete yet, but close)
- namespaces
- closures
- dynamic variables
- flexible tuple data type (named members and positional slots)
- explicit and unambiguous "references"## Getting Started
```bash
pip install ply
./lark.py
```## Examples
```
# comments
x = 3
y = { x } # boxed val
z = [a]{ a * x } # parametrized value
z[2] # 6str = 'hello wendl' #string
make_counter = [n]{
a = n
{ ^a = a + 1 } # last expression is returned
}
if true
print['sane universe']
elif false
print['uh oh']
else
print['who even knows']
endthing = if x > 2
'x is bigger than two'
else
'x is 2 or smaller'
endnoref = [x] { x += 1 }
y = 0
noref[y] # 1
y # 1yesref = [^x] { x += 1 }
# yesref[y] # error
yesref[^y] # 1
y # 1
yesref[^y] # 2counter = make_counter[0]
print[counter] # 1
print[counter] # 2
print[counter] # 3t = (1,) # tuple
t2 = (1, "hello world") # more tuple
print[t.0] # 1
i = 1
print[t2.(i)] # hello worldi = 0
loop true
i += 1
print[i]
if i > 5
break
end
end# default parameter values
log = [msg="default used!"] { print["LOG: " + msg] }
log['parameter provided'] # > LOG: parameter provided
log # > LOG: default used!# default parameters must be at the end
test = [a, b=1]{ a + b }
test[1] # > 2
test[1, 2] # > 3namespace hello {
namespace world {
yes = true
}
}
print[hello::world::yes] # trueimport test # imports a file named test (optional extensions)
import test::nested # imports namespace "nested" from file test,
# or file "nested[.lk]" from folder 'test'nested::my_value = i
extern """import sys"""
input = extern "sys.stdin.readline().strip()"
```