Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
/ metapython Public archive

metaprogramming extension for python programming language

Notifications You must be signed in to change notification settings

imperzer0/metapython

Repository files navigation

METAPYTHON

metaprogramming extension for python programming language

General explanation

It's just an application that generates python code from metapython code. Metapython programming language has the same syntax as python. But it has a feature of code segment preprocessing.

It looks like this

result=@@@
def __metagenerator__():
    return 122+23
@@@
print(result)

If you compile the code above you'll get

result=145
print(result)

Metapython gets the code between @@@, executes it during compilation and places the result instead of it.

The syntax

The syntax of metacode segment is the same as python's, except it requires __metagenerator__ token to obtain the execution result.

It could be a function that returns the result or a variable that stores the result.

If the result is a string, compiler will substitute it directly (without the quotes). Otherwise, it will convert it into string and then substitute.

Examples

result = @@@
def __metagenerator__():
    return "\"the result will be a string\""
@@@

Turns into

result = "the result will be a string"

result = @@@__metagenerator__="122"+"150"@@@

Turns into

result = 122150

result = @@@__metagenerator__=(1, 2, 4, 5)@@@

Turns into

result = (1, 2, 4, 5)

Installation

From AUR (Arch-based distros)

yay -Sy metapython

From Git repository

git clone https://github.com/imperzer0/metapython.git
cd metapython

Archlinux

makepkg -sif

Other distributions

sudo bash -c ". ./PKGBUILD && build && notarch_package"

About

metaprogramming extension for python programming language

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published