PythBrSc
Jump to navigation
Jump to search
PythBrSc (Python with Brackets and Semicolons) is a esolang by Mihai Popa.
After seeing that Python is a little hard to program and not being C-like enough, he made this!
Syntax
It's Python, but with brackets instead of indentation and semicolons at the end of the lines, just like in C, JavaScript, Java, etc... It's also for golfing.
Examples
Hello, world!
print("Hello, world!");
FizzBuzz
for num in range(1,101) { string = ""; if num % 3 == 0 { string = string + "Fizz"; } if num % 5 == 0 { string = string + "Buzz"; } if num % 5 != 0 and num % 3 != 0 { string = string + str(num); } print(string); }
Golfed
for n in range(1,101){if n%3{print(n if n%5 else"Buzz")}else{print("Fizz"+(""if n%5 else"Buzz"))}}
Transpiler
def PythBrSc2Py(text): new = "" lvindent = 0 instr = 0 for i in list(text): if i == "'": if instr == 0: instr = 1 if instr == 1: instr = 0 if i == '"': if instr == 0: instr = 2 if instr == 2: instr = 0 if instr: new += i continue if i == "{": lvindent += 1 new += ":\n" + lvindent * "\t" elif i == "}": lvindent -= 1 new += "\n" + lvindent * "\t" elif i == ";": new += "\n" + lvindent * "\t" elif i in " \r\n\t": try: n = new.split("\n")[-1] flag = True for j in list(n): if j not in " \r\n\t": flag = False if not flag: new += i except: pass else: new += i return new print(PythBrSc2Py('for n in range(1,101){if n%3{print(n if n%5 else"Buzz")}else{print("Fizz"+(""if n%5 else"Buzz"))}}'))
Replace print
with exec
to make it an interpreter! Made by islptng.