Orion language interpreter.
Project description
Orion Language
Orion is a simple interpreted programming language, built for fun.
🔃 Installation
Install using pip:
pip install orion-lang
🛠️ Usage
Running it is easy:
orion <script.or>
ℹ️ Documentation
Variables
Variables can be declared with the var keyword
var x = 1;
Arrays must be declared with the array keyword
array x = [1, 2, 3, 4, 5];
Array methods
push() : pushes an element to the last index
x.push("a");
// [1, 2, 3, 4, 5, "a"]
or multiple elements:
x.push("a", "b", "c");
// [1, 2, 3, 4, 5, "a", "b", "c"]
pop() : removes the last element of an array
x.pop();
// [1, 2, 3, 4]
insert() : inserts an element at the specified index
x.insert(0, "abc");
// ["abc", 1, 2, 3, 4, 5]
delete() : deletes the specified index of an array (the outermost dimension)
x.delete(1);
// [1, 3, 4, 5]
Data types
null values can be assigned using the Nothing keyword:
var a = Nothing;
Functions may also return Nothing:
fn donothing():
return Nothing;
end
Type conversion
Data types can also be converted.
int : converts to integer
var x = 3.0;
x = int(x); // 3
float : converts to float
var x = 3;
x = float(x); // 3.0
string : converts to string
var x = 3;
x = string(x); // "3"
Strings
Strings can also be concatenated.
var str = "Hello" + ", " + "World";
print(str);
// Hello, World
If statements
if (condition):
// do
end
or
if (condition):
// do
else if (condition):
// do
else:
// do
end
While statements
while (condition):
// do
end
For loops
Examples:
// Example 1
for (var i = 0; i < 3; i++):
print(i);
end
// Example 3
for (var i = 0; i < 3; i = i + 1):
print(i);
end
Functions
Functions can be written with the fn keyword. You can also return values using return
fn add(a, b):
return a + b;
end
Recursion is also supported:
fn factorial(n):
if (n==1):
return 1;
end
return n * factorial(n-1);
end
I/O
ask() : prompts the user for an input
var input = ask("name: ");
print() : prints a message into the terminal
print("Hello, world");
you can also print multiple items
print("Hello," "world");
// Hello, world
Termination
terminate() : exits the program
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file orion_lang-0.1.0.tar.gz.
File metadata
- Download URL: orion_lang-0.1.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2042824f6f3b9ddd93ad04ea7d8400a60fa38d54a326a8d433f50807a76ed920
|
|
| MD5 |
a1269f35c32b2d091c159d3fe73839a3
|
|
| BLAKE2b-256 |
65b166c37d62d9df1772763f01c9992930c868c7b1de2068b6dc0b7c73081c89
|
File details
Details for the file orion_lang-0.1.0-py3-none-any.whl.
File metadata
- Download URL: orion_lang-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84a68588de648d7fdaeab3ee52247fa1bb2d593de40ae2cf007824f1554664c4
|
|
| MD5 |
ebbb9bcb3d9267cfb25d479489b9fe61
|
|
| BLAKE2b-256 |
10fe91d49701aea7b87bd766aff2407d9872c3e1edb7792ddb22d6cd7f645027
|