| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 | 
							- /**
 
-  *
 
-  * @author    seagle
 
-  * @date      2024-7-22
 
-  * @Description if语句处理
 
-  */
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- namespace MECF.Framework.UI.Core.DxfScript
 
- {
 
-     public class IfSentence:Sentence
 
-     {
 
-         
 
-         private Express ifExpr = null;
 
-         BlockSentence ifBlock = null;
 
-         BlockSentence elseBlock = null;
 
-         public override void Create(StringReader reader)
 
-         {
 
-             KeywordType kw = reader.Next();
 
-             if (kw != KeywordType.KW_IF)
 
-             {
 
-                 throw new Exception("SetSentence: if expected");
 
-             }
 
-             kw = reader.Next();
 
-             if (kw != KeywordType.KW_ROUND_LEFT)
 
-             {
 
-                 throw new Exception("Round left expected in if sentence");
 
-             }
 
-             ifExpr = new Express();
 
-             ifExpr.Create(reader);
 
-             kw = reader.Next();
 
-             if (kw != KeywordType.KW_ROUND_RIGHT)
 
-             {
 
-                 throw new Exception("Round right expected in if sentence");
 
-             }
 
-             kw = reader.Next();
 
-             if (kw != KeywordType.KW_BRACE_LEFT)
 
-             {
 
-                 throw new Exception("Brace left expected in if sentence");
 
-             }
 
-             ifBlock = new BlockSentence();
 
-             ifBlock.Create(reader);
 
-             
 
-             kw = reader.Next();
 
-             if(kw== KeywordType.KW_ELSE)
 
-             {
 
-                 kw = reader.Next();
 
-                 if (kw != KeywordType.KW_BRACE_LEFT)
 
-                 {
 
-                     throw new Exception("Brace left expected in if-else sentence");
 
-                 }
 
-                 elseBlock = new BlockSentence();
 
-                 elseBlock.Create(reader);
 
-             }
 
-             else
 
-             {
 
-                 if(kw!= KeywordType.KW_EOF)
 
-                 {
 
-                     reader.rollback(kw);
 
-                 }
 
-             }
 
-              
 
-         }
 
-         public override void Execute()
 
-         {
 
-             ifExpr.Compute();
 
-             if (ifExpr.Root.Var.BoolValue)
 
-             {
 
-                 if(ifBlock != null)
 
-                 {
 
-                     ifBlock.Execute();
 
-                     if (ifBlock.ShouldReturn)
 
-                     {
 
-                         ShouldReturn = true;
 
-                         ReturnVar = ifBlock.ReturnVar;
 
-                         return;
 
-                     }
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (elseBlock != null)
 
-                 {
 
-                     elseBlock.Execute();
 
-                     if (elseBlock.ShouldReturn)
 
-                     {
 
-                         ShouldReturn = true;
 
-                         ReturnVar = elseBlock.ReturnVar;
 
-                         return;
 
-                     }
 
-                 }
 
-             }
 
-             
 
-         }
 
-     }
 
- }
 
 
  |