Skip to content

Commit

Permalink
MAJOR UPDATE 3!
Browse files Browse the repository at this point in the history
added long_script.potscr, added interactive shell, made website a lot easier to look at, added multiplication and division, made a function for doing math operations, made potscr logo, did a bunch of other crap to make potscr better
  • Loading branch information
James A. Clark committed Sep 17, 2021
1 parent 67577b7 commit a0bab32
Show file tree
Hide file tree
Showing 10 changed files with 382 additions and 151 deletions.
16 changes: 5 additions & 11 deletions README.md
Expand Up @@ -13,14 +13,8 @@ go [here](https://nanobot567.github.io/potscr)

### how to parse potatoscript

* download the latest version of python from [the website](https://python.org/downloads/)
* clone the latest version of potscr
* open command prompt and change your directory to wherever you downloaded potscr-main to
* type ```python potscr.py (potatoscript file path)```
* your output will be showed in command prompt!

### to-do

- add an interactive shell
- add more stuff to the cli
- unlimited char numeric addition
1. download the latest version of python from [the website](https://python.org/downloads/)
2. clone the latest version of potscr
3. open command prompt and change your directory to wherever you downloaded potscr-main to
4. type ```python potscr.py (potatoscript file path)```
5. your output will be showed in command prompt!
1 change: 1 addition & 0 deletions examples/long_script.potscr
@@ -0,0 +1 @@
~-Please type an integer: _%#%//-That integer plus, minus, times, and divided by 5: _/+%^`%`%^+%>%^&%&%^~
128 changes: 128 additions & 0 deletions files/shell.py
@@ -0,0 +1,128 @@
from sys import stdout
from time import sleep

storednum = 0

def shell():
global storednum
txtfound = ""
curnum = 0
lookinfortxt = ""
firstTime = True
stored = ""
shellver = 1.0

while True:
curnum = 0
shellIn = ""
if firstTime:
print(f"potscr shell v{shellver}\n")
print("type 'quit' to exit.")
firstTime = False

shellIn = input("> ")
if shellIn == "quit" or shellIn == "q" or shellIn == "bye" or shellIn == "exit":
exit()

# code in potscr.py starts here

def mathsomethin(type):
global storednum
try:
if shellIn[curnum+1] == "%":
if shellIn[curnum+2].isnumeric():
if type == "+":
storednum += int(shellIn[curnum+2])
elif type == "-":
storednum -= int(shellIn[curnum+2])
elif type == "*":
storednum = storednum * int(shellIn[curnum+2])
elif type == "/":
storednum = storednum / int(shellIn[curnum+2])
else:
if type == "+":
storednum += 5
elif type == "-":
storednum -= 5
elif type == "*":
storednum = storednum * 5
elif type == "/":
storednum = storednum / 5
except IndexError:
if type == "+":
storednum += 1
elif type == "-":
storednum -= 1
elif type == "*":
storednum = storednum * 1
elif type == "/":
storednum = storednum / 1



for i in range(0,shellIn.__len__()):
char = shellIn[curnum]
if char == "-": # start of print
lookinfortxt = True
elif char == "_": # end of print
lookinfortxt = False
try:
if shellIn[curnum+1] == "%": # percentage after means an alt version of the command, in this case no newline
stdout.write(txtfound[1:])
stdout.flush()
txtfound = ""
else:
print(txtfound[1:])
txtfound = ""
except IndexError:
print(txtfound[1:])
txtfound = ""
elif char == "#": # get input
temp = input()
try:
if temp.isnumeric() and shellIn[curnum+1] == "%":
storednum = int(temp)
elif shellIn[curnum+1] == "%" and not temp.isnumeric():
print("ERROR: Input must be an integer!")
exit()
else:
stored = temp
except:
stored = temp

elif char == "$": # print stored var
print(stored,end="")
elif char == "/": # newline
print("")
elif char == "*": # reset stored number
storednum = 0
elif char == "+": # number +
mathsomethin("+")
elif char == "`": # number -
mathsomethin("-")
elif char == ">": # number multiplied
mathsomethin("*")
elif char == "&": # number divided
mathsomethin("/")
elif char == "^": # print stored num
try:
if shellIn[curnum+1] == "%":
print(storednum,end="")
else:
print(storednum)
except IndexError:
print(storednum)

elif char == "@": # sleep
try:
sleep(int(shellIn[curnum+1]))
except ValueError:
print(f"\nERROR: Char {curnum}: An integer is required for sleeping")
exit()



if lookinfortxt:
txtfound += char

curnum += 1
16 changes: 7 additions & 9 deletions index.html
@@ -1,23 +1,21 @@
<!DOCTYPE html>
<html>
<style>
h1{
color:sienna;
font-family: "Segoe UI";
font-size: 45px;
}

</style>


<head>
<title>potatoscript - home</title>
<link rel="icon" type="image/png" href="website/favicon.png"/>
<link rel="icon" type="image/png" href="website/img/favicon.png"/>
<link rel="stylesheet" type="text/css" href="website/css/style.css"/>
</head>
<body>
<h1>potatoscript</h1>
<img src="website/img/potscr.png">
<!--<h1>potatoscript</h1>!-->
<h2>potatoscript is an esoteric programming language, similar to unlambda.</h3>
<a href="website/guide.html">potatoscript programming guide</a>
<a href="website/guide.html"><button>potatoscript programming guide</button></a>
<p></p>
<a href="website/cli.html">cli usage guide</a>
<a href="website/cli.html"><button>cli usage guide</button></a>
</body>
</html>

0 comments on commit a0bab32

Please sign in to comment.