Sup: an English-like programming language (MVP)
Project description
SUP — English-like Programming Language
An English-like programming language focused on readability with deterministic semantics.
Quickstart
- Create a virtual environment and install:
python -m venv .venv
.venv\\Scripts\\activate
pip install -e .
- Run a program:
sup examples/06_mixed.sup
CLI usage
Run a file:
sup path/to/program.sup
Emit Python for a single source:
sup --emit python path/to/program.sup
Transpile entry + imports to a folder and run:
sup transpile path/to/entry.sup --out dist_py
python dist_py/run.py
Check version:
sup --version
- Run tests (with coverage in CI):
pip install pytest
pytest
Language Tour (MVP)
Program structure:
sup
print add 2 and 3
bye
Assignments and expressions:
sup
set x to add 10 and 5
print the result
print subtract 3 from x
bye
Conditionals and loops:
sup
set a to 5
set b to 3
if a is greater than b then
print a
end if
repeat 3 times
print multiply a and b
end repeat
bye
Input:
sup
ask for name
print name
bye
Comments: lines starting with note are ignored.
Errors are reported with line numbers and suggestions.
Phase 2: Functions, Strings, Transpiler
Functions:
sup
define function called area with width and height
set result to multiply width and height
return result
end function
print call area with 5 and 6
bye
Strings:
sup
set name to "Ada"
print name
bye
Transpiler to Python:
sup --emit python examples/07_functions.sup
Transpile a project (entry + imports) to Python files:
sup transpile examples/12_imports.sup --out dist_py
python dist_py/run.py
Notes:
- The transpiler performs a DFS on imports and writes sanitized module names into
dist_py/. run.pycalls the transpiled entry module's__main__()to execute top-level code.
Phase 3: Collections and Stdlib
Lists and Maps:
sup
make list of 1, 2, 3
push 4 to list
print the list
pop from list
print the list
make map
set "name" to "Karthik" in map
set "age" to 21 in map
print get "name" from map
delete "age" from map
print the map
bye
Stdlib:
- Math:
power of A and B,sqrt of X,absolute of X - String:
length of S,upper of S,lower of S,concat of A and B - List:
push,pop,length of <list>
Indexing and access:
sup
make list of 1, 2, 3
print get 0 from list # prints first element
make map
set "k" to 42 in map
print get "k" from map
bye
Phase 4: Conditionals, Loops, Booleans
Conditionals with else:
sup
if x is greater than 5
print "big"
else
print "small"
end if
bye
While and For Each:
sup
set x to 0
while x is less than 3
print x
set x to add x and 1
end while
make list of 1, 2, 3
for each item in list
print item
end for
bye
Booleans:
- Operators:
and,or,not - Comparisons:
is equal to,is not equal to,is greater than,is less than,is greater than or equal to,is less than or equal to
Phase 5: Errors and Imports
Errors:
sup
try
throw "oops"
catch e
print e
finally
print "done"
end try
bye
Imports:
sup
import mathlib
print mathlib.pi
from mathlib import square as sq
print call sq with 3
bye
Notes:
- Interpreter searches modules in
SUP_PATH(os.pathsep-separated) then CWD. - Transpiler emits Python
import/fromstatements; ensure modules exist as Python when executing transpiled code.
Additional built-ins
- Math:
min of A and B,max of A and B,floor of X,ceil of X - String:
trim of S(strip whitespace),upper of S,lower of S,concat of A and B - Contains/join:
contains of L and Xwhere L is a list (true if X in list)contains of S and Twhere S,T are strings (substring check)join of SEP and LIST(e.g.,join of "," and list)
Error handling notes
throw <expr>raises a runtime error carrying the raw value of<expr>; incatch e, the variableereceives that raw value.finallyalways runs whether thetrybody throws or not; if there is nocatch, the error is re-raised afterfinally.
Circular imports
- The interpreter detects circular imports and raises a friendly error identifying the module involved.
Test runner
- To run tests reliably in terminals that buffer output, use:
\.venv\Scripts\python sup-lang\tools\run_tests.py
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 sup_lang-2.3.6.tar.gz.
File metadata
- Download URL: sup_lang-2.3.6.tar.gz
- Upload date:
- Size: 132.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df61d4c34a68531ef825747943ec6260df05018a6d99e5b140a7a58bfb6ae6e2
|
|
| MD5 |
5386e9055cac1e37043ddf6a1429808f
|
|
| BLAKE2b-256 |
e057dd3cc41599bdec385a714e80c433d6d04903110223b1b92bbacbffe1f5de
|
File details
Details for the file sup_lang-2.3.6-py3-none-any.whl.
File metadata
- Download URL: sup_lang-2.3.6-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd9c42d36e7249c3435876f17c07876aa8516d9217d72a06204b64b50946d677
|
|
| MD5 |
e7211d450610ec99fe2488d049707048
|
|
| BLAKE2b-256 |
010f0b05fd8df06721d2402598bfe1abe47e91a0e23c30abaf5bc9791e122596
|