mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Use frozenset for keywords; allow Pop.
Rather than using tuples for set belonging, use a frozen set. That eliminates the need to separate them by lengths. Also, 'Pop' is not a reserved word. It's perfectly valid as a possible substitution identifier, so allow it. If used, it will go to the used words anyway and thus will be skipped by the sequential name generator.
This commit is contained in:
parent
9b09c29eea
commit
7659eb1654
1 changed files with 5 additions and 3 deletions
|
@ -29,8 +29,10 @@ class renamer(object):
|
|||
CharSet1 = '_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
||||
CharSet2 = '0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
||||
# TODO: Derive these from builtins.txt somehow.
|
||||
KwByLen = ((), (), ('do', 'if', 'PI'), ('for', 'key', 'EOF', 'Pop'),
|
||||
('jump', 'else', 'list', 'TRUE', 'LOOP', 'case'))
|
||||
Kws = (frozenset({'do', 'if', 'PI',
|
||||
'for', 'key', 'EOF',
|
||||
'jump', 'else', 'list', 'TRUE', 'LOOP', 'case'
|
||||
}))
|
||||
def GetNextShortest(self):
|
||||
"""Generate the next shortest possible identifier"""
|
||||
while True:
|
||||
|
@ -48,7 +50,7 @@ class renamer(object):
|
|||
else:
|
||||
self.WordRestOfChars.append(0)
|
||||
|
||||
if ret not in self.KwByLen[len(ret)] and ret not in self.UsedNames:
|
||||
if ret not in self.Kws and ret not in self.UsedNames:
|
||||
return ret
|
||||
|
||||
def ShrinkNames(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue