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

Position zu Token hinzugefügt

parent 1db3efae
No related branches found
No related tags found
1 merge request!1Master
...@@ -2,9 +2,10 @@ import re ...@@ -2,9 +2,10 @@ import re
class Token: class Token:
def __init__(self, key, value): def __init__(self, key, value, position):
self.k = key self.k = key
self.v = value self.v = value
self.p = position
class Lexer: class Lexer:
...@@ -20,7 +21,7 @@ class Lexer: ...@@ -20,7 +21,7 @@ class Lexer:
for pattern, value in self.regex_to_token: for pattern, value in self.regex_to_token:
match = pattern.match(self.program, self.current_position) match = pattern.match(self.program, self.current_position)
if match: if match:
next_token = Token(value, match.group()) next_token = Token(value, match.group(), self.current_position)
new_position = match.span()[1] new_position = match.span()[1]
break break
if self.current_position == new_position: 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