Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 108389e

Browse files
Update lexer.py
1 parent f6f2d35 commit 108389e

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

Main/lexer.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def __init__(self, text: str):
101101
"-": "SUBTRACT",
102102
"*": "MULTIPLY",
103103
"/": "DIVIDE",
104-
"%": "STRING_FORMATTER",
104+
"%": "MODULO",
105+
".": "CHILD",
106+
",": "SEPERATOR"
105107
}
106108
self.keywords = {
107109
"class": "CLASS",
@@ -125,7 +127,7 @@ def __init__(self, text: str):
125127
"dict", # and dictionary
126128
"bool",
127129
"dynamic",
128-
"None", # CONST, can't be changed
130+
"null", # CONST, can't be changed
129131
]
130132

131133
self.tokens = []
@@ -150,18 +152,7 @@ def validate_integer(string: str) -> bool:
150152
if string[0] == "-":
151153
string = string[1:]
152154
for char in string:
153-
valid = valid and char in [
154-
"0",
155-
"1",
156-
"2",
157-
"3",
158-
"4",
159-
"5",
160-
"6",
161-
"7",
162-
"8",
163-
"9",
164-
]
155+
valid = valid and char in DIGITS_AS_STRINGS
165156

166157
return valid
167158

@@ -189,7 +180,7 @@ def gettoken(
189180
else:
190181
raise LexerError("Unrecognized Pattern: '" + string + "'", line, column)
191182

192-
def repl(ar): # What's that?
183+
def replace_none(ar): # What's that?
193184
n = []
194185
for el in ar:
195186
if el is not None:
@@ -251,7 +242,7 @@ def repl(ar): # What's that?
251242
buffer += self.text[index]
252243

253244
index += 1
254-
self.tokens = repl(self.tokens)
245+
self.tokens = replace_none(self.tokens)
255246
return self.tokens
256247

257248

0 commit comments

Comments
 (0)