-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterp.py
More file actions
67 lines (49 loc) · 2.05 KB
/
interp.py
File metadata and controls
67 lines (49 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import re
def formatdick(dick : str) -> int:
x = re.match("8(=*)D", dick)
if not x:
raise ValueError("Invalid dick supplied")
return len(x.group(1))
def ensureHand(hand) -> None:
if hand is not None:
return
else:
raise ValueError("Nothing in hand")
def runDicklang(filename : os.PathLike):
in_hand = None
vars_ = {}
with open(filename, 'r') as buffer:
for line in buffer:
keyword, *args = line.strip('\n').split(" ")
match keyword:
case "DICK": # assign var
vars_[args[0]] = formatdick(args[1])
case "GRAB": # set hand to var
try:
in_hand = [args[0], vars_[args[0]]]
except KeyError:
raise KeyError("No variable with that name found!")
case "RELEASE": # unset hand from var
if in_hand[0] == args[0]:
in_hand = None
else:
raise ValueError("What")
case "LONGDICK": # addition to hand
ensureHand(in_hand)
in_hand[1] += formatdick(args[0])
case "SMALLDICK": # subtraction from hand
ensureHand(in_hand)
in_hand[1] -= formatdick(args[0])
case "HUGEDICK": # multiply hand
ensureHand(in_hand)
in_hand[1] *= formatdick(args[0])
case "TINYDICK": # divide from hand
ensureHand(in_hand)
if args[0] == 0:
raise ZeroDivisionError("You're really enjoying yourself aren't you?")
in_hand[1] /= formatdick(args[0])
case "PEE": # print penis to term
print(f"8{'='*in_hand[1]}D")
case "WEE": # print ascii value of hand
print(chr(in_hand[1]))