mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Add lslcalc support.
lslcalc is currently derived from a snapshot of PyOptimizer at some point in past, making it difficult to maintain when bug fixes are applied to the optimizer. Solve this by incorporating expression evaluation capabilities.
This commit is contained in:
parent
43beb767f2
commit
2f4f403535
1 changed files with 17 additions and 2 deletions
|
@ -2359,6 +2359,17 @@ list lazy_list_set(list L, integer i, list v)
|
|||
|
||||
del self.jump_lookups # Finished with it.
|
||||
|
||||
def Parse_single_expression(self):
|
||||
"""Parse the script as an expression, Used by lslcalc.
|
||||
|
||||
Grammar parsed here:
|
||||
|
||||
script: expression EOF
|
||||
"""
|
||||
value = self.Parse_expression()
|
||||
self.tree.append({'nt':'EXPR', 't':value['t'], 'ch':[value]})
|
||||
return
|
||||
|
||||
def BuildTempGlobalsTable(self):
|
||||
"""Build an approximate globals table.
|
||||
|
||||
|
@ -2609,7 +2620,8 @@ list lazy_list_set(list L, integer i, list v)
|
|||
self.linestart = True
|
||||
self.tok = self.GetToken()
|
||||
|
||||
self.globals = self.BuildTempGlobalsTable()
|
||||
self.globals = self.BuildTempGlobalsTable() if \
|
||||
'lslcalc' not in options else self.funclibrary.copy()
|
||||
|
||||
# Restart
|
||||
|
||||
|
@ -2623,6 +2635,9 @@ list lazy_list_set(list L, integer i, list v)
|
|||
self.usedspots = 0
|
||||
|
||||
# Start the parsing proper
|
||||
if 'lslcalc' in options:
|
||||
self.Parse_single_expression()
|
||||
else:
|
||||
self.Parse_script()
|
||||
|
||||
# No longer needed. The data is already in self.symtab[0].
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue