This repository has been archived by the owner on Jul 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/pranavbaburaj/long
- Loading branch information
Showing
7 changed files
with
157 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Long | ||
|
||
[![chat](https://shields.io/discord/808537055177080892)](https://discord.gg/vzcNRVrHR5) | ||
![stars](https://img.shields.io/github/stars/pranavbaburaj/long?color=%237289da&label=stars&style=plastic) | ||
![draw](https://img.shields.io/github/last-commit/pranavbaburaj/long) | ||
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=A%20simple%20esoteric%20programming%20language%204&url=https://github.com/pranavbaburaj/long&via=baburaj_pranav&hashtags=developers,esoteric,language) | ||
|
||
> You can find more about the language is [this blog](https://dev.to/pranavbaburaj/long-an-esoteric-language-pag?fbclid=IwAR14z86ebnanThbxtTmo8RKuEUtbu5PSuWBx5nMV2_J_u0eqbSzfYAvsMJg) | ||
A simple, elegant, useless, minimal esoteric programming language created for fun | ||
|
||
> ### An example | ||
> | ||
> ``` | ||
> 72+#29+#7+##3+#79-# 55+#24+#3+#6-#8-#68-#1+# ; | ||
> ``` | ||
|
||
## Documentation | ||
|
||
The documentation is under contruction | ||
|
||
## License | ||
|
||
The long programming language is licensed under the MIT license . You can read it [here](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from clint.textui import colored | ||
import sys as process | ||
import json as json | ||
import requests as requests | ||
|
||
|
||
class LongReplException(object): | ||
def __init__(self, exception_message, suggestion, error_type): | ||
self.exception_message = exception_message | ||
self.suggestion = suggestion | ||
|
||
self.error_type = error_type | ||
self.evoke_repl_exception() | ||
|
||
def evoke_repl_exception(self): | ||
stdout_message = [ | ||
colored.red(f"[{self.error_type}] {self.exception_message}"), | ||
colored.green(f"[Suggestion] {self.suggestion}") | ||
] | ||
for stdout_message_index in range(len(stdout_message)): | ||
message = stdout_message[stdout_message_index] | ||
print(message) | ||
|
||
def __len__(self): | ||
return len(self.exception_message) | ||
|
||
def __repr__(self): | ||
return self.exception_message | ||
|
||
def __str__(self): | ||
return self.exception_message | ||
|
||
|
||
def prompt(prompt_message=">"): | ||
print(colored.cyan(f"{prompt_message} "), end='') | ||
try: | ||
input_data = str(input()) | ||
except KeyboardInterrupt: | ||
exception = LongReplException("Your keyboard interrupted", | ||
"Restart the repl", "KeyBoardInterrupt") | ||
process.exit() | ||
|
||
return input_data | ||
|
||
|
||
def execute_code_snippet(code_snippet): | ||
request_body = json.dumps({"code": code_snippet}) | ||
request_url = 'https://long-1.pranavbaburaj.repl.co/run' | ||
try: | ||
response = requests.request( | ||
'POST', | ||
request_url, | ||
data=request_body, | ||
headers={'Content-Type': 'application/json'}) | ||
response_data = json.loads(response.content.decode("utf-8")) | ||
if "stdout" in response_data: | ||
for stdout_element_index in range(len(response_data["stdout"])): | ||
stdout_element = response_data["stdout"][stdout_element_index] | ||
print(colored.green(stdout_element), end='') | ||
|
||
if len(response_data["stdout"]) != 0: | ||
print("") | ||
|
||
except Exception as exception_message: | ||
error = LongReplException("An unknown error occured", "Try again", | ||
"UnknownError") | ||
process.exit() | ||
|
||
|
||
def initialize_long_cli(): | ||
user_exists_repl = False | ||
while not user_exists_repl: | ||
code_input = prompt() | ||
|
||
if code_input == ".exit": | ||
user_exists_repl = True | ||
execute_code_snippet(code_input) | ||
|
||
|
||
if __name__ == "__main__": | ||
initialize_long_cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import setuptools | ||
|
||
with open("README.md", "r", encoding="utf-8") as fh: | ||
long_description = fh.read() | ||
|
||
DEPENDENCIES = ["clint", "requests"] | ||
|
||
setuptools.setup( | ||
name="long-cli", # Replace with your own username | ||
version="0.0.2", | ||
author="P Pranav Baburaj", | ||
author_email="code-roller@googlegroups.com", | ||
description="A simple esoteric programming language", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/pranavbaburaj/long", | ||
packages=setuptools.find_packages(), | ||
install_requires=DEPENDENCIES, | ||
entry_points={"console_scripts": [ | ||
'long = cli:initialize_long_cli', | ||
]}, | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
], | ||
python_requires='>=3.6', | ||
) |