Yu Language - yulang
A toy project for creating a simple programming language using Bison and Flex in C++. This is the wrapper to Python.
interactive console
$ python
>>> import yulang
>>> yulang.console()
Yu Language 0.0.1 (unstable, Oct 23 2021, 21:31:19)
interactive:
y> var a = 3;
y> print(a);
print: 3
y> square a: {return a ^ 2;}
y> print(square(a : 10));
print: 100
y>
parsing Python string
$ python
>>> import yulang
>>> yulang.parse("var a = 10; print(a);")
print: 10
examples
arithmetic
source codes:
print(10 + 30);
print(10 - 30);
print(10. / 30.);
print(10 * 30);
print(30 % 9);
print((5. + 5.) / 3.);
output:
$ python
>>> import yulang
>>> yulang.read("path/to/arithmetics.yu")
print: 40
print: -20
print: 0.333333
print: 300
print: 3
print: 3.33333
string
source codes:
var a = "hello world";
print(a);
$ python
>>> import yulang
>>> yulang.read("path/to/strings.yu")
print: hello world
functions
source codes: (// is used for comments)
// create a square function
square p, l:
{
var L = p * l;
return L;
}
// using the square function in a volume function
volume t:
{
var V = square(p : 5, l : 6) * t;
return V;
}
// assigning volume return in myVol variable
var myVol = volume(4);
print(myVol);
output:
$ python
>>> import yulang
>>> yulang.read("path/to/functions.yu")
print: 120
variables
source codes: (var is used for generating variables)
// defining variables
var a, b, c, d;
a = 10; // integer
b = .5; // float
c = 3.; // float
d = 3.14; // float
print(a);
print(b);
print(c);
print(d);
output:
$ python
>>> import yulang
>>> yulang.read("path/to/variables.yu")
print: 10
print: 0.5
print: 3
print: 3.14
import files
source codes in includes.yu
multiply a, b:
{
return a * b;
}
source codes in multi_files.yu
// relative to current directory of terminal (or shell)
// you can import multiple relative paths and they do not create errors
import: "tests/stable/multi_files/includes.yu"
import: "stable/multi_files/includes.yu"
import: "multi_files/includes.yu"
var c = multiply(a : 10, b : 20);
print(c);
output:
$ python
>>> import yulang
>>> yulang.read("path/to/multi_files.yu")
print: 200
Metadata
Release files for yulang 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| yulang-0.0.2.tar.gz | 916.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yulang-0.0.2-py38-none-win_amd64.whl | Python 3.8 | none | Windows x86-64 | Details |
Total release size: 1.8 MB
Release files / yulang-0.0.2.tar.gz
| Download URL | yulang-0.0.2.tar.gz |
|---|---|
| Size | 916.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac58e7d4d3a91451ad00bafa24f699ef77350e3721eb96db98a07178864e31d5
|
|
BLAKE2b-256 checksum How to use checksums |
93ef45eb29a69d6925e08aae17205af2f70dc0a24ca9e4a9d0151774aa22b6ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|
Release files / yulang-0.0.2-py38-none-win_amd64.whl
| Download URL | yulang-0.0.2-py38-none-win_amd64.whl |
|---|---|
| Size | 919.0 kB |
| Tags | Python 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
12c496e24cd2c4a1d34921107486d1bdcb805a2eb4c95334e0e1db0cfb039897
|
|
BLAKE2b-256 checksum How to use checksums |
f3816f88b32b0ebd75cb5a1ee9446b4e808c6831d1d00840ccdb88e4ff6abe31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|