mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
Add a getLine method to Script.
It returns the rest of the line (minus // style comments) as the token. I needed it in another project but this is my central repository for script.py.
This commit is contained in:
parent
eeaf2bc43f
commit
6996e7295a
1 changed files with 18 additions and 0 deletions
|
@ -61,6 +61,24 @@ class Script:
|
|||
continue
|
||||
return True
|
||||
return False
|
||||
def getLine(self):
|
||||
start = self.pos
|
||||
end = start
|
||||
while self.pos < len(self.text):
|
||||
if self.text[self.pos] == "\n":
|
||||
self.line += 1
|
||||
self.pos += 1
|
||||
break
|
||||
if self.text[self.pos:self.pos + 2] == "//":
|
||||
break
|
||||
self.pos += 1
|
||||
end = self.pos
|
||||
if self.unget:
|
||||
self.unget = False
|
||||
self.token = self.token + self.text[start:end]
|
||||
else:
|
||||
self.token = self.text[start:end]
|
||||
return self.pos < len(self.text)
|
||||
def getToken(self, crossline=False):
|
||||
if self.unget:
|
||||
self.unget = False
|
||||
|
|
Loading…
Reference in a new issue