Browse Source

TurtleC v1.1

master
Matthilde 1 year ago
parent
commit
ad00f80e88
  1. 63
      README.txt
  2. 1
      programs/truttle1.trt
  3. 71
      turtlec.py

63
README.txt

@ -3,6 +3,26 @@ @@ -3,6 +3,26 @@
| | | | | _| _| | -__| ---|
|___| |_____|__| |____|__|_____|______|
TABLE OF CONTENTS
-----------------
* Introduction
* Compatibility
* Files
* The Interpreter
* How To Program In TurtleC
* Integers
* Arithmetics
* Control Flow
* Variable and Function Assignement
* Array
* I/O
* Comments
* ??????????
* Examples
* Purpose?
* Licensing
INTRODUCTION
------------
@ -115,6 +135,17 @@ them all), you will get the grip quite easily. @@ -115,6 +135,17 @@ them all), you will get the grip quite easily.
# ...
}
The return value of the last instruction ran in the function will be
what the function returns.
Array
-----
TurtleArray(length) Creates an array of <length> size
TurtleASet(arr, i, v) arr[i] = v
TurtleAGet(arr, i) Returns arr[i]
TurtleALength(arr) Returns the length of an array
I/O
---
@ -122,14 +153,44 @@ them all), you will get the grip quite easily. @@ -122,14 +153,44 @@ them all), you will get the grip quite easily.
wOA(a, ...) Output integers as integers
woA() Reads a byte from input and returns an integer
TurtleARead(filename)
Reads from a file, the filename is an array of integers where each
integer represents an ASCII value to represent a string.
The function will return an array of integers which is the content
of the file.
Comments
--------
Like in Python, type a '#' then write your comment. The text after
# will be ignored.
See examples in the programs
?????????
---------
Truttle1(); ???????????????????????? idk what it does. the source code
of this function looks kinda obfuscated.
Examples
--------
There are plenty of examples and tests in the programs folder. Even
thought all features has been tested, I do not guarantee the
interpreter is stable.
The programming language is now turing complete since I have added
arrays. I have wrote a brainfuck interpreter in TurtleC. (I recommend
to run it using the debug interpreter cus Turtle is very very slow).
PURPOSE?
--------
There aren't really any purpose for this language except being an entry
of Truttle1's turtle-themed esolang jam. However, one of the goals of
this programming language is that programs looks obfuscated at first
glance and must be, well, not difficult to program but to get easily
lost because TURTLES EVERYWHERE
LICENSING
---------

1
programs/truttle1.trt

@ -0,0 +1 @@ @@ -0,0 +1 @@
Truttle1();

71
turtlec.py

@ -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 ###

Loading…
Cancel
Save