[qfmap] Update script.py from io_object_mu

While not necessary for qf (at this stage), this brings in support for
optionally not parsing strings and better utf-8 and wide char handling.
This commit is contained in:
Bill Currie 2020-07-17 20:11:44 +09:00
parent 900728169e
commit 3413947e0c

View file

@ -25,10 +25,15 @@ class ScriptError(Exception):
self.line = line
class Script:
def __init__(self, filename, text, single="{}()':"):
def __init__(self, filename, text, single="{}()':", quotes=True):
self.filename = filename
if text[0:3] == "\xef\xbb\xbf":
text = text[3:]
elif text[0] == u"\ufeff":
text = text[1:]
self.text = text
self.single = single
self.quotes = quotes
self.pos = 0
self.line = 1
self.unget = False
@ -87,7 +92,7 @@ class Script:
if not crossline:
self.error("line is incomplete")
return None
if self.text[self.pos] == "\"":
if self.quotes and self.text[self.pos] == "\"":
self.pos += 1
start = self.pos
if self.text[self.pos] == len(self.text):