Skip to content
This repository was archived by the owner on Nov 16, 2021. It is now read-only.

Commit 76b644d

Browse files
author
Glitch
committedMay 26, 2021
Added correct variable syntax
1 parent ce88fe8 commit 76b644d

File tree

3 files changed

+59
-10
lines changed

3 files changed

+59
-10
lines changed
 

‎README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## _**Attention!**_
1+
# PyScript
2+
###### The language.
3+
4+
25
If you are viewing this on github, view the [`githubREADME`](https://github.com/PyScript-Language/PyScript-Compiler/blob/master/githubREADME.md). If you are viewing this on replit, view the [`replitREADME`](https://github.com/PyScript-Language/PyScript-Compiler/blob/master/replitREADME.md)
36

4-
### Thank you in advance!
7+
### Thank you in advance!
8+
### Cya!

‎index.pys

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Note that this also belongs to static folder
22

3-
var jb;
3+
var jb = "eee";
44

55
// import("time");
66
// import("os");

‎main.py

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class InvalidModuleError(Exception):
3838
class InvalidStringIntError(Exception):
3939
pass
4040

41-
class Error(Exception):
41+
class TemplateError(Exception):
4242
pass
4343

4444
allvars = {}
@@ -52,6 +52,7 @@ class Error(Exception):
5252
input1 = "Undefined input"
5353
input2 = "Undefined input"
5454
input3 = "Undefined input"
55+
functions = ["time.time(", "os.system(", "os.userinfo(","time.sleep(","time.strftime(","window.alert(","console.print(","alert(","console.input(","window.prompt(","prompt(","if "]
5556

5657

5758
def timeTIME():
@@ -91,7 +92,7 @@ def osSYSTEM():
9192

9293
#print(res)
9394
try:
94-
os.system(f"{res}")
95+
os.system(str(res))
9596
except:
9697
raise InvalidModuleError(f"'{res}' command doesn't exist!")
9798
else:
@@ -372,14 +373,57 @@ def CONSOLEprint():
372373
#newvar = variable;
373374
if newvar[-1] == ";":
374375
if ";" in newvar[:-1]:
375-
raise InvalidSyntaxError("You must only include one semi-colon!")
376+
for i in newvar[:-1]:
377+
if "'" == i or "\"" == i or "`" == i:
378+
pass
379+
else:
380+
raise InvalidSyntaxError("You must only include one semi-colon!")
376381
else:
377382
newvarTEST = newvar[-1]
378383
newvar = newvar.replace(";","")#make ; disappear into blank space
379384
else:
380385
raise InvalidSyntaxError("Variable statement is missing semi-colon!")
386+
381387
if " " in newvar:
382-
raise InvalidSyntaxError("Variables cannot include spaces!")
388+
if "=" in newvar:
389+
idk = []
390+
Continue = True
391+
for i in newvar:
392+
if Continue:
393+
if i == "=":
394+
idk.append(i)
395+
Continue = False
396+
else:
397+
idk.append(i)
398+
else:
399+
if i == " ":
400+
idk.append(i)
401+
break
402+
else:
403+
break
404+
idk = "".join(idk)
405+
newvar = newvar.replace(idk, "")
406+
407+
if "'" in newvar or "\"" in newvar or "`" in newvar:
408+
if newvar in functions:
409+
e
410+
else:
411+
newvar = str(newvar) # makes sure its a string
412+
if newvar[-1] == "'" and newvar[0] == "'" or newvar[-1] == "\"" and newvar[0] == "\"" or newvar[-1] == "`" and newvar[0] == "`":
413+
newvar = newvar.replace(newvar[-1], "")
414+
#newvar = newvar.replace(newvar[0], "")
415+
else:
416+
raise InvalidSyntaxError("Starting quotations and end quotations must be the same!")
417+
allvars[newvar] = newvar
418+
elif newvar == "true":
419+
allvars[newvar] = True
420+
elif newvar == "false":
421+
allvars[newvar] = False
422+
423+
else:
424+
raise InvalidSyntaxError("Variables must be named after there is a equal sign!")
425+
else:
426+
raise InvalidSyntaxError("Variables cannot include spaces!")
383427
else:
384428
allvars[newvar] = 0
385429

@@ -488,6 +532,8 @@ def CONSOLEprint():
488532
alert()
489533

490534

535+
elif "if " in lines:
536+
e
491537

492538

493539
elif "time.sleep(" in lines:
@@ -522,9 +568,8 @@ def CONSOLEprint():
522568
elif "os.system(" in lines:
523569
osSYSTEM()
524570

525-
elif "os.environ[" in lines:
526-
osENVIRON()
527-
#pass #the function above doesnt even do anything.
571+
elif "os.userinfo(" in lines:
572+
osUSERINFO()
528573

529574

530575

0 commit comments

Comments
 (0)