PyHorizon custom language interpreter
Project description
PyHorizon
PyHorizon is a tiny custom programming language written in Python. Program files use the .pyh extension and are executed by main.py.
Project Structure
main.py- command-line entry point. Reads a.pyhfile and runs it.lexer.py- converts source code into tokens.parser.py- turns tokens into an abstract syntax tree.ast_nodes.py- AST node definitions.interpreter.py- executes the AST.environment.py- variable scope handling.errors.py- readable lexer, parser, and runtime errors.tokens.py- token data model.example.pyh- sample program in the language.calculator.pyh- interactive calculator app written in PyHorizon.app.pyh- GUI app that opens a window.
Syntax
Supported commands:
say "Hello"say Hello world nameimp x = 10x = x + 1if x > 5 ... else ... endloop x < 10 ... endfunc add(a, b) ... endreturn value# comment
In say, plain words without quotes are treated as text, and variables are inserted automatically. Example:
imp name = Gh
say Hello name
ask reads user input and automatically converts numbers and booleans when possible:
imp value = ask Введи число
How It Works
- The lexer reads text from a
.pyhfile and turns it into tokens. - The parser builds a structured tree of statements and expressions.
- The interpreter walks that tree and executes the program.
Run
Install
From PyPI, when published:
pip install pyhori
From local source:
pip install .
Windows
pyhori example.pyh
Linux
pyhori example.pyh
Termux
pkg install python
pip install .
pyhori example.pyh
You can also run your own file:
pyhori program.pyh
Run the included app:
pyhori calculator.pyh
Open the GUI app:
pyhori app.pyh
Show the version:
pyhori --version
Project details
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 pyhori-0.1.1.tar.gz.
File metadata
- Download URL: pyhori-0.1.1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ad295076c61201fddfaeafe766f72c3cdcc5a38d6697a955c9a12d39e640716
|
|
| MD5 |
32de5bc5533b4b0d10025e719c7f8517
|
|
| BLAKE2b-256 |
be01b27f8be01f4fa25462f01dfe9360c04e7943e7704711b208e3a64360b668
|
File details
Details for the file pyhori-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyhori-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f2d5af8c6f67d61f878a321105d5fac75d0e4ce9bf25df6d008e80e3fd76ad8
|
|
| MD5 |
b9712946fc69878b6ea70770e0da3baa
|
|
| BLAKE2b-256 |
04a9ff899358e0cde3415c5bce40fa186b19ee1723ff644a62269f5f78e54677
|