Import 'warning' from lslparse instead of redefining. Cosmetic fixes.

This commit is contained in:
Sei Lisa 2014-07-27 18:05:11 +02:00
parent 26ab4f0382
commit f1656c41aa

View file

@ -1,11 +1,7 @@
# Convert a symbol table (with parse tree) back to a script. # Convert a symbol table (with parse tree) back to a script.
import lslfuncs import lslfuncs
from lslcommon import Key, Vector, Quaternion from lslcommon import Key, Vector, Quaternion
import sys from lslparse import warning
def warning(txt):
assert type(txt) == unicode
sys.stderr.write(txt + u'\n')
class outscript(object): class outscript(object):
@ -23,13 +19,17 @@ class outscript(object):
# Constants of type key can not be represented # Constants of type key can not be represented
#raise lslfuncs.ELSLTypeMismatch #raise lslfuncs.ELSLTypeMismatch
# Actually they can be the result of folding. # Actually they can be the result of folding.
# On second thought, if we report the error, the location info is lost. # On second thought, if we report the error, the location info
# So we will let the compiler deal with the error. # is lost. So we emit a warning instead, letting the compiler
# report the error in the generated source.
if self.globalmode and self.listmode: if self.globalmode and self.listmode:
warning(u'Illegal combo: Key type inside a global list') warning(u'Illegal combo: Key type inside a global list')
if self.listmode or not self.globalmode: if self.listmode or not self.globalmode:
pfx = '((key)' if self.globalmode:
sfx = ')' pfx = '(key)'
else:
pfx = '((key)'
sfx = ')'
return pfx + '"' + value.encode('utf8').replace('\\','\\\\') \ return pfx + '"' + value.encode('utf8').replace('\\','\\\\') \
.replace('"','\\"').replace('\n','\\n') + '"' + sfx .replace('"','\\"').replace('\n','\\n') + '"' + sfx
if tvalue == int: if tvalue == int:
@ -90,7 +90,7 @@ class outscript(object):
first = False first = False
self.indentlevel -= 1 self.indentlevel -= 1
return ret + self.dent() + self.indent + ']' return ret + self.dent() + self.indent + ']'
assert False, u'Unknown value type in Value2LSL: ' + repr(type(value)) assert False, u'Value of unknown type in Value2LSL: ' + repr(value)
def dent(self): def dent(self):
return self.indent * self.indentlevel return self.indent * self.indentlevel