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
1 merge request!5Added peekline feature to SimpleMatcher.
......@@ -29,6 +29,7 @@ class PushbackLineFile(object):
def __init__(self, fIn, lines=tuple()):
self.fIn = fIn
self.fInLine = None
self.lines = list(lines)
self.lineNr = 0
self.name = fIn.name
......@@ -40,10 +41,18 @@ class PushbackLineFile(object):
else:
res = self.fIn.readline()
if res:
self.fInLine = res
self.lineNr += 1
return res
def peekline(self):
pos = self.fIn.tell()
line = self.fIn.readline()
self.fIn.seek(pos)
return line
def pushbackLine(self, line):
self.fInLine = line
self.lines.append(line)
self.lineNr -= 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment