No project description provided
Project description
tr-lang-py
Python bindings for tr-lang
Installation
$ pip install tr-lang-py
Usage
To Run Inline tr-lang Code
from tr_lang import Lexer, Parser, Run, bytecode
code = """
'Hello, World!\\n' de
"""
lexer = Lexer(code)
parser = Parser(lexer.tokenize())
bytes = bytecode.to_bytes(parser.parse())
run = Run(bytecode.from_bytes(bytes))
run.run() # prints "Hello, World!\n"
To Use tr-lang Files with Python
# /path/to/file.py
from tr_lang import Lexer, Parser, Run
with open("/path/to/tr-lang/file.trl") as f:
Run(Parser(Lexer(f.read()).tokenize()).parse()).run()
# /path/to/tr-lang/file.trl
"What is your name? " de # print("What is your name?", end="")
girdi -> name # name = input()
"Your name is " de name de ".\n" de # print(f"Your name is{name}.")
To Use tr-lang Bytecode from Python
from tr_lang import Run, bytecode
with open("/path/to/bytecode.trl.byt", "rb") as f:
Run(bytecode.from_bytes(f.read())).run()
Documentation
Contributing
To report bugs or suggest new features please use the issue tracker
Bugfix PR's are welcome!
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
tr_lang_py-0.2.0.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for tr_lang_py-0.2.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5920bc3b98496cccdcf56fda7f4f1cb1d97caf2491730fde89ed6adb186496c |
|
MD5 | 3365260202edb62c106bb02710cc223f |
|
BLAKE2b-256 | 08e273654e542bb7bfb704588422cfe642b4d35d773dd147c8b2d53022aa9828 |