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
Whats new in Orion 0.2.0
- Support for module imports
- Added
mathmodule - Boolean inversion
- New global function
find()
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
Data types built into Orion are as follows: string, int, float, True, False, Nothing
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
Booleans
True and False can be inverted interchangeably
Boolean inversion using !:
var x = True;
print(!x);
Boolean operators
&& : AND operator
||: OR operator
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
Importing modules
Make multiple .or files work together!
Syntax:
import <YOUR_FILE_HERE> as <NAME>
(optional)
Example
If you want to import from \example\animals.or:
import example.animals
print(animals.bark())
// some logic here
Math module
Math is easy with import math!
| Name | Usage | Description |
|---|---|---|
math.sqrt() |
math.sqrt(number) |
returns the square root of a given number |
math.pi |
math.pi |
mathematical constant pi |
math.pi |
math.e |
euler's number |
Global functions
| Name | Usage | Description |
|---|---|---|
terminate() |
terminate() |
exits the program |
find() |
find(target, element) |
returns True if element is found within target string |
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.2.0.tar.gz.
File metadata
- Download URL: orion_lang-0.2.0.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a6ee6ea80e2b2f71a43299571040cea841b13066ca80e9ad272028cad1280ea
|
|
| MD5 |
0d9ef5812564658237be12bc64c60695
|
|
| BLAKE2b-256 |
c886223ecca0ec41769c03d7c0d9474b7da7f14d6017b4f41351bac8f7127b7f
|
File details
Details for the file orion_lang-0.2.0-py3-none-any.whl.
File metadata
- Download URL: orion_lang-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.4 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 |
c85415e79597bef68bc3fc18dfb49c1e769f17c6ee79c53e3956667df674450b
|
|
| MD5 |
4c7e3ed310d4e34a5b78d048c6717acd
|
|
| BLAKE2b-256 |
d7ad369104c75c63e94c1a22a9b2223a4d6543e3b20e5eb19db2411b2a72fb9d
|