Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
starter
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrusch committed Jun 28, 2024
1 parent 7d7d9d8 commit 9450a5d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions in.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
S'%4}).$%8
43 changes: 43 additions & 0 deletions index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from sys import argv

OFFSET = 33
SPC = " "
NL = "\n"
ALPHA = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"
"\"#$%&'()*+,-./:;<=>?@[\]^_`|~") + [SPC, NL]


def read_file(fn):
with open(fn) as fp:
return fp.read()


def parse(s):
print(indicator(s))
return s


def decode_str(s):
chars = [c for c in list(s)]
return "".join([ALPHA[(ord(c) - OFFSET)] for c in chars])


def encode_str(s):
chars = [c for c in list(s)]
return "".join([chr(ALPHA.index(c) + OFFSET) for c in chars])


def indicator(s):
fst = s[0]
if fst == 'T': return "true"
if fst == 'F': return "false"
if fst == 'I': return "int"
if fst == 'S': return decode_str(s[1:])
if fst == 'U': return 'unary'
if fst == 'B': return 'binary'
if fst == '?': return 'if'
if fst == 'L': return 'lambda abs'


if __name__ == '__main__':
print(parse(read_file(argv[1])))

0 comments on commit 9450a5d

Please sign in to comment.