Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
Merge branch 'main' of https://github.com/pranavbaburaj/long
Browse files Browse the repository at this point in the history
  • Loading branch information
lainq committed Apr 14, 2021
2 parents 984b4c7 + 8d7d890 commit ee05d20
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,16 @@ dist

# TernJS port file
.tern-port

# Files and directories created by pub
.dart_tool/
.packages

# Conventional directory for build outputs
build/

# Directory created by dartdoc
doc/api/


.vscode/
2 changes: 1 addition & 1 deletion lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class LongLexicalAnalyser {
* @constructor
* @param fileData the data in the file
*/
constructor(fileData) {
constructor(fileData:string) {
this.fileData = fileData.toString();
this.position = {position: 0, tail: false};
this.character = this.setCurrentCharacter();
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A simple programming language :winK;",
"main": "index.ts",
"scripts": {
"start" : "node dist/server.js",
"start": "node dist/server.js",
"build": "tsc server.ts --outDir dist --esModuleInterop true & node dist/server"
},
"repository": {
Expand Down Expand Up @@ -38,5 +38,7 @@
"files": [
"dist"
],
"engines": { "node": "14.5.0" }
"engines": {
"node": "14.5.0"
}
}
25 changes: 25 additions & 0 deletions repl/README.md
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)
81 changes: 81 additions & 0 deletions repl/cli.py
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()
28 changes: 28 additions & 0 deletions repl/setup.py
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',
)

0 comments on commit ee05d20

Please sign in to comment.