|
|
|
@ -1,52 +1,13 @@
@@ -1,52 +1,13 @@
|
|
|
|
|
#!/usr/bin/env python3 |
|
|
|
|
# TurtleC - C-like with turtles (i think, not sure) |
|
|
|
|
# |
|
|
|
|
# For the turtle-themed Esojam |
|
|
|
|
# This programming langauge has been designed and implemented for the |
|
|
|
|
# Turtle-themed esojam hosted by Truttle1 (a very cool YouTuber who |
|
|
|
|
# makes educational videos about esolangs and retrolangs). |
|
|
|
|
# |
|
|
|
|
# Integers |
|
|
|
|
# turtle() = 1 |
|
|
|
|
# turtle(turtle()) = 2 |
|
|
|
|
# turtle(turtle(turtle(turtle()))) = 4 |
|
|
|
|
# noTurtle() = 0 |
|
|
|
|
# Obfuscate will be proud of me :> |
|
|
|
|
# |
|
|
|
|
# Arith |
|
|
|
|
# Woa(a, b) = a + b |
|
|
|
|
# Woa(turtle(turtle()), turtle(turtle(turtle()))) = |
|
|
|
|
# turtle(turtle(turtle(turtle(turtle()))))) |
|
|
|
|
# WOa(a, b) = a - b |
|
|
|
|
# WoA(a, b) = a * b |
|
|
|
|
# WOA(a, b) = a / b |
|
|
|
|
# |
|
|
|
|
# Wow(a, b) = a == b |
|
|
|
|
# WoW(a, b) = a < b |
|
|
|
|
# |
|
|
|
|
# Control Flow |
|
|
|
|
# Mu a { ... } # if (a>0) { ... } |
|
|
|
|
# mU a { ... } # if (a==0) { ... } |
|
|
|
|
# MU a { ... } # while (a) { ... } |
|
|
|
|
# |
|
|
|
|
# Functions and Variables |
|
|
|
|
# |
|
|
|
|
# tUrtle = turtle() # Assigns 1 to tUrtle |
|
|
|
|
# mu Tturtle(tturtle, ttturtle) { ... } # Function named Tturtle |
|
|
|
|
# Function will return the last instruction |
|
|
|
|
# |
|
|
|
|
# I/O |
|
|
|
|
# wOa(a, b, c, ...) # Output a stream of integers as ASCII chars |
|
|
|
|
# wOA(a, b, c, ...) # Output a stream of integers as integers |
|
|
|
|
# woA() # Returns a byte from stdin |
|
|
|
|
# |
|
|
|
|
# Variable notation standards |
|
|
|
|
# Variables are case-sensitive and must be named turtle. You can |
|
|
|
|
# combine uppercase and lowercase to have different variables |
|
|
|
|
# You can also have as much T as you want in the beginning of the name |
|
|
|
|
# |
|
|
|
|
# ttturtle # Valid name |
|
|
|
|
# Turtle # Valid name |
|
|
|
|
# notATurtle # Not a valid name |
|
|
|
|
# TtUrtlE # Valid name |
|
|
|
|
# |
|
|
|
|
import sys, re, time |
|
|
|
|
import sys, re, time, random |
|
|
|
|
|
|
|
|
|
blocks = ["Mu", "mU", "MU", "mu"] |
|
|
|
|
int_funcs = ["turtle", "noTurtle"] |
|
|
|
@ -66,6 +27,23 @@ def argv2turtle(arr):
@@ -66,6 +27,23 @@ def argv2turtle(arr):
|
|
|
|
|
|
|
|
|
|
### BUILT-INS ### |
|
|
|
|
|
|
|
|
|
# The best way to find out what it does is to run the function |
|
|
|
|
# (see programs/truttle1.trt) |
|
|
|
|
def _builtin_Truttle1(env, *args): |
|
|
|
|
_xor_endec=lambda s,p:''.join((chr(ord(c)^ord(p[x%len(p)]))for x,c in enumerate(s))) |
|
|
|
|
quotes = ['\x1c\x17\x0cT\x13\x19\x00BSI\x04H\x02\x1bP', |
|
|
|
|
'\x00\x1a\x1c\x07T\n\x10_C\x1d\x1aO\rO\x06\x1ft\x17\x05\x1d' + \ |
|
|
|
|
'\x17L\x07TC\x08\x06S\x06AAB', |
|
|
|
|
'=\x06U\x10\x1b\t\x16\x1f\x0eG]', |
|
|
|
|
'5\x10\x06\x1b\x18\x19\x11TL\x10]\x0eMAABz', |
|
|
|
|
'\x1a<:;;8-yi\'4g$((+\x135233+"v\x01HR\x01BN'] |
|
|
|
|
pswd = "Truttle1 is cool" |
|
|
|
|
for quote in quotes: |
|
|
|
|
print(_xor_endec(quote, pswd)) |
|
|
|
|
time.sleep(2) |
|
|
|
|
|
|
|
|
|
return TurtleInteger(random.randint(0, 100)) |
|
|
|
|
|
|
|
|
|
def _builtin_set_value(env, k, v): |
|
|
|
|
k = k.name |
|
|
|
|
assert is_turtle(k), "That variable name is not turtle enough. FIX IT." |
|
|
|
@ -176,7 +154,10 @@ default_env = {
@@ -176,7 +154,10 @@ default_env = {
|
|
|
|
|
"TurtleASet": _builtin_TurtleSet, |
|
|
|
|
"TurtleAGet": _builtin_TurtleGet, |
|
|
|
|
"TurtleARead": _builtin_TurtleRead, |
|
|
|
|
"TurtleALength": _builtin_TurtleLength |
|
|
|
|
"TurtleALength": _builtin_TurtleLength, |
|
|
|
|
|
|
|
|
|
# ????????????? |
|
|
|
|
"Truttle1": _builtin_Truttle1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
### ERROR ### |
|
|
|
|