diff options
author | Mike Mazur | 2008-07-31 01:27:33 +0000 |
---|---|---|
committer | Mike Mazur | 2008-07-31 01:27:33 +0000 |
commit | eef386427863e27a40cb22a424ddb5ceeb6c7a56 (patch) | |
tree | 331ca69428a9ece47d412556a366839f76ffded2 /OpenSim/Region/ScriptEngine/Shared | |
parent | More LSL_Types implicit/explicit cast changes. Fix issue 1854. (diff) | |
download | opensim-SC_OLD-eef386427863e27a40cb22a424ddb5ceeb6c7a56.zip opensim-SC_OLD-eef386427863e27a40cb22a424ddb5ceeb6c7a56.tar.gz opensim-SC_OLD-eef386427863e27a40cb22a424ddb5ceeb6c7a56.tar.bz2 opensim-SC_OLD-eef386427863e27a40cb22a424ddb5ceeb6c7a56.tar.xz |
Fix issue 1860; exception thrown in the parser on if/if-else/for/while/do-while
statements with no body.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs | 10 |
2 files changed, 14 insertions, 10 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 3bdad4d..2226673 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | |||
@@ -388,14 +388,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
388 | private string GenerateStatement(Statement s) | 388 | private string GenerateStatement(Statement s) |
389 | { | 389 | { |
390 | string retstr = String.Empty; | 390 | string retstr = String.Empty; |
391 | 391 | bool printSemicolon = true; | |
392 | // Jump label prints its own colon, we don't need a semicolon. | ||
393 | bool printSemicolon = !(s.kids.Top is JumpLabel); | ||
394 | 392 | ||
395 | retstr += Indent(); | 393 | retstr += Indent(); |
396 | 394 | ||
397 | foreach (SYMBOL kid in s.kids) | 395 | if (0 < s.kids.Count) |
398 | retstr += GenerateNode(kid); | 396 | { |
397 | // Jump label prints its own colon, we don't need a semicolon. | ||
398 | printSemicolon = !(s.kids.Top is JumpLabel); | ||
399 | |||
400 | foreach (SYMBOL kid in s.kids) | ||
401 | retstr += GenerateNode(kid); | ||
402 | } | ||
399 | 403 | ||
400 | if (printSemicolon) | 404 | if (printSemicolon) |
401 | retstr += GenerateLine(";"); | 405 | retstr += GenerateLine(";"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs index e9b3886..9778245 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs | |||
@@ -359,7 +359,7 @@ public override int yynum { get { return 114; }} | |||
359 | public StateChange(Parser yyp):base(yyp){}} | 359 | public StateChange(Parser yyp):base(yyp){}} |
360 | //%+IfStatement+115 | 360 | //%+IfStatement+115 |
361 | public class IfStatement : SYMBOL{ | 361 | public class IfStatement : SYMBOL{ |
362 | private void AddStatement ( Statement s ){ if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); | 362 | private void AddStatement ( Statement s ){ if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); |
363 | else kids . Add ( s ); | 363 | else kids . Add ( s ); |
364 | } | 364 | } |
365 | public IfStatement (Parser yyp, Expression e , Statement ifs ):base(((LSLSyntax | 365 | public IfStatement (Parser yyp, Expression e , Statement ifs ):base(((LSLSyntax |
@@ -369,7 +369,7 @@ public class IfStatement : SYMBOL{ | |||
369 | public IfStatement (Parser yyp, Expression e , Statement ifs , Statement es ):base(((LSLSyntax | 369 | public IfStatement (Parser yyp, Expression e , Statement ifs , Statement es ):base(((LSLSyntax |
370 | )yyp)){ kids . Add ( e ); | 370 | )yyp)){ kids . Add ( e ); |
371 | AddStatement ( ifs ); | 371 | AddStatement ( ifs ); |
372 | if ( es . kids . Top is IfStatement ) kids . Add ( es . kids . Pop ()); | 372 | if (0< es . kids . Count && es . kids . Top is IfStatement ) kids . Add ( es . kids . Pop ()); |
373 | else AddStatement ( es ); | 373 | else AddStatement ( es ); |
374 | } | 374 | } |
375 | 375 | ||
@@ -380,7 +380,7 @@ public IfStatement(Parser yyp):base(yyp){}} | |||
380 | public class WhileStatement : SYMBOL{ | 380 | public class WhileStatement : SYMBOL{ |
381 | public WhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax | 381 | public WhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax |
382 | )yyp)){ kids . Add ( e ); | 382 | )yyp)){ kids . Add ( e ); |
383 | if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); | 383 | if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); |
384 | else kids . Add ( s ); | 384 | else kids . Add ( s ); |
385 | } | 385 | } |
386 | 386 | ||
@@ -390,7 +390,7 @@ public WhileStatement(Parser yyp):base(yyp){}} | |||
390 | //%+DoWhileStatement+117 | 390 | //%+DoWhileStatement+117 |
391 | public class DoWhileStatement : SYMBOL{ | 391 | public class DoWhileStatement : SYMBOL{ |
392 | public DoWhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax | 392 | public DoWhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax |
393 | )yyp)){ if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); | 393 | )yyp)){ if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); |
394 | else kids . Add ( s ); | 394 | else kids . Add ( s ); |
395 | kids . Add ( e ); | 395 | kids . Add ( e ); |
396 | } | 396 | } |
@@ -404,7 +404,7 @@ public class ForLoop : SYMBOL{ | |||
404 | )yyp)){ kids . Add ( flsa ); | 404 | )yyp)){ kids . Add ( flsa ); |
405 | kids . Add ( e ); | 405 | kids . Add ( e ); |
406 | kids . Add ( flsb ); | 406 | kids . Add ( flsb ); |
407 | if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); | 407 | if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); |
408 | else kids . Add ( s ); | 408 | else kids . Add ( s ); |
409 | } | 409 | } |
410 | 410 | ||