فهرست منبع

完善编辑器检测方法

cxs 7 ماه پیش
والد
کامیت
7963863748
1فایلهای تغییر یافته به همراه30 افزوده شده و 15 حذف شده
  1. 30 15
      OTSPartA_STDEditor/UI/Form_Main.cs

+ 30 - 15
OTSPartA_STDEditor/UI/Form_Main.cs

@@ -370,6 +370,21 @@ namespace OTSPartA_STDEditor
                         MessageBox.Show("Invalid string exists:" + "(" + Symbol[i], "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         return false;
                     }
+                    //尾字符检测
+                    int n= Symbol[i].Length;
+                    if (str_RemoveBlank.Length >= n)
+                    {
+                        if (str_RemoveBlank.Substring(str_RemoveBlank.Length-n, n) == Symbol[i]) 
+                        {
+                            MessageBox.Show("Last character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                            return false;
+                        }
+                        if (str_RemoveBlank.Substring(0, n) == Symbol[i])
+                        {
+                            MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                            return false;
+                        }
+                    }
                 }
 
                 //左右括号匹配检验
@@ -384,21 +399,21 @@ namespace OTSPartA_STDEditor
                     MessageBox.Show("Number of left and right parentheses does not match!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     return false;
                 }
-                //首字符检测
-                if ((str_RemoveBlank[0] == '+') || (str_RemoveBlank[0] == '-') || (str_RemoveBlank[0] == '*') || (str_RemoveBlank[0] == '/') || (str_RemoveBlank[0] == '>') || (str_RemoveBlank[0] == '<') || (str_RemoveBlank[0] == '=') || (str_RemoveBlank[0] == ')') || (str_RemoveBlank[str_RemoveBlank.Length - 1] == '('))
-                {
-                    MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
-                    return false;
-                }
-
-                if (str_RemoveBlank.Length >= 3)
-                {
-                    if ((str_RemoveBlank.Substring(0, 3) == "and") || (str_RemoveBlank.Substring(0, 3) == "end"))
-                    {
-                        MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
-                        return false;
-                    }
-                }
+                ////首字符检测
+                //if ((str_RemoveBlank[0] == '+') || (str_RemoveBlank[0] == '-') || (str_RemoveBlank[0] == '*') || (str_RemoveBlank[0] == '/') || (str_RemoveBlank[0] == '>') || (str_RemoveBlank[0] == '<') || (str_RemoveBlank[0] == '=') || (str_RemoveBlank[0] == ')') || (str_RemoveBlank[str_RemoveBlank.Length - 1] == '('))
+                //{
+                //    MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                //    return false;
+                //}
+
+                //if (str_RemoveBlank.Length >= 3)
+                //{
+                //    if ((str_RemoveBlank.Substring(0, 3) == "and") || (str_RemoveBlank.Substring(0, 3) == "end"))
+                //    {
+                //        MessageBox.Show("First character is error!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                //        return false;
+                //    }
+                //}
 
 
                 //forth_elem干扰or分隔符,故先行去掉