Skip to content

Commit 3f1ea38

Browse files
author
Derp McDerpson
authored
Added support for ASCII inputs
1 parent 348c56e commit 3f1ea38

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

logicode.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
rWhitespace = re.compile(r"[ \t]+", re.M)
1515
rCommandSeparator = re.compile(r"[\r\n;]+", re.M)
1616
rBits = re.compile(r"[01]+")
17-
rName = re.compile(r"(?!\binp\b|\b__scope__\b)[a-zA-Z0-9_$]+")
17+
rName = re.compile(r"(?!\b[ab]inp\b|\b__scope__\b)[a-zA-Z0-9_$]+")
1818
rRandom = re.compile(r"\?")
19-
rInput = re.compile(r"\binp\b")
19+
rInput = re.compile(r"\b[ab]inp\b")
2020
rScope = re.compile(r"\b__scope__\b")
2121
rInfix = re.compile(r"[&|]")
2222
rPrefix = re.compile(r"[!~@]")
@@ -74,7 +74,7 @@ def Random(result):
7474

7575

7676
def Input(result):
77-
return lambda scope: GetInput(scope)
77+
return lambda scope: GetInput(scope, result[0][0])
7878

7979

8080
def ScopeTransform(result):
@@ -175,9 +175,18 @@ def Out(result):
175175
return lambda scope: Print(result[1](scope))
176176

177177

178-
def GetInput(scope):
178+
def GetInput(scope, inputarg):
179179
if not len(scope["input"]):
180-
scope["input"] = [list(map(int, filter(lambda c: c == "0" or c == "1", raw_input("Input: "))))]
180+
if inputarg == "a":
181+
temp = list(x for x in raw_input("Input: ") if ord(x) < 256)
182+
for a in range(len(temp)):
183+
temp[a] = bin(ord(temp[a]))[2:]
184+
while len(temp[a]) < 8:
185+
temp[a] = "0" + temp[a]
186+
temp = "".join(temp)
187+
scope["input"] = [[int(x) for x in temp]]
188+
if inputarg == "b":
189+
scope["input"] = [list(map(int, filter(lambda c: c == "0" or c == "1", raw_input("Input: "))))]
181190
return scope["input"].pop()
182191

183192

0 commit comments

Comments
 (0)