Python transpiler for the esoteric language Rockstar
Project description
Python transpiler for the esoteric language Rockstar
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Installing
First, make sure you have installed a supported Python version. We use python_requires=">= 3.4", but our tests only cover Python >= 3.6, since 3.5 is already reaching its EOF on september/2020.
Now, the easiest way of installing rockstar-py is using pip:
pip install rockstar-py
(This may require sudo if you’re installing globally on a *nix system.
You can also clone this project using git and install the package with setuptools:
git clone https://github.com/yyyyyyyan/rockstar-py.git cd rockstar-py python3 setup.py install
Usage
If you installed the package using pip or setuptools, you can simply run rockstar-py in the command line:
rockstar-py [-h] (-i INPUT | --stdin) [-o OUTPUT | --stdout | --exec] [-v]
Otherwise, you can run the transpiler from inside the rockstar-py folder by calling python with the -m flag:
python3 -W ignore -m rockstarpy [-h] (-i INPUT | --stdin) [-o OUTPUT | --stdout | --exec] [-v]
Call rockstar-py with the flag -h/--help to see a description of all options:
usage: rockstar-py [-h] (-i INPUT | --stdin) [-o OUTPUT | --stdout | --exec] [-v] Python transpiler for the esoteric language Rockstar optional arguments: -h, --help show this help message and exit -i INPUT, --input INPUT Input file (.rock) --stdin Stream in stdin -o OUTPUT, --output OUTPUT Output file (.py) --stdout Stream to stdout --exec Execute (without saving) the transpiled code -v, --version Version
Examples
Just to make it more clear, some examples with the fizz.rock code.
Basic usage
> rockstar-py -i fizz.rock -o fizz.py > ls fizz.py fizz.rock > cat fizz.py def Midnight(your_heart, your_soul): while your_heart >= your_soul: # this is a comment your_heart = your_heart - your_soul return your_heart Desire = 100 my_world = False Fire = 3 # i love comments Hate = 5 while not my_world == Desire: my_world += 1 if Midnight(my_world, Fire) == False and Midnight(my_world, Hate) == False: print("FizzBuzz!") continue if Midnight(my_world, Fire) == False: print("Fizz!") continue if Midnight(my_world, Hate) == False: print("Buzz!") continue print(my_world)
Using --stdout
> rockstar-py -i fizz.rock --stdout def Midnight(your_heart, your_soul): while your_heart >= your_soul: # this is a comment your_heart = your_heart - your_soul return your_heart Desire = 100 my_world = False Fire = 3 # i love comments Hate = 5 while not my_world == Desire: my_world += 1 if Midnight(my_world, Fire) == False and Midnight(my_world, Hate) == False: print("FizzBuzz!") continue if Midnight(my_world, Fire) == False: print("Fizz!") continue if Midnight(my_world, Hate) == False: print("Buzz!") continue print(my_world)
Using --stdin
> rockstar-py --stdin -o fizz.py Midnight takes your heart and your soul While your heart is as high as your soul (this is a comment) Put your heart without your soul into your heart Give back your heart Desire's a lovestruck ladykiller My world is empty Fire's ice (i love comments) Hate is water Until my world is Desire, Build my world up If Midnight taking my world, Fire is nothing and Midnight taking my world, Hate is nothing Shout "FizzBuzz!" Take it to the top If Midnight taking my world, Fire is nothing Shout "Fizz!" Take it to the top If Midnight taking my world, Hate is nothing Say "Buzz!" Take it to the top Whisper my world [Ctrl+D] > ls fizz.py fizz.rock
Using --exec
> rockstar-py -i fizz.rock --exec 1 2 Fizz! 4 Buzz! Fizz! 7 8 Fizz! Buzz! 11 Fizz! 13 14 FizzBuzz! 16 17 Fizz! 19 Buzz! Fizz! 22 23 Fizz! Buzz! 26 Fizz! 28 29 FizzBuzz! 31 32 Fizz! 34 Buzz! Fizz! 37 38 Fizz! Buzz! 41 Fizz! 43 44 FizzBuzz! 46 47 Fizz! 49 Buzz! Fizz! 52 53 Fizz! Buzz! 56 Fizz! 58 59 FizzBuzz! 61 62 Fizz! 64 Buzz! Fizz! 67 68 Fizz! Buzz! 71 Fizz! 73 74 FizzBuzz! 76 77 Fizz! 79 Buzz! Fizz! 82 83 Fizz! Buzz! 86 Fizz! 88 89 FizzBuzz! 91 92 Fizz! 94 Buzz! Fizz! 97 98 Fizz! Buzz!
Contributing
The project has basically reached its end, but I’m still accepting pull requests that improve speed and legibility of the code.
Contributors
Huge thanks to everyone who is contribuing to this project. Check them out at Contributors!
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Hat tip to dylanbeattie for creating Rockstar
The FizzBuzz example works well. If valid code doesn’t work, create an issue so I can get a look.
I’ll work on the readibility and organization of the code, would love suggestions on how/where to do that.
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
Hashes for rockstar_py-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5da2bc0da424b1e9677fb9fbdc9a0be49b4470fd296418d97733666964bf287 |
|
MD5 | c4441aa2ea38f282eb8747b071524a95 |
|
BLAKE2b-256 | 8fb6d4fa8b057ed06aa76a8274f45e36a35af70d452b7956382dbbb6023dbc0b |