mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Comment-at-eol cleanup
Ensure every comment has a double space after the code.
This commit is contained in:
parent
f3c87299c2
commit
d890f0b5fa
1 changed files with 46 additions and 46 deletions
|
@ -234,12 +234,12 @@ class parser(object):
|
||||||
|
|
||||||
def PushScope(self):
|
def PushScope(self):
|
||||||
"""Create a new symbol table / scope level"""
|
"""Create a new symbol table / scope level"""
|
||||||
self.symtab.append({-1:self.scopeindex}) # Add parent pointer
|
self.symtab.append({-1:self.scopeindex}) # Add parent pointer
|
||||||
self.scopeindex = len(self.symtab)-1
|
self.scopeindex = len(self.symtab)-1
|
||||||
|
|
||||||
def PopScope(self):
|
def PopScope(self):
|
||||||
"""Return to the previous scope level"""
|
"""Return to the previous scope level"""
|
||||||
self.scopeindex = self.symtab[self.scopeindex][-1] # -1 is a dict key, not an index
|
self.scopeindex = self.symtab[self.scopeindex][-1] # -1 is a dict key, not an index
|
||||||
assert self.scopeindex is not None, 'Unexpected internal error'
|
assert self.scopeindex is not None, 'Unexpected internal error'
|
||||||
|
|
||||||
def AddSymbol(self, kind, scope, name, **values):
|
def AddSymbol(self, kind, scope, name, **values):
|
||||||
|
@ -273,7 +273,7 @@ class parser(object):
|
||||||
symtab = self.symtab[scopelevel]
|
symtab = self.symtab[scopelevel]
|
||||||
if symbol in symtab and (not MustBeLabel or symtab[symbol]['Kind'] == 'l'):
|
if symbol in symtab and (not MustBeLabel or symtab[symbol]['Kind'] == 'l'):
|
||||||
return symtab[symbol]
|
return symtab[symbol]
|
||||||
scopelevel = symtab[-1] # -1 is a dict key, not an index
|
scopelevel = symtab[-1] # -1 is a dict key, not an index
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# No labels or states allowed here (but functions are)
|
# No labels or states allowed here (but functions are)
|
||||||
|
@ -282,7 +282,7 @@ class parser(object):
|
||||||
if scopelevel is None:
|
if scopelevel is None:
|
||||||
# unspecified scope level means to look in the current scope
|
# unspecified scope level means to look in the current scope
|
||||||
scopelevel = self.scopeindex
|
scopelevel = self.scopeindex
|
||||||
while scopelevel: # Loop over all local scopes
|
while scopelevel: # Loop over all local scopes
|
||||||
symtab = self.symtab[scopelevel]
|
symtab = self.symtab[scopelevel]
|
||||||
if symbol in symtab:
|
if symbol in symtab:
|
||||||
# This can't happen, as functions can't be local
|
# This can't happen, as functions can't be local
|
||||||
|
@ -291,11 +291,11 @@ class parser(object):
|
||||||
return symtab[symbol]
|
return symtab[symbol]
|
||||||
scopelevel = symtab[-1]
|
scopelevel = symtab[-1]
|
||||||
try:
|
try:
|
||||||
return self.symtab[0][symbol] # Quick guess
|
return self.symtab[0][symbol] # Quick guess
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if self.disallowglobalvars and symbol not in self.symtab[0] \
|
if self.disallowglobalvars and symbol not in self.symtab[0] \
|
||||||
or symbol not in self.globals:
|
or symbol not in self.globals:
|
||||||
return None # Disallow forwards in global var mode
|
return None # Disallow forwards in global var mode
|
||||||
return self.globals[symbol]
|
return self.globals[symbol]
|
||||||
|
|
||||||
def ValidateField(self, typ, field):
|
def ValidateField(self, typ, field):
|
||||||
|
@ -326,7 +326,7 @@ class parser(object):
|
||||||
def ceof(self):
|
def ceof(self):
|
||||||
"""Check for normal EOF"""
|
"""Check for normal EOF"""
|
||||||
if self.pos >= self.length:
|
if self.pos >= self.length:
|
||||||
raise EInternal() # force GetToken to return EOF
|
raise EInternal() # force GetToken to return EOF
|
||||||
|
|
||||||
def SetOpt(self, option, value):
|
def SetOpt(self, option, value):
|
||||||
# See parse() for meaning of options.
|
# See parse() for meaning of options.
|
||||||
|
@ -477,7 +477,7 @@ class parser(object):
|
||||||
self.ceof()
|
self.ceof()
|
||||||
while self.script[self.pos] != '\n':
|
while self.script[self.pos] != '\n':
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
self.ceof() # A preprocessor command at EOF is not unexpected EOF.
|
self.ceof() # A preprocessor command at EOF is not unexpected EOF.
|
||||||
|
|
||||||
self.ProcessDirective(self.script[self.errorpos:self.pos])
|
self.ProcessDirective(self.script[self.errorpos:self.pos])
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ class parser(object):
|
||||||
self.ceof()
|
self.ceof()
|
||||||
while self.script[self.pos] != '\n':
|
while self.script[self.pos] != '\n':
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
self.ceof() # A single-line comment at EOF is not unexpected EOF.
|
self.ceof() # A single-line comment at EOF is not unexpected EOF.
|
||||||
|
|
||||||
self.linestart = True
|
self.linestart = True
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
|
@ -503,7 +503,7 @@ class parser(object):
|
||||||
self.pos += 2
|
self.pos += 2
|
||||||
while self.script[self.pos-1:self.pos+1] != '*/':
|
while self.script[self.pos-1:self.pos+1] != '*/':
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
self.ueof() # An unterminated multiline comment *is* unexpected EOF.
|
self.ueof() # An unterminated multiline comment *is* unexpected EOF.
|
||||||
|
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
self.ceof()
|
self.ceof()
|
||||||
|
@ -521,8 +521,8 @@ class parser(object):
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
strliteral = '"'
|
strliteral = '"'
|
||||||
|
|
||||||
savepos = self.pos # we may need to backtrack
|
savepos = self.pos # we may need to backtrack
|
||||||
is_string = True # by default
|
is_string = True # by default
|
||||||
|
|
||||||
while self.script[self.pos:self.pos+1] != '"':
|
while self.script[self.pos:self.pos+1] != '"':
|
||||||
# per the grammar, on EOF, it's not considered a string
|
# per the grammar, on EOF, it's not considered a string
|
||||||
|
@ -568,7 +568,7 @@ class parser(object):
|
||||||
return (ident.upper(),)
|
return (ident.upper(),)
|
||||||
if ident in types:
|
if ident in types:
|
||||||
if ident == 'quaternion':
|
if ident == 'quaternion':
|
||||||
ident = 'rotation' # Normalize types
|
ident = 'rotation' # Normalize types
|
||||||
return ('TYPE',ident)
|
return ('TYPE',ident)
|
||||||
if ident in self.events:
|
if ident in self.events:
|
||||||
return ('EVENT_NAME',ident)
|
return ('EVENT_NAME',ident)
|
||||||
|
@ -603,7 +603,7 @@ class parser(object):
|
||||||
number = ''
|
number = ''
|
||||||
|
|
||||||
while ishex(self.script[self.pos:self.pos+1]):
|
while ishex(self.script[self.pos:self.pos+1]):
|
||||||
if len(number) < 9: # don't let it grow more than necessary
|
if len(number) < 9: # don't let it grow more than necessary
|
||||||
number += self.script[self.pos]
|
number += self.script[self.pos]
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
if number == '':
|
if number == '':
|
||||||
|
@ -629,10 +629,10 @@ class parser(object):
|
||||||
|
|
||||||
# At this point, number contains as many digits as there are before the dot,
|
# At this point, number contains as many digits as there are before the dot,
|
||||||
# the dot if present, and as many digits as there are after the dot.
|
# the dot if present, and as many digits as there are after the dot.
|
||||||
if number != '.': # A dot alone can't be a number so we rule it out here.
|
if number != '.': # A dot alone can't be a number so we rule it out here.
|
||||||
exp = ''
|
exp = ''
|
||||||
if self.script[self.pos:self.pos+1] in ('e','E'):
|
if self.script[self.pos:self.pos+1] in ('e','E'):
|
||||||
epos = self.pos # Temporary position tracker, made permanent only if the match succeeds
|
epos = self.pos # Temporary position tracker, made permanent only if the match succeeds
|
||||||
exp = self.script[epos]
|
exp = self.script[epos]
|
||||||
epos += 1
|
epos += 1
|
||||||
if self.script[epos:epos+1] in ('+','-'):
|
if self.script[epos:epos+1] in ('+','-'):
|
||||||
|
@ -645,11 +645,11 @@ class parser(object):
|
||||||
while isdigit(self.script[epos:epos+1]):
|
while isdigit(self.script[epos:epos+1]):
|
||||||
exp += self.script[epos]
|
exp += self.script[epos]
|
||||||
epos += 1
|
epos += 1
|
||||||
self.pos = epos # "Commit" the new position
|
self.pos = epos # "Commit" the new position
|
||||||
else:
|
else:
|
||||||
exp = '' # No cigar. Rollback and backtrack. Invalidate exp.
|
exp = '' # No cigar. Rollback and backtrack. Invalidate exp.
|
||||||
|
|
||||||
if exp != '' or '.' in number: # Float
|
if exp != '' or '.' in number: # Float
|
||||||
if '.' in number:
|
if '.' in number:
|
||||||
# Eat the 'F' if present
|
# Eat the 'F' if present
|
||||||
if self.script[self.pos:self.pos+1] in ('f','F'):
|
if self.script[self.pos:self.pos+1] in ('f','F'):
|
||||||
|
@ -685,7 +685,7 @@ class parser(object):
|
||||||
# continue
|
# continue
|
||||||
|
|
||||||
except EInternal:
|
except EInternal:
|
||||||
pass # clear the exception and fall through
|
pass # clear the exception and fall through
|
||||||
|
|
||||||
return ('EOF',)
|
return ('EOF',)
|
||||||
|
|
||||||
|
@ -745,14 +745,14 @@ class parser(object):
|
||||||
|
|
||||||
self.expect(',')
|
self.expect(',')
|
||||||
self.NextToken()
|
self.NextToken()
|
||||||
except EParse: # The errors can be varied, e.g. <0,0,0>-v; raises EParseTypeMismatch
|
except EParse: # The errors can be varied, e.g. <0,0,0>-v; raises EParseTypeMismatch
|
||||||
# Backtrack
|
# Backtrack
|
||||||
self.pos = pos
|
self.pos = pos
|
||||||
self.errorpos = errorpos
|
self.errorpos = errorpos
|
||||||
self.tok = tok
|
self.tok = tok
|
||||||
|
|
||||||
# OK, here we are.
|
# OK, here we are.
|
||||||
inequality = self.Parse_shift() # shift is the descendant of inequality
|
inequality = self.Parse_shift() # shift is the descendant of inequality
|
||||||
while self.tok[0] in ('<', '<=', '>=', '>'):
|
while self.tok[0] in ('<', '<=', '>=', '>'):
|
||||||
op = self.tok[0]
|
op = self.tok[0]
|
||||||
self.NextToken()
|
self.NextToken()
|
||||||
|
@ -982,7 +982,7 @@ class parser(object):
|
||||||
self.AddSymbol('v', paramscope, 'L', Type='list')
|
self.AddSymbol('v', paramscope, 'L', Type='list')
|
||||||
self.AddSymbol('v', paramscope, 'i', Type='integer')
|
self.AddSymbol('v', paramscope, 'i', Type='integer')
|
||||||
self.AddSymbol('v', paramscope, 'v', Type='list')
|
self.AddSymbol('v', paramscope, 'v', Type='list')
|
||||||
#self.PushScope() # no locals
|
#self.PushScope() # no locals
|
||||||
|
|
||||||
# Add body (apologies for the wall of text)
|
# Add body (apologies for the wall of text)
|
||||||
# Generated from this source:
|
# Generated from this source:
|
||||||
|
@ -996,7 +996,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
'''
|
'''
|
||||||
self.tree[self.usedspots] = {'ch': [{'ch': [{'ch': [{'ch': [{'ch': [{'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'L'}], 'nt': 'FNCALL', 't': 'integer', 'name': 'llGetListLength'}, {'scope': paramscope, 'nt': 'IDENT', 't': 'integer', 'name': 'i'}], 'nt': '<', 't': 'integer'}, {'ch': [{'ch': [{'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'L'}, {'ch': [{'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'L'}, {'nt': 'CONST', 't': 'integer', 'value': 0}], 'nt': '+', 't': 'list'}], 'nt': '=', 't': 'list'}], 'nt': 'EXPR', 't': 'list'}], 'nt': 'WHILE', 't': None}, {'ch': [{'ch': [{'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'L'}, {'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'v'}, {'scope': paramscope, 'nt': 'IDENT', 't': 'integer', 'name': 'i'}, {'scope': paramscope, 'nt': 'IDENT', 't': 'integer', 'name': 'i'}], 'nt': 'FNCALL', 't': 'list', 'name': 'llListReplaceList'}], 'nt': 'RETURN', 't': None, 'LIR': True}], 'nt': '{}', 't': None, 'LIR': True}], 't': 'list', 'pnames': params[1], 'scope': 0, 'pscope': paramscope, 'nt': 'FNDEF', 'ptypes': params[0], 'name': 'lazy_list_set'}
|
self.tree[self.usedspots] = {'ch': [{'ch': [{'ch': [{'ch': [{'ch': [{'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'L'}], 'nt': 'FNCALL', 't': 'integer', 'name': 'llGetListLength'}, {'scope': paramscope, 'nt': 'IDENT', 't': 'integer', 'name': 'i'}], 'nt': '<', 't': 'integer'}, {'ch': [{'ch': [{'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'L'}, {'ch': [{'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'L'}, {'nt': 'CONST', 't': 'integer', 'value': 0}], 'nt': '+', 't': 'list'}], 'nt': '=', 't': 'list'}], 'nt': 'EXPR', 't': 'list'}], 'nt': 'WHILE', 't': None}, {'ch': [{'ch': [{'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'L'}, {'scope': paramscope, 'nt': 'IDENT', 't': 'list', 'name': 'v'}, {'scope': paramscope, 'nt': 'IDENT', 't': 'integer', 'name': 'i'}, {'scope': paramscope, 'nt': 'IDENT', 't': 'integer', 'name': 'i'}], 'nt': 'FNCALL', 't': 'list', 'name': 'llListReplaceList'}], 'nt': 'RETURN', 't': None, 'LIR': True}], 'nt': '{}', 't': None, 'LIR': True}], 't': 'list', 'pnames': params[1], 'scope': 0, 'pscope': paramscope, 'nt': 'FNDEF', 'ptypes': params[0], 'name': 'lazy_list_set'}
|
||||||
self.usedspots += 1
|
self.usedspots += 1
|
||||||
#self.PopScope() # no locals
|
#self.PopScope() # no locals
|
||||||
self.PopScope()
|
self.PopScope()
|
||||||
|
|
||||||
if expr['t'] is None:
|
if expr['t'] is None:
|
||||||
|
@ -1513,7 +1513,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
expr = self.autocastcheck(expr, expected_types[idx]);
|
expr = self.autocastcheck(expr, expected_types[idx]);
|
||||||
except EParseTypeMismatch:
|
except EParseTypeMismatch:
|
||||||
raise EParseFunctionMismatch(self)
|
raise EParseFunctionMismatch(self)
|
||||||
elif expected_types is False: # don't accept void expressions
|
elif expected_types is False: # don't accept void expressions
|
||||||
if expr['t'] not in types:
|
if expr['t'] not in types:
|
||||||
raise EParseTypeMismatch(self)
|
raise EParseTypeMismatch(self)
|
||||||
idx += 1
|
idx += 1
|
||||||
|
@ -1855,7 +1855,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
# Since label scope rules prevent us from being able to jump inside
|
# Since label scope rules prevent us from being able to jump inside
|
||||||
# a nested block, only one nesting level is considered.
|
# a nested block, only one nesting level is considered.
|
||||||
assert blk['nt'] == '{}'
|
assert blk['nt'] == '{}'
|
||||||
blk = blk['ch'] # Disregard the '{}' - we'll add it back later
|
blk = blk['ch'] # Disregard the '{}' - we'll add it back later
|
||||||
for idx in xrange(len(blk)):
|
for idx in xrange(len(blk)):
|
||||||
if blk[idx]['nt'] == 'CASE':
|
if blk[idx]['nt'] == 'CASE':
|
||||||
lbl = self.GenerateLabel()
|
lbl = self.GenerateLabel()
|
||||||
|
@ -1994,8 +1994,8 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
# while (cond) while (cond) while (cond) continue 3;
|
# while (cond) while (cond) while (cond) continue 3;
|
||||||
# Transform to while(cond) while(cond) while(cond) break 2;
|
# Transform to while(cond) while(cond) while(cond) break 2;
|
||||||
# which is equivalent since there are no {}.
|
# which is equivalent since there are no {}.
|
||||||
n += 1 # e.g. -3 -> -2
|
n += 1 # e.g. -3 -> -2
|
||||||
self.breakstack[n][2] = True # mark the break as used
|
self.breakstack[n][2] = True # mark the break as used
|
||||||
return {'nt':'JUMP', 't':None, 'name':self.breakstack[n][0],
|
return {'nt':'JUMP', 't':None, 'name':self.breakstack[n][0],
|
||||||
'scope':self.breakstack[n][1]}
|
'scope':self.breakstack[n][1]}
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -2046,7 +2046,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
|
|
||||||
# Kludge to find the scope of the break (for switch) /
|
# Kludge to find the scope of the break (for switch) /
|
||||||
# continue (for loops) labels.
|
# continue (for loops) labels.
|
||||||
if self.breakstack: # non-empty iff inside loop or switch
|
if self.breakstack: # non-empty iff inside loop or switch
|
||||||
if InsideSwitch and self.breakstack[-1][1] is None:
|
if InsideSwitch and self.breakstack[-1][1] is None:
|
||||||
self.breakstack[-1][1] = self.scopeindex
|
self.breakstack[-1][1] = self.scopeindex
|
||||||
if InsideLoop and self.continuestack[-1][1] is None:
|
if InsideLoop and self.continuestack[-1][1] is None:
|
||||||
|
@ -2088,7 +2088,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
"""
|
"""
|
||||||
tok = self.tok
|
tok = self.tok
|
||||||
self.NextToken()
|
self.NextToken()
|
||||||
if tok[0] in ('TRUE', 'FALSE'): # TRUE and FALSE don't admit sign in globals
|
if tok[0] in ('TRUE', 'FALSE'): # TRUE and FALSE don't admit sign in globals
|
||||||
return {'nt':'CONST', 't':'integer', 'value':int(tok[0]=='TRUE')}
|
return {'nt':'CONST', 't':'integer', 'value':int(tok[0]=='TRUE')}
|
||||||
if tok[0] in ('STRING_VALUE', 'KEY_VALUE', 'VECTOR_VALUE', 'ROTATION_VALUE', 'LIST_VALUE'):
|
if tok[0] in ('STRING_VALUE', 'KEY_VALUE', 'VECTOR_VALUE', 'ROTATION_VALUE', 'LIST_VALUE'):
|
||||||
val = tok[1]
|
val = tok[1]
|
||||||
|
@ -2193,7 +2193,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
events: event | events event
|
events: event | events event
|
||||||
event: EVENT_NAME '(' optional_parameter_list ')' code_block
|
event: EVENT_NAME '(' optional_parameter_list ')' code_block
|
||||||
"""
|
"""
|
||||||
self.expect('EVENT_NAME') # mandatory
|
self.expect('EVENT_NAME') # mandatory
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
|
@ -2217,7 +2217,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
self.locallabels = set()
|
self.locallabels = set()
|
||||||
body = self.Parse_code_block(None)
|
body = self.Parse_code_block(None)
|
||||||
del self.locallabels
|
del self.locallabels
|
||||||
ret.append({'nt':'FNDEF', 't':None, 'name':name, # no scope as these are reserved words
|
ret.append({'nt':'FNDEF', 't':None, 'name':name, # no scope as these are reserved words
|
||||||
'pscope':self.scopeindex, 'ptypes':params[0], 'pnames':params[1],
|
'pscope':self.scopeindex, 'ptypes':params[0], 'pnames':params[1],
|
||||||
'ch':[body]})
|
'ch':[body]})
|
||||||
self.PopScope()
|
self.PopScope()
|
||||||
|
@ -2264,13 +2264,13 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
|
|
||||||
if self.tok[0] in ('=', ';'):
|
if self.tok[0] in ('=', ';'):
|
||||||
# This is a variable definition
|
# This is a variable definition
|
||||||
if typ is None: # Typeless variables are not allowed
|
if typ is None: # Typeless variables are not allowed
|
||||||
raise EParseSyntax(self)
|
raise EParseSyntax(self)
|
||||||
|
|
||||||
if self.tok[0] == '=':
|
if self.tok[0] == '=':
|
||||||
self.NextToken()
|
self.NextToken()
|
||||||
if self.extendedglobalexpr:
|
if self.extendedglobalexpr:
|
||||||
self.disallowglobalvars = True # Disallow forward globals.
|
self.disallowglobalvars = True # Disallow forward globals.
|
||||||
# Mark backtracking position
|
# Mark backtracking position
|
||||||
pos = self.pos
|
pos = self.pos
|
||||||
errorpos = self.errorpos
|
errorpos = self.errorpos
|
||||||
|
@ -2278,7 +2278,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
try:
|
try:
|
||||||
value = self.Parse_simple_expr()
|
value = self.Parse_simple_expr()
|
||||||
self.expect(';')
|
self.expect(';')
|
||||||
value['Simple'] = True # Success - mark it as simple
|
value['Simple'] = True # Success - mark it as simple
|
||||||
except EParse:
|
except EParse:
|
||||||
# Backtrack
|
# Backtrack
|
||||||
self.pos = pos
|
self.pos = pos
|
||||||
|
@ -2287,12 +2287,12 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
# Use advanced expression evaluation.
|
# Use advanced expression evaluation.
|
||||||
value = self.Parse_expression()
|
value = self.Parse_expression()
|
||||||
self.expect(';')
|
self.expect(';')
|
||||||
self.disallowglobalvars = False # Allow forward globals again.
|
self.disallowglobalvars = False # Allow forward globals again.
|
||||||
else:
|
else:
|
||||||
# Use LSL's dull global expression.
|
# Use LSL's dull global expression.
|
||||||
value = self.Parse_simple_expr()
|
value = self.Parse_simple_expr()
|
||||||
self.expect(';')
|
self.expect(';')
|
||||||
else: # must be semicolon
|
else: # must be semicolon
|
||||||
value = None
|
value = None
|
||||||
|
|
||||||
assert self.scopeindex == 0
|
assert self.scopeindex == 0
|
||||||
|
@ -2315,7 +2315,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
self.locallabels = set()
|
self.locallabels = set()
|
||||||
body = self.Parse_code_block(typ)
|
body = self.Parse_code_block(typ)
|
||||||
del self.locallabels
|
del self.locallabels
|
||||||
if typ and 'LIR' not in body: # is LastIsReturn flag set?
|
if typ and 'LIR' not in body: # is LastIsReturn flag set?
|
||||||
raise EParseCodePathWithoutRet(self)
|
raise EParseCodePathWithoutRet(self)
|
||||||
paramscope = self.scopeindex
|
paramscope = self.scopeindex
|
||||||
self.AddSymbol('f', 0, name, Loc=len(self.tree), Type=typ,
|
self.AddSymbol('f', 0, name, Loc=len(self.tree), Type=typ,
|
||||||
|
@ -2401,7 +2401,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
raise EParseUndefined(self)
|
raise EParseUndefined(self)
|
||||||
tgt[3]['scope'] = sym['Scope']
|
tgt[3]['scope'] = sym['Scope']
|
||||||
|
|
||||||
del self.jump_lookups # Finished with it.
|
del self.jump_lookups # Finished with it.
|
||||||
|
|
||||||
def Parse_single_expression(self):
|
def Parse_single_expression(self):
|
||||||
"""Parse the script as an expression, Used by lslcalc.
|
"""Parse the script as an expression, Used by lslcalc.
|
||||||
|
@ -2432,7 +2432,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
states: state [state [...]]
|
states: state [state [...]]
|
||||||
state: (DEFAULT | STATE IDENT) balanced_braces_or_anything_else
|
state: (DEFAULT | STATE IDENT) balanced_braces_or_anything_else
|
||||||
"""
|
"""
|
||||||
ret = self.funclibrary.copy() # The library functions go here too.
|
ret = self.funclibrary.copy() # The library functions go here too.
|
||||||
|
|
||||||
# If there's a syntax error, that's not our business. We just return
|
# If there's a syntax error, that's not our business. We just return
|
||||||
# what we have so far. Doing a proper parse will determine the exact
|
# what we have so far. Doing a proper parse will determine the exact
|
||||||
|
@ -2462,14 +2462,14 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
return ret
|
return ret
|
||||||
params.append(self.tok[1])
|
params.append(self.tok[1])
|
||||||
self.NextToken()
|
self.NextToken()
|
||||||
self.NextToken() # not interested in parameter names
|
self.NextToken() # not interested in parameter names
|
||||||
if self.tok[0] != ',':
|
if self.tok[0] != ',':
|
||||||
break
|
break
|
||||||
self.NextToken()
|
self.NextToken()
|
||||||
self.NextToken()
|
self.NextToken()
|
||||||
if self.tok[0] != '{':
|
if self.tok[0] != '{':
|
||||||
return ret
|
return ret
|
||||||
self.NextToken() # Enter the first brace
|
self.NextToken() # Enter the first brace
|
||||||
|
|
||||||
bracelevel = 1
|
bracelevel = 1
|
||||||
while bracelevel and self.tok[0] != 'EOF':
|
while bracelevel and self.tok[0] != 'EOF':
|
||||||
|
@ -2482,12 +2482,12 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
'uns':True}
|
'uns':True}
|
||||||
|
|
||||||
elif typ is None:
|
elif typ is None:
|
||||||
return ret # A variable needs a type
|
return ret # A variable needs a type
|
||||||
else:
|
else:
|
||||||
# No location info but none is necessary for forward
|
# No location info but none is necessary for forward
|
||||||
# declarations.
|
# declarations.
|
||||||
ret[name] = {'Kind':'v','Type':typ,'Scope':0}
|
ret[name] = {'Kind':'v','Type':typ,'Scope':0}
|
||||||
while self.tok[0] != ';': # Don't stop to analyze what's before the ending ';'
|
while self.tok[0] != ';': # Don't stop to analyze what's before the ending ';'
|
||||||
if self.tok[0] == 'EOF':
|
if self.tok[0] == 'EOF':
|
||||||
return ret
|
return ret
|
||||||
self.NextToken()
|
self.NextToken()
|
||||||
|
@ -2498,7 +2498,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
# Scan states
|
# Scan states
|
||||||
while True:
|
while True:
|
||||||
if self.tok[0] not in ('DEFAULT', 'STATE'):
|
if self.tok[0] not in ('DEFAULT', 'STATE'):
|
||||||
return ret # includes EOF i.e. this is the normal return
|
return ret # includes EOF i.e. this is the normal return
|
||||||
|
|
||||||
if self.tok[0] == 'STATE':
|
if self.tok[0] == 'STATE':
|
||||||
self.NextToken()
|
self.NextToken()
|
||||||
|
@ -2514,7 +2514,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
|
|
||||||
if self.tok[0] != '{':
|
if self.tok[0] != '{':
|
||||||
return ret
|
return ret
|
||||||
self.NextToken() # Enter the first brace
|
self.NextToken() # Enter the first brace
|
||||||
|
|
||||||
bracelevel = 1
|
bracelevel = 1
|
||||||
while bracelevel and self.tok[0] != 'EOF':
|
while bracelevel and self.tok[0] != 'EOF':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue