mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-03 00:18:20 +00:00
Fix wrong output leading to incorrect tokenization of minus signs
When the tree has a unary minus node (NEG) whose child is a product node (*), and the left operand of the product node starts with a minus sign but is not a NEG node, this produced at least two minus signs in sequence without any spaces. Normally, OptSigns hides this problem, but when it is disabled, or when the left factor is a pre-decrement (--V) node, the problem is visible. Fix by creating a function that detects all kinds of leading minus signs, and use it in place of the comparison with NEG. Fixes #31. Reported by @KrsityKu, who also provided a repro.
This commit is contained in:
parent
0083da6b01
commit
d70c914738
4 changed files with 61 additions and 4 deletions
20
unit_tests/regression.suite/issue-31.lsl
Normal file
20
unit_tests/regression.suite/issue-31.lsl
Normal file
|
@ -0,0 +1,20 @@
|
|||
default{timer(){
|
||||
integer ia = llGetUnixTime();
|
||||
integer ib = llGetUnixTime();
|
||||
integer ic = -5;
|
||||
integer id = ia*2;
|
||||
integer ie = -ic*ia;
|
||||
float fa = llGetTime();
|
||||
float fb = llGetTime();
|
||||
float fc = -5.5;
|
||||
float fd = fa*2;
|
||||
float fe = -fc*fa;
|
||||
// FIXME: This is broken in the output module.
|
||||
// The output should parenthesize the first two factors in the products,
|
||||
// just as they are in the source. Fortunately they are equivalent.
|
||||
// FIXME: The output is not optimal.
|
||||
// It would suffice to add a space without parenthesizing the --ia,
|
||||
// just like in the source.
|
||||
llOwnerSay((string)[(- --ia*ib)*ib, (-++ia*ib)*ib, --ia*ib, ie]);
|
||||
llOwnerSay((string)[(- --fa*fb)*fb, (-++fa*fb)*fb, --fa*fb, fe]);
|
||||
}}
|
Loading…
Add table
Add a link
Reference in a new issue