Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
omg the parser is done
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomlogo committed Sep 29, 2021
1 parent da4673b commit 7ec4d74
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions dinoux/dparser.py
Expand Up @@ -15,9 +15,31 @@ def split(string):
splitted code
"""
string = re.sub(r'⍝.*', '', string)
string = re.sub(r'([^0-9\. ])', r' \1 ', string, re.MULTILINE)
print(string)

return string.split()
n_str = ''

i = 0
while i < len(string):
char = string[i]
if char in "0123456789.":
while string[i] in "0123456789.":
n_str += string[i]
i += 1
n_str += ' '
elif char in "@→←λð":
n_str += char + ' '
i += 1
while string[i] in "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
n_str += string[i]
i += 1
n_str += ' '
else:
n_str += char + ' '
i += 1

print(n_str)
return n_str.split()

def tokenise(splitted):
"""
Expand Down Expand Up @@ -107,4 +129,12 @@ def parse(tokens):
return parsed

if __name__ == "__main__":
print(parse(tokenise(split('{}'))))
c="""λnth
≡›
⍨↾[
Ḥ,
]H
⍨,
‹⍨;
"""
print(parse(tokenise(split(c))))

0 comments on commit 7ec4d74

Please sign in to comment.