Welcome to OrionLang. A general pupose lanaguage inspired by MonkeyLang built in the Writing An Interpreter In Go.
OrionLang supports Read-Evaluate-Print-Loop (REPL). To run the OrionLang REPL run the following:
go run ./cmd/orionlang/main.go -repl
You should see something along the lines of:
Hello user! This is the Orion programming language!
Feel free to type in commands
>>
To execute files, the OrionLang files must end in .or
.
Once your file is ready to be executed run the following command:
go run ./cmd/orionlang/main.go -path {{ PATH_TO_MKL_FILE }}
OrionLang supports the following features:
- Integers
- Booleans
- Strings
- Arrays
- Hashes
- Prefix-, infix- and index operators
- conditionals
- global and local bindings
- first-class functions
- return statements
- closures
OrionLang supports the following built-in functions:
Returns the length of an array or string.
let x = [1, 2, 3]
puts(len(x)) // 3
Prints out data to the standard output
puts("Hello") // Hello
Returns the first element of an array
let x = [1, 2, 3]
puts(first(x)) // 1
Returns the last element of an array
let x = [1, 2, 3]
puts(last(x)) // 1
Returns a new array containing everything after the first element
let x = [1, 2, 3]
puts(rest(x)) // [2, 3]
Pushes an element to an array. Returning a new array.
let x = [1, 2, 3]
let y = push(x, 4)
puts(x) // [1, 2, 3]
puts(y) // [1, 2, 3, 4]