Skip to content
Snippets Groups Projects
Commit 3e2cfeb7 authored by Berk Onat's avatar Berk Onat
Browse files

Added peekline feature to SimpleMatcher. The macthed line can be accessed with...

Added peekline feature to SimpleMatcher. The macthed line can be accessed with self.fInLine in parser
parent 6492edbb
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,7 @@ class PushbackLineFile(object): ...@@ -29,6 +29,7 @@ class PushbackLineFile(object):
def __init__(self, fIn, lines=tuple()): def __init__(self, fIn, lines=tuple()):
self.fIn = fIn self.fIn = fIn
self.fInLine = None
self.lines = list(lines) self.lines = list(lines)
self.lineNr = 0 self.lineNr = 0
self.name = fIn.name self.name = fIn.name
...@@ -40,10 +41,18 @@ class PushbackLineFile(object): ...@@ -40,10 +41,18 @@ class PushbackLineFile(object):
else: else:
res = self.fIn.readline() res = self.fIn.readline()
if res: if res:
self.fInLine = res
self.lineNr += 1 self.lineNr += 1
return res return res
def peekline(self):
pos = self.fIn.tell()
line = self.fIn.readline()
self.fIn.seek(pos)
return line
def pushbackLine(self, line): def pushbackLine(self, line):
self.fInLine = line
self.lines.append(line) self.lines.append(line)
self.lineNr -= 1 self.lineNr -= 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment