A tiny interpreter REPL with get/how/clear/cycle commands.
Project description
meak-interpreter
一个支持精确有理数运算的小型解释器 REPL。
特性
- 精确有理数运算(使用 Python 的
Fraction) - 支持基本数学运算:
+,-,*,/,^(幂运算) - 特殊操作符:
?x- 返回值和变量名的组合X for Y- 如果都是数字则相加,否则字符串拼接A o B- 特殊的值获取操作符
- 内置函数:
abs,pow,gcd,lcm - 命令:
get <expr>- 累加表达式结果how- 显示累加总和clear- 清除累加总和cycle <cmd> for <N>- 重复执行命令 N 次
安装
pip install -e .
使用
命令行 REPL
meak
作为 Python 模块
from meak_interpreter import MeakInterpreter
interp = MeakInterpreter()
result = interp.run_line("2 + 3")
print(result) # ['5']
示例
meak> 1/3 + 1/6
1/2
meak> x = 10
meak> y = 20
meak> x + y
30
meak> get 100
meak> get 50
meak> how
150
许可证
MIT License
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 meak_interpreter-0.1.1.tar.gz.
File metadata
- Download URL: meak_interpreter-0.1.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d98c391b9e1dfb7678db767d1a2e9478d2dd5735ed29eece88e20fe91aadabd1
|
|
| MD5 |
34284488f0e079aad3af8be8a9d00e4d
|
|
| BLAKE2b-256 |
a073eb698906acf09b457329b72f5143ea756fca8d9650c16203573eb96bf285
|
File details
Details for the file meak_interpreter-0.1.1-py3-none-any.whl.
File metadata
- Download URL: meak_interpreter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
184ff5f6ee760389ca53237582928dba854a5c075e3e3d5c51debd2f828a443b
|
|
| MD5 |
6913fbebdf2c2935376771601b35cf79
|
|
| BLAKE2b-256 |
a58b6cc8dcee9511604af9258def3fb855427dcddd700de92d3092cdc185337c
|