UniLang Script (ULS) is a simple, interpreted programming language designed for beginners. It draws inspiration from Python and JavaScript, striving to provide a straightforward, accessible environment for learning fundamental programming concepts.
-
Beginner-Friendly Syntax:
ULS uses braces{}to denote code blocks and supports both line breaks and optional semicolons;as statement separators. -
Familiar Data Types:
- Numbers:
intandfloat - Strings:
"Hello, World!"(with escape sequences) - Booleans:
true,false - Lists:
[1, 2, 3]or["apple", "banana"] - Triple-Quoted Strings:
"""Multi-line text here..."""
- Numbers:
-
Control Structures:
if/elseconditionswhileloopsfor i in range(...)loopsbreakto exit loops
-
Functions: Define and call functions:
define greet(name) { result "Hello, " + name + "!" } print(greet("ULS User")) -
Built-in Functions:
- I/O:
print(),input() - Conversions:
str(),int(),float() - Math & Utilities:
abs(),round(),min(),max(),sqrt(),pow(),sin(),cos(),tan(),log() - Strings:
replace(),upper(),lower(),capitalize(),find(),substring(),split(),join() - Lists:
append(),remove(),len(),sum(),any(),all(),sorted(),reverse(),random_choice(),random_shuffle() - Random:
randomint(min, max) - Date/Time:
current_time(),current_date() - File I/O:
read_file(),write_file(),append_file() - Networking:
http_get(url)
- I/O:
-
Advanced Features:
eval(code): Execute ULS code at runtime.python_eval(expr): Evaluate a Python expression at runtime (for trusted code only).try/except/finallyblocks for basic exception handling.- Optional semicolon
;as a statement separator. - Escape sequences in strings (
\n,\t, etc.) and support for ANSI codes in strings if the terminal supports them.
-
Empty
print()for New Lines: Just callprint()with no arguments to print a blank line.
-
Requirements:
- Python or PyPy
plyandcoloramaPython packagesrequestsforcheck_for_update()function
If any dependencies are missing, which are later automatially installed if they are, you can manually run:
pip install ply colorama requests
-
Clone the Repo:
git clone https://github.com/UN7X/unilang.git cd unilang -
Initialize the Interpreter:
pypy interpreter.py --init
Or use Python if PyPy is not available:
python interpreter.py --init
-
Run the Interpreter: (PyPy)
pypy interpreter.py example_scripts/test_features.uls
(Python)
python interpreter.py example_scripts/test_features.uls
-
Run a Script:
pypy interpreter.py my_script.uls
-
Show the Manual:
pypy interpreter.py --man pypy interpreter.py --man 3
Use
--man <page>to navigate the included manual pages. -
About:
pypy interpreter.py --about
-
Init (First-Time Setup OR changes made to the Interpreter itself):
pypy interpreter.py --init
-
Check for Updates:
pypy interpreter.py --check
# example.uls
x = 10
if (x > 5) {
print("x is greater than 5")
} else {
print("x is 5 or less")
}
lst = [1, 2, 3]
append(lst, 4)
print("List after append: " + str(lst)) # [1, 2, 3, 4]
# Using a function
define add(a, b) {
result a + b
}
print(add(5,7)) # 12
# File I/O example:
write_file("out.txt", "Hello, ULS!")
print(read_file("out.txt"))
Run it:
pypy interpreter.py example.ulsContributions are welcome! Key areas that might need improvement:
- More robust escape sequence handling in strings.
- Better error messages and debugging tools.
- More built-in functions or libraries.
This project is licensed under the MIT License. See LICENSE for details.
For questions or suggestions, open an issue on GitHub or visit https://un7x.net/unilang-script. (Site WIP)