├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── githubREADME.md ├── index.pys ├── main.py ├── replitREADME.md ├── static ├── index.js └── style.css └── templates ├── index.bhtml └── index.html /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | . 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Glitch 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PyScript 2 | ###### The language. 3 | 4 | 5 | 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://replit.com/@JBloves27/PyScript-Compiler#replitREADME.md) 6 | 7 | ### Thank you in advance! 8 | ### Cya! -------------------------------------------------------------------------------- /githubREADME.md: -------------------------------------------------------------------------------- 1 |

PyScript

2 |
The Unoffical and Offical Language coded by @JBYT27
3 |
View the replitREADME.md if you are viewing this on replit. 4 | 5 |
6 | 7 | ## About the language 8 | #### PyScript is a PL *(programming language)*; `Python` combined with `JavaScript`. The syntax is a bit wobbled up, but it's basically `JavaScript` syntax and `Python` syntax mashed together. Like I said, it's wobbled up because they don't really fit, __`whitespace`__ *vs* __`brackets`__. For more info about the syntax, you can visit the docs (below). The language is meant to be a scripting language combined with a bit of `OOP`* Language as well. So it's mostly a `Scripting` Language, bit then again, it can be used as an `OOP` Language. 9 | 10 |
11 | 12 | ## Using the PL 13 | #### To use it, please either fork the repl, or fork the repo, either one works! :) 14 | 15 |
16 | 17 | ## Code of Conduct 18 | #### Please view the [`CODE_OF_CONDUCT`](https://github.com/PyScript-Language/PyScript-Compiler/blob/master/CODE_OF_CONDUCT.md) README! 19 | 20 |
21 | 22 | ## License 23 | #### This project is under the MIT License. Please view the [`LICENSE`](https://github.com/PyScript-Language/PyScript-Compiler/blob/master/LICENSE) for more! 24 | 25 |
26 | 27 | ## PyScript Docs 28 | #### The docs are located in a separate repo/repl, but the link is [here](https://pyscript-docs.jbloves27.repl.co) 29 | > Note that it might take a long time to load as it is coded in reactjs. 30 | 31 | ##### * OOP stands for Object-Oriented-Programming 32 | -------------------------------------------------------------------------------- /index.pys: -------------------------------------------------------------------------------- 1 | // Note that this also belongs to static folder 2 | 3 | import("os"); 4 | 5 | var jb = os.userinfo(); 6 | 7 | // import("time"); 8 | // import("os"); 9 | 10 | // console.input(jb); 11 | 12 | // time.sleep(2); 13 | 14 | // console.print('{{jb}}'); 15 | 16 | // window.alert("{{time.time();}}"); 17 | 18 | // os.system("clear"); -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import time, os, sys, getpass, re, string 2 | 3 | fp = input('FilePath: ') 4 | 5 | if '.pys' in fp:#hmmmm 6 | try: 7 | f = open(f'{fp}') 8 | except: 9 | raise Exception("No Such File Exists!") 10 | else: 11 | raise Exception("The file isn't a '.pys' file!") 12 | 13 | content = f.read() 14 | colist = content.split("\n") 15 | 16 | def check(): 17 | df = re.findall("(?<=[AZaz])?(?!\d*=)[0-9.+-]+", lines) 18 | df = str(df) 19 | 20 | def wait_until(somepredicate, timeout, period=0.25, *args, **kwargs): 21 | mustend = time.time() + timeout 22 | while time.time() < mustend: 23 | if somepredicate(*args, **kwargs): return True 24 | time.sleep(period) 25 | return False 26 | 27 | #all errors 28 | class InvalidVariableError(Exception): 29 | pass 30 | class InvalidSyntaxError(Exception): 31 | pass 32 | class InvalidIndentationError(Exception): 33 | pass 34 | class InvalidModuleError(Exception): 35 | pass 36 | class InvalidStringIntError(Exception): 37 | pass 38 | 39 | class TemplateError(Exception): 40 | pass 41 | 42 | allvars = {} 43 | line = 0 44 | read_line=0 45 | PASS = False 46 | getChar1 = "none" 47 | getChar2 = "none" 48 | getChar3 = "none" 49 | var1 = "Undefined variable" 50 | input1 = "Undefined input" 51 | input2 = "Undefined input" 52 | input3 = "Undefined input" 53 | functions = ["os.userinfo(","time.strftime(","window.alert(","console.print(","alert(","console.input(","window.prompt(","prompt("] 54 | 55 | 56 | def timeTIME(): 57 | if time_module == 1: 58 | wrd = "time.time(" 59 | res = lines.partition(wrd)[2] 60 | res = res.replace(");","") 61 | print(res) 62 | 63 | if type(res) == str: 64 | if res == " " or res == "": 65 | time.time()#this won't do anything of course, unless you print it ;) 66 | else: 67 | raise InvalidStringIntError("'time.time' must be empty!") 68 | else: 69 | raise InvalidStringIntError("'time.time' must be empty!") 70 | else: 71 | raise InvalidModuleError("The 'time' module isn't imported or it doesn't exist!") 72 | 73 | def osSYSTEM(): 74 | if os_module == 1: 75 | wrd = "os.system(" 76 | res = lines.partition(wrd)[2] 77 | 78 | if res[-3] == "\"" and res[0] == "\'" or res[-3] == "'" and res[0] == "\"": 79 | raise InvalidSyntaxError("The 'os.system' starting quotations and ending quotations are different!") 80 | else: 81 | if "\"" in res: 82 | split_string = res.split("\");", -1) 83 | elif "'" in res: 84 | split_string = res.split("\');", -1) 85 | else: 86 | raise InvalidSyntaxError("The 'os.system' statement is missing quotations!") 87 | res = res.replace("\"", "") 88 | res = res.replace("'", "") 89 | res = res.replace(");", "") 90 | 91 | #print(res) 92 | try: 93 | os.system(str(res)) 94 | except: 95 | raise InvalidModuleError(f"'{res}' command doesn't exist!") 96 | else: 97 | raise InvalidModuleError("The 'os' module isn't imported or it doesn't exist!") 98 | 99 | def osUSERINFO(): 100 | if os_module == 1: 101 | wrd = "os.userinfo(" 102 | global res 103 | res = lines.partition(wrd)[2] 104 | 105 | if " " in res: 106 | raise InvalidSyntaxError("'os.userinfo' cannot include spaces!") 107 | else: 108 | if ");" in res: 109 | res = res.replace(");","") 110 | else: 111 | raise InvalidSyntaxError("'os.userinfo' must have ');'!") 112 | if res == "" or res == " ": 113 | try: 114 | print(os.environ["REPL_OWNER"]) 115 | except: 116 | raise InvalidModuleError("This function does not exist on your device!") 117 | else: 118 | raise InvalidModuleError("'os.userinfo' must be empty!") 119 | else: 120 | raise InvalidModuleError("The 'os' module isn't imported or it doesn't exist!") 121 | 122 | 123 | ''' 124 | Note that ascii characters are used like this in pyscript: 125 | /1234 or /u1243 126 | Of course, those are examples ;) Another thing I should mention is that not all characters have been made yet ;) 127 | ''' 128 | 129 | def WINDOWalert():#add f'string 130 | try: 131 | if '");' in lines or "');" in lines or "`);" in lines: 132 | wrd = "window.alert(" 133 | res = lines.partition(wrd)[2] 134 | #print(res) 135 | if res[-3] == "\"" and res[0] == "\'" or res[-3] == "\"" and res[0] == "`" or res[-3] == "'" and res[0] == "\"" or res[-3] == "'" and res[0] == "`" or res[-3] == "`" and res[0] == "\"" or res[-3] == "`" and res[0] == "'": 136 | raise InvalidSyntaxError("The 'window.alert' starting quotations and ending quotations are different!") 137 | else: 138 | res = res.replace("\");","") 139 | res = res.replace('`);',"") 140 | res = res.replace('\');',"") 141 | res = res.replace("/n", "\n") 142 | res = res.replace("/t", "\t") 143 | if "\"" in res: 144 | split_string = res.split("\");", -1) 145 | elif "'" in res: 146 | split_string = res.split("\');", -1) 147 | elif "`" in res: 148 | split_string = res.split("`);", -1) 149 | else: 150 | raise InvalidSyntaxError("The 'window.alert' statement is missing quotations!") 151 | res = split_string[0] 152 | res = res.replace("\");","") 153 | res = res.replace('`);',"") 154 | res = res.replace('\');',"") 155 | res = res.replace("/n", "\n") 156 | res = res.replace("/t", "\t") 157 | #colors: res = res.replace("{red}", red) 158 | res = res.replace('"', "") 159 | res = res.replace("'", "") 160 | res = res.replace("`", "") 161 | res = res.replace(");","") 162 | 163 | if "{{" in res: 164 | if "}}" in res: 165 | start = "{{" 166 | end = "}}" 167 | check = res[res.find(start) + len(start):res.rfind(end)] 168 | if check in allvars: 169 | res = res.replace("{{", "") 170 | res = res.replace("}}", "") 171 | dffdfdfdf = allvars[check] 172 | res = res.replace(check, str(dffdfdfdf)) 173 | else: 174 | global PASS 175 | PASS = False 176 | if "time.time(" in check: 177 | if check[-1] == "(": 178 | print(time.time()) 179 | PASS = True 180 | else: 181 | raise InvalidSyntaxError("'time.time' must be empty!") 182 | elif "time.strftime(" in check: 183 | #print(timeSTRFTIME()) 184 | PASS = True 185 | else: 186 | #print(var) 187 | #print(res) 188 | raise InvalidVariableError(f"'{var}' variable does not exist!") 189 | if PASS: 190 | pass 191 | else: 192 | print(res, end="") 193 | print() 194 | else: 195 | raise InvalidSyntaxError("The 'window.alert' statement must have a closing ');!") 196 | except: 197 | raise InvalidSyntaxError("The 'window.alert' statement must have a closing ');!") 198 | 199 | def alert(): 200 | try: 201 | if '");' in lines or "');" in lines or "`);" in lines: 202 | wrd = "alert(" 203 | res = lines.partition(wrd)[2] 204 | if res[-3] == "\"" and res[0] == "\'" or res[-3] == "\"" and res[0] == "`" or res[-3] == "'" and res[0] == "\"" or res[-3] == "'" and res[0] == "`" or res[-3] == "`" and res[0] == "\"" or res[-3] == "`" and res[0] == "'": 205 | raise InvalidSyntaxError("The 'alert' starting quotations and ending quotations are different!") 206 | else: 207 | res = res.replace("\");","") 208 | res = res.replace('`);',"") 209 | res = res.replace('\');',"") 210 | res = res.replace("/n", "\n") 211 | res = res.replace("/t", "\t") 212 | if "\"" in res: 213 | split_string = res.split("\");", -1) 214 | elif "'" in res: 215 | split_string = res.split("\');", -1) 216 | elif "`" in res: 217 | split_string = res.split("`);", -1) 218 | else: 219 | raise InvalidSyntaxError("The 'alert' statement is missing quotations!") 220 | res = split_string[0] 221 | res = res.replace("\");","") 222 | res = res.replace('`);',"") 223 | res = res.replace('\');',"") 224 | res = res.replace("/n", "\n") 225 | res = res.replace("/t", "\t") 226 | #colors: res = res.replace("{red}", red) 227 | res = res.replace('"', "") 228 | res = res.replace("'", "") 229 | res = res.replace("`", "") 230 | res = res.replace(");","") 231 | 232 | if "{{" in res: 233 | if "}}" in res: 234 | start = "{{" 235 | end = "}}" 236 | check = res[res.find(start) + len(start):res.rfind(end)] 237 | if check in allvars: 238 | res = res.replace("{{", "") 239 | res = res.replace("}}", "") 240 | dffdfdfdf = allvars[check] 241 | res = res.replace(check, str(dffdfdfdf)) 242 | else: 243 | global PASS 244 | PASS = False 245 | if "time.time(" in check: 246 | if check[-1] == "(": 247 | print(time.time()) 248 | PASS = True 249 | else: 250 | raise InvalidSyntaxError("'time.time' must be empty!") 251 | elif "time.strftime(" in check: 252 | #print(timeSTRFTIME()) 253 | PASS = True 254 | else: 255 | raise InvalidVariableError(f"'{var}' variable does not exist!") 256 | if PASS: 257 | pass 258 | else: 259 | print(res, end="") 260 | print() 261 | else: 262 | raise InvalidSyntaxError("The 'alert' statement must have a closing ');!") 263 | except: 264 | raise InvalidSyntaxError("The 'alert' statement must have a closing ');!") 265 | 266 | def CONSOLEprint(): 267 | try: 268 | if '");' in lines or "');" in lines or "`);" in lines: 269 | wrd = "console.print(" 270 | res = lines.partition(wrd)[2] 271 | if res[-3] == "\"" and res[0] == "\'" or res[-3] == "\"" and res[0] == "`" or res[-3] == "'" and res[0] == "\"" or res[-3] == "'" and res[0] == "`" or res[-3] == "`" and res[0] == "\"" or res[-3] == "`" and res[0] == "'": 272 | raise InvalidSyntaxError("The 'console.print' starting quotations and ending quotations are different!") 273 | else: 274 | res = res.replace("\");","") 275 | res = res.replace('`);',"") 276 | res = res.replace('\');',"") 277 | res = res.replace("/n", "\n") 278 | res = res.replace("/t", "\t") 279 | if "\"" in res: 280 | split_string = res.split("\");", -1) 281 | elif "'" in res: 282 | split_string = res.split("\');", -1) 283 | elif "`" in res: 284 | split_string = res.split("`);", -1) 285 | else: 286 | raise InvalidSyntaxError("The 'console.print' statement is missing quotations!") 287 | res = split_string[0] 288 | res = res.replace("\");","") 289 | res = res.replace('`);',"") 290 | res = res.replace('\');',"") 291 | res = res.replace("/n", "\n") 292 | res = res.replace("/t", "\t") 293 | #colors: res = res.replace("{red}", red) 294 | res = res.replace('"', "") 295 | res = res.replace("'", "") 296 | res = res.replace("`", "") 297 | res = res.replace(");","") 298 | 299 | if "{{" in res: 300 | if "}}" in res: 301 | start = "{{" 302 | end = "}}" 303 | check = res[res.find(start) + len(start):res.rfind(end)] 304 | if check in allvars: 305 | res = res.replace("{{", "") 306 | res = res.replace("}}", "") 307 | dffdfdfdf = allvars[check] 308 | res = res.replace(check, str(dffdfdfdf)) 309 | else: 310 | global PASS 311 | PASS = False 312 | if "time.time(" in check: 313 | if check[-1] == "(": 314 | print(time.time()) 315 | PASS = True 316 | else: 317 | raise InvalidSyntaxError("'time.time' must be empty!") 318 | elif "time.strftime(" in check: 319 | #print(timeSTRFTIME()) 320 | PASS = True 321 | else: 322 | raise InvalidVariableError(f"'{var}' variable does not exist!") 323 | if PASS: 324 | pass 325 | else: 326 | print(res, end="") 327 | print() 328 | else: 329 | raise InvalidSyntaxError("The 'console.print' statement must have a closing ');!") 330 | except: 331 | raise InvalidSyntaxError("The 'console.print' statement must have a closing ');!") 332 | 333 | 334 | 335 | newvar = 0 336 | time_module = 0 337 | file = open(fp) 338 | readline2 = 0 339 | for lines in file.readlines(): 340 | 341 | #print(lines) 342 | 343 | if "/#" in lines: 344 | readline2=1 345 | #print(wait_until("*/", 0)) 346 | wait_until("#/", 0) 347 | if readline2 == 1: 348 | readline2 = 0 349 | continue 350 | if "//" in lines:#maybe change to /# 351 | readline2=1 352 | 353 | line+=1 354 | lines = lines.replace('\n','') 355 | lines = lines.replace('\t','') 356 | 357 | #print(lines) 358 | 359 | if lines == '': 360 | pass 361 | elif lines in string.whitespace: 362 | raise InvalidIndentationError("Your indentation does not fit the other statements!") 363 | elif "/#" in lines: 364 | wait_until("#/", 0) 365 | readline2 = 1 366 | elif "//" in lines: 367 | pass 368 | lines = lines.rstrip() 369 | 370 | #print(lines[:2]) 371 | 372 | ''' 373 | elif " " in lines or "\t" in lines or " " in lines: 374 | raise InvalidIndentationError(f"line {line}, the indentation does not fit the other statements!") 375 | ''' 376 | 377 | ''' 378 | Note that `;`'s are strictly required in this language 379 | ''' 380 | 381 | if lines[:2] == "//" or "//" in lines: 382 | pass 383 | read_line = 0 384 | elif "import(\"time\");" in lines or "import('time');" in lines:#add semicolon error 385 | time_module = 1 386 | elif "import(\"os\");" in lines or "import('os');" in lines: 387 | os_module = 1 388 | elif "var " in lines: 389 | wrd = "var " 390 | newvar = lines.partition(wrd)[2] 391 | split_string = newvar.split("\")", -1) 392 | newvar.replace(")","") 393 | newvar.replace('\"', '') 394 | newvar = split_string[0] 395 | #newvar = variable; 396 | if newvar[-1] == ";": 397 | if ";" in newvar[:-1]: 398 | for i in newvar[:-1]: 399 | if "'" == i or "\"" == i or "`" == i: 400 | pass 401 | else: 402 | raise InvalidSyntaxError("You must only include one semi-colon!") 403 | else: 404 | newvarTEST = newvar[-1] 405 | newvar = newvar.replace(";","")#make ; disappear into blank space 406 | else: 407 | raise InvalidSyntaxError("Variable statement is missing semi-colon!") 408 | 409 | if " " in newvar: 410 | if "=" in newvar: 411 | idk = [] 412 | Continue = True 413 | for i in newvar: 414 | if Continue: 415 | if i == "=": 416 | idk.append(i) 417 | Continue = False 418 | else: 419 | idk.append(i) 420 | else: 421 | if i == " ": 422 | idk.append(i) 423 | break 424 | else: 425 | break 426 | idk = "".join(idk) 427 | newvar = newvar.replace(idk, "") 428 | 429 | if "'" in newvar or "\"" in newvar or "`" in newvar or "os.userinfo(" in newvar: 430 | if newvar in functions: 431 | if "console.print(" in newvar: 432 | CONSOLEprint() 433 | elif "window.alert(" in newvar: 434 | WINDOWalert() 435 | elif "alert(" in newvar: 436 | alert() 437 | 438 | elif "window.prompt(" in newvar: 439 | e 440 | elif "prompt(" in newvar: 441 | e 442 | elif "console.input(" in newvar: 443 | e 444 | 445 | elif "os.userinfo(" in newvar: 446 | osUSERINFO() 447 | allvars[res] = os.environ["REPL_OWNER"] 448 | 449 | elif "time.strftime(" in newvar: 450 | if time_module == 1: 451 | timeSTRFTIME() 452 | #allvars[] = time.strftime() 453 | else: 454 | raise InvalidModuleError("The 'time' module isn't imported or it doesn't exist!") 455 | 456 | else: 457 | newvar = str(newvar) # makes sure its a string 458 | if newvar[-1] == "'" and newvar[0] == "'" or newvar[-1] == "\"" and newvar[0] == "\"" or newvar[-1] == "`" and newvar[0] == "`": 459 | newvar = newvar.replace(newvar[-1], "") 460 | #newvar = newvar.replace(newvar[0], "") 461 | elif "os.userinfo(" in newvar: 462 | pass 463 | else: 464 | raise InvalidSyntaxError("Starting quotations and end quotations must be the same!") 465 | allvars[newvar] = newvar 466 | elif newvar == "true": 467 | allvars[newvar] = True 468 | elif newvar == "false": 469 | allvars[newvar] = False 470 | 471 | else: 472 | raise InvalidSyntaxError("Variables must be named after there is a equal sign!") 473 | else: 474 | raise InvalidSyntaxError("Variables cannot include spaces!") 475 | else: 476 | allvars[newvar] = 0 477 | 478 | 479 | 480 | elif "window.prompt(" in lines: 481 | wrd = "window.prompt(" 482 | var = lines.partition(wrd)[2] 483 | if var[-1] == ";": 484 | split_string = var.split(");", -1) 485 | var.replace(');','') 486 | var.replace('\"',"") 487 | var.replace('\'',"") 488 | var.replace('`',"") 489 | var = split_string[0] 490 | var.strip(");") 491 | 492 | if var in allvars: 493 | var = input() 494 | allvars[newvar] = var 495 | else: 496 | if var not in allvars: 497 | raise InvalidVariableError(f"'{var}' variable does not exist!") 498 | else: 499 | pass 500 | else: 501 | raise InvalidSyntaxError("'window.prompt' statement is missing semi-colon!") 502 | elif "prompt(" in lines: 503 | wrd = "prompt(" 504 | var = lines.partition(wrd)[2] 505 | if var[-1] == ";": 506 | split_string = var.split(");", -1) 507 | var.replace(');','') 508 | var.replace('\"',"") 509 | var.replace('\'',"") 510 | var.replace('`',"") 511 | var = split_string[0] 512 | var.strip(");") 513 | 514 | if var in allvars: 515 | var = input() 516 | allvars[newvar] = var 517 | else: 518 | if var not in allvars: 519 | raise InvalidVariableError(f"'{var}' variable does not exist!") 520 | else: 521 | pass 522 | else: 523 | raise InvalidSyntaxError("'prompt' statement is missing semi-colon!") 524 | elif "console.input(" in lines: 525 | wrd = "console.input(" 526 | var = lines.partition(wrd)[2] 527 | if var[-1] == ";": 528 | split_string = var.split(");", -1) 529 | var.replace(');','') 530 | var.replace('\"',"") 531 | var.replace('\'',"") 532 | var.replace('`',"") 533 | var = split_string[0] 534 | var.strip(");") 535 | 536 | if var in allvars: 537 | var = input() 538 | allvars[newvar] = var 539 | else: 540 | if var not in allvars: 541 | raise InvalidVariableError(f"'{var}' variable does not exist!") 542 | else: 543 | pass 544 | else: 545 | raise InvalidSyntaxError("'console.input' statement is missing semi-colon!") 546 | 547 | 548 | elif "window.alert(" in lines: 549 | WINDOWalert() 550 | elif "console.print(" in lines: 551 | CONSOLEprint() 552 | elif "alert(" in lines: 553 | alert() 554 | 555 | 556 | elif "if " in lines: 557 | e 558 | 559 | 560 | elif "time.sleep(" in lines: 561 | if time_module == 1: 562 | wrd = "time.sleep(" 563 | res = lines.partition(wrd)[2] 564 | 565 | if res[-1] == ";": 566 | try: 567 | res = res.replace(");","") 568 | for i in res: 569 | if i in ["1","2","3","4","5","6","7","8","9","0"]: 570 | time.sleep(int(res)) 571 | else: 572 | raise InvalidStringIntError("Strings cannot be inside integer values!") 573 | except: 574 | raise InvalidSyntaxError("There must be only one semi-colon!") 575 | else: 576 | raise InvalidSyntaxError("'time.sleep' is missing semi-colon!") 577 | else: 578 | raise InvalidModuleError("The 'time' module isn't imported or it doesn't exist!") 579 | 580 | elif "time.time(" in lines:#remember to NOT print. It only prints when you do print 581 | timeTIME()#this doesnt really do anything. 582 | 583 | elif "time.strftime(" in lines: 584 | timeSTRFTIME() 585 | if time_module == 1: 586 | wrd = "time.strftime(" 587 | 588 | 589 | elif "os.system(" in lines: 590 | osSYSTEM() 591 | 592 | elif "os.userinfo(" in lines: 593 | osUSERINFO() 594 | 595 | 596 | 597 | else: 598 | pass 599 | -------------------------------------------------------------------------------- /replitREADME.md: -------------------------------------------------------------------------------- 1 | # PyScript 2 | ##### The Unoffical and Offical Language coded by @JBYT27 3 | ###### View the `githubREADME.md` if you are viewing this on GITHUB. 4 | 5 | ## About the language 6 | #### PyScript is a PL *(programming language)*; `Python` combined with `JavaScript`. The syntax is a bit wobbled up, but it's basically `JavaScript` syntax and `Python` syntax mashed together. Like I said, it's wobbled up because they don't really fit, __`whitespace`__ *vs* __`brackets`__. For more info about the syntax, you can visit the docs (below). The language is meant to be a scripting language combined with a bit of `OOP`* Language as well. So it's mostly a `Scripting` Language, bit then again, it can be used as an `OOP` Language. 7 | 8 | ## Using the PL 9 | #### To use it, please either fork the repl, or fork the repo, either one works! :) 10 | 11 | ## Code of Conduct 12 | #### Please view the [`CODE_OF_CONDUCT`](https://github.com/PyScript-Language/PyScript-Compiler/blob/master/CODE_OF_CONDUCT.md) README! 13 | 14 | ## License 15 | #### This project is under the MIT License. For more, view the [`LICENSE`](https://github.com/PyScript-Language/PyScript-Compiler/blob/master/LICENSE)! 16 | 17 | ## PyScript Docs 18 | #### The docs are located in a separate repo/repl, but the link is [here](https://pyscript-docs.jbloves27.repl.co) 19 | > Note that it might take a long time to load as it is coded in reactjs. 20 | 21 | ##### * OOP stands for Object-Oriented-Programming -------------------------------------------------------------------------------- /static/index.js: -------------------------------------------------------------------------------- 1 | console.log("haiiiiiii") -------------------------------------------------------------------------------- /static/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0px 3 | } 4 | 5 | body { 6 | color: white; 7 | background-color: black; 8 | } 9 | -------------------------------------------------------------------------------- /templates/index.bhtml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PyScript-Language/PyScript-Compiler/f634656518d391a65fede8429d770cc72f2b4871/templates/index.bhtml -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PyScript Compiler 5 | 6 | 7 | 8 |

PyScript Compiler

9 | 10 | --------------------------------------------------------------------------------