Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ws-kj/orpheus
The Orpheus programming language
https://github.com/ws-kj/orpheus
Last synced: 6 days ago
JSON representation
The Orpheus programming language
- Host: GitHub
- URL: https://github.com/ws-kj/orpheus
- Owner: ws-kj
- Created: 2023-12-04T03:52:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-25T17:36:58.000Z (11 months ago)
- Last Synced: 2024-02-25T18:43:02.176Z (11 months ago)
- Language: Python
- Homepage:
- Size: 8.61 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A tour of the Orpheus interpreter
The interpreter currently has functions, scoping, basic control flow, and a type system.* Scope denoted by `->`.
* Types: `int`, `float`, `str`, `bool` `list`, `map`, `any`, `func`.
* Adding `?` to variable type allows it to be assigned `nil`.
* `auto` functions as expected.
* Types can be compared with `type()` or `is`
* Builtins: `len`, `print`, `println`, `tail`, `append`, `type`, `has`.
* Keywords: `and`, `or`, `not`, `true`, `false`, `if`, `else`,`var`, `return`, `pass`, `func`.
* All objects can be represented as strings.
* All variables are mutable.
* `list`s and `map`s can contain mixed types.Examples:
```
func fizzbuzz(n: int)
->
var x: auto = 1 // auto binds var to first type assignedwhile x <= n
->
if x % 3 == 0 and x % 5 == 0 -> println("FizzBuzz")
else if x % 3 == 0 -> println("Fizz")
else if x % 5 == 0 -> println("Buzz")
else -> println(x)
x = x + 1fizzbuzz(20)
```
```
var people: list = [
{ "name": "Bob", "age": 25 },
{ "name": "Alice", "age": 17 },
{ "name": "John", "age": 22 }
]func greet(person: map)
->
print(person["name"])
print(" is ")
print(person["age"])
println(" years old.")var i: int = 0
while i < len(people)
->
greet(people[i])
if people[i]["age"] < 21
->
println("Not eligible to drink!")
else
->
println("Eligible to drink.")
println()i = i + 1
```
```
var test: any = 3.0 // any can contain any type
println(test)
test = "hello world!"
println(test)
```
```
if "hello" is str // "is" keyword allows type checking on any
->
println("This will execute!")
```
```
func do_thing(data: any)
->
if has(data) -> println(data)
else -> println("No data.")
var mydata: str? = nil // ? denotes "maybe" type, which can be nil
do_thing(mydata) // outputs "No data."
mydata = "wow!"
do_thing(mydata) // outputs "wow!"
```