Skip to content
Snippets Groups Projects
Commit 35f66707 authored by Chris's avatar Chris
Browse files

Position zu Token hinzugefügt

parent 1db3efae
Branches
No related tags found
1 merge request!1Master
......@@ -2,9 +2,10 @@ import re
class Token:
def __init__(self, key, value):
def __init__(self, key, value, position):
self.k = key
self.v = value
self.p = position
class Lexer:
......@@ -20,7 +21,7 @@ class Lexer:
for pattern, value in self.regex_to_token:
match = pattern.match(self.program, self.current_position)
if match:
next_token = Token(value, match.group())
next_token = Token(value, match.group(), self.current_position)
new_position = match.span()[1]
break
if self.current_position == new_position:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment