From 61deef5cdf96cbfdd6ad45be49e80d597c00ca65 Mon Sep 17 00:00:00 2001
From: QuakeGod <QuakeGod@sina.com>
Date: 星期二, 24 十二月 2024 08:37:21 +0800
Subject: [PATCH] 2024-12-24

---
 MTerm1/MTerm1View.h |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/MTerm1/MTerm1View.h b/MTerm1/MTerm1View.h
index d5bca8a..773acd5 100644
--- a/MTerm1/MTerm1View.h
+++ b/MTerm1/MTerm1View.h
@@ -62,6 +62,7 @@
 		typeFN4 = 70,		//3涓弬鏁扮殑鍑芥暟
 
 		typeCoil=99,
+		typeEND = 255,
 
 	};
 	struct stCell
@@ -95,6 +96,9 @@
 	stCell Cells[2000][16] = { 0 };
 	struct stProgSection
 	{
+		int Prefix = 0;
+		int Suffix = 0;
+		int bModifyVal = 1;
 		std::vector <CMTerm1Doc::stProg> Progs;
 		int Append(CMTerm1Doc::stProg prog) {
 			Progs.push_back(prog);
@@ -109,6 +113,7 @@
 		};
 		int operator+=(const struct stProgSection progsec) {
 			Append(progsec);
+			bModifyVal = bModifyVal | progsec.bModifyVal;
 			return 0;
 		};
 
@@ -120,6 +125,7 @@
 			CString s1;
 			CStringA s2A;
 			int n = (int)Progs.size();
+			s2A.Format(" +%d ", Prefix);
 			for (int k = 0; k < n; k++) {
 				CMTerm1Doc::stProg& prog0 = Progs.at(k);
 				s2A = prog0.ToText();
@@ -127,6 +133,32 @@
 			}
 			return s1;
 		}
+		int reduce()
+		{
+			if (Prefix > 0) {
+				int level = 0;
+				int j = Progs.size();
+				for (int i = 0; i < j; i++) {
+					int nOp = Progs[i].nOpType1;
+					if (nOp == OP_ST || nOp == OP_ST_) {
+						level += 1;;
+					}
+					else if (nOp == OP_ORS) {
+						level -= 1;
+					}
+					if (nOp == OP_ANS) {
+						level -= 1;
+						if (level == 0) {
+							Progs.erase(Progs.begin() + i);
+							Prefix -= 1;
+							break;
+						}
+					}
+				}
+
+			}
+			return Prefix;
+		}
 	};
 	std::pair<int, int> popsPoint[100];
 

--
Gitblit v1.9.1