vue2-client 1.22.2 → 1.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/.claude/settings.local.json +30 -30
  2. package/.env.his +19 -19
  3. package/.eslintrc.js +74 -74
  4. package/.history/.eslintrc_20260521171150.js +74 -0
  5. package/.history/.eslintrc_20260521171213.js +74 -0
  6. package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154443.vue +726 -0
  7. package/.history/src/base-client/components/common/HIS/HAddNativeForm/HAddNativeForm_20260601154700.vue +478 -0
  8. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175435.vue +706 -0
  9. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260512175450.vue +694 -0
  10. package/.history/src/base-client/components/common/HIS/HButtons/HButtons_20260611152602.vue +755 -0
  11. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513145941.vue +524 -0
  12. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513153133.vue +731 -0
  13. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260513160316.vue +525 -0
  14. package/.history/src/base-client/components/common/HIS/HForm/HForm_20260601144150.vue +1046 -0
  15. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310142713.vue +512 -0
  16. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260310145118.vue +511 -0
  17. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260311094834.vue +696 -0
  18. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260320143028.vue +693 -0
  19. package/.history/src/base-client/components/common/HIS/HFormTable/HFormTable_20260409101450.vue +677 -0
  20. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260508164645.vue +758 -0
  21. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260508164714.vue +693 -0
  22. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260508171651.vue +716 -0
  23. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260509133717.vue +695 -0
  24. package/.history/src/base-client/components/common/HIS/HTab/HTab_20260509171115.vue +664 -0
  25. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140637.vue +1455 -0
  26. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513140935.vue +1441 -0
  27. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513150818.vue +1441 -0
  28. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153119.vue +1442 -0
  29. package/.history/src/base-client/components/common/XAddNativeForm/XAddNativeForm_20260513153126.vue +1486 -0
  30. package/.history/src/base-client/components/common/XForm/XFormItem_20260513140854.vue +1607 -0
  31. package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140403.vue +643 -0
  32. package/.history/src/base-client/components/common/XMarkdownViewer/XMarkdownViewer_20260519140829.vue +628 -0
  33. package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519142824.vue +104 -0
  34. package/.history/src/base-client/components/common/XMarkdownViewer/demo_20260519143155.vue +102 -0
  35. package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171231.vue +1241 -0
  36. package/.history/src/base-client/components/common/XReportGrid/XReport_20260309171441.vue +1223 -0
  37. package/.history/src/base-client/components/his/HAi/HAi_20260612174826.vue +472 -0
  38. package/.history/src/base-client/components/his/HAi/HAi_20260612175839.vue +538 -0
  39. package/.history/src/base-client/components/his/HAi/HAi_20260615103331.vue +650 -0
  40. package/.history/src/base-client/components/his/XHDescriptions/XHDescriptions_20260424134504.vue +1469 -0
  41. package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171133.vue +788 -0
  42. package/.history/src/base-client/components/his/XSidebar/XSidebar_20260610171151.vue +780 -0
  43. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511170841.vue +585 -0
  44. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260511171138.vue +787 -0
  45. package/.history/src/base-client/components/his/XTransfer/XTransfer_20260512141830.vue +739 -0
  46. package/.history/src/components/STable/index_20260409155138.js +806 -0
  47. package/.history/src/components/STable/index_20260409155218.js +814 -0
  48. package/.history/src/expression/core/Expression_20260305164427.js +1371 -0
  49. package/.history/src/expression/core/Expression_20260305170258.js +1358 -0
  50. package/.history/src/expression/core/Program_20260305111830.js +944 -0
  51. package/.history/src/expression/core/Program_20260305112041.js +931 -0
  52. package/.history/src/logic/LogicRunner_20260304154306.js +170 -0
  53. package/.history/src/logic/LogicRunner_20260304155553.js +112 -0
  54. package/.history/src/logic/LogicRunner_20260305105834.js +112 -0
  55. package/.history/src/logic/LogicRunner_20260305112718.js +129 -0
  56. package/.history/src/logic/LogicRunner_20260305182436.js +133 -0
  57. package/.history/src/logic/LogicRunner_20260306151301.js +213 -0
  58. package/.history/src/logic/LogicRunner_20260306152419.js +213 -0
  59. package/.history/src/logic/plugins/common/DateTools_20260305154159.js +61 -0
  60. package/.history/src/logic/plugins/common/DateTools_20260305154217.js +44 -0
  61. package/.history/src/logic/plugins/common/DateTools_20260305161014.js +44 -0
  62. package/.history/src/logic/plugins/common/HttpTools_20260305164352.js +80 -0
  63. package/.history/src/logic/plugins/common/HttpTools_20260305170258.js +75 -0
  64. package/.history/src/logic/plugins/common/HttpTools_20260305171634.js +75 -0
  65. package/.history/src/logic/plugins/common/HttpTools_20260306152419.js +72 -0
  66. package/.history/src/services/api/restTools_20260427142149.js +245 -0
  67. package/.history/src/services/api/restTools_20260427142853.js +230 -0
  68. package/.history/src/services/api/restTools_20260519135558.js +230 -0
  69. package/.history/src/services/api/restTools_20260519140825.js +230 -0
  70. package/.history/src/services/api/restTools_20260519151223.js +230 -0
  71. package/.history/src/utils/indexedDB_20260306150918.js +593 -0
  72. package/.history/src/utils/indexedDB_20260306151301.js +586 -0
  73. package/.idea/af-vue2-client.iml +9 -0
  74. package/.idea/codeStyles/Project.xml +62 -0
  75. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  76. package/.idea/misc.xml +6 -0
  77. package/.idea/modules.xml +1 -1
  78. package/Components.md +60 -60
  79. package/index.js +31 -31
  80. package/jest-transform-stub.js +8 -8
  81. package/jest.setup.js +7 -7
  82. package/package.json +1 -1
  83. package/preview-input-box.html +180 -0
  84. package/src/assets/img/querySlotDemo.svg +15 -15
  85. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  86. package/src/base-client/components/common/CitySelect/index.js +3 -3
  87. package/src/base-client/components/common/CitySelect/index.md +109 -109
  88. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  89. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  90. package/src/base-client/components/common/HIS/HButtons/HButtons.vue +55 -1
  91. package/src/base-client/components/common/HIS/HForm/HForm.vue +1186 -1186
  92. package/src/base-client/components/common/HIS/HTab/HTab.vue +88 -1
  93. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  94. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  95. package/src/base-client/components/common/Tree/index.js +2 -2
  96. package/src/base-client/components/common/Upload/index.js +3 -3
  97. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  98. package/src/base-client/components/common/XAddReport/XAddReport.vue +16 -1
  99. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  100. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  101. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  102. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  103. package/src/base-client/components/common/XDescriptions/index.js +3 -3
  104. package/src/base-client/components/common/XDescriptions/index.md +382 -382
  105. package/src/base-client/components/common/XForm/index.md +178 -178
  106. package/src/base-client/components/common/XInput/XInput.vue +32 -1
  107. package/src/base-client/components/common/XInspectionDetailDrawer/index.vue +1 -1
  108. package/src/base-client/components/common/XMarkdownViewer/demo.vue +102 -102
  109. package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
  110. package/src/base-client/components/common/XStepView/index.js +3 -3
  111. package/src/base-client/components/common/XStepView/index.md +31 -31
  112. package/src/base-client/components/common/XTable/index.md +255 -255
  113. package/src/base-client/components/his/HAi/HAi.vue +1177 -436
  114. package/src/base-client/components/his/XList/XList.vue +337 -58
  115. package/src/base-client/components/his/XSidebar/XSidebar.vue +36 -12
  116. package/src/base-client/components/his/XTransfer/index.md +327 -327
  117. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  118. package/src/base-client/plugins/Config.js +19 -19
  119. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  120. package/src/components/Charts/Bar.vue +62 -62
  121. package/src/components/Charts/ChartCard.vue +134 -134
  122. package/src/components/Charts/Liquid.vue +67 -67
  123. package/src/components/Charts/MiniArea.vue +39 -39
  124. package/src/components/Charts/MiniBar.vue +39 -39
  125. package/src/components/Charts/MiniProgress.vue +75 -75
  126. package/src/components/Charts/MiniSmoothArea.vue +40 -40
  127. package/src/components/Charts/Radar.vue +68 -68
  128. package/src/components/Charts/RankList.vue +77 -77
  129. package/src/components/Charts/TagCloud.vue +113 -113
  130. package/src/components/Charts/TransferBar.vue +64 -64
  131. package/src/components/Charts/Trend.vue +82 -82
  132. package/src/components/Charts/chart.less +12 -12
  133. package/src/components/Charts/smooth.area.less +13 -13
  134. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  135. package/src/components/NumberInfo/index.js +3 -3
  136. package/src/components/NumberInfo/index.less +54 -54
  137. package/src/components/NumberInfo/index.md +43 -43
  138. package/src/components/STable/index.js +953 -953
  139. package/src/components/card/ChartCard.vue +79 -79
  140. package/src/components/chart/Bar.vue +60 -60
  141. package/src/components/chart/MiniArea.vue +67 -67
  142. package/src/components/chart/MiniBar.vue +59 -59
  143. package/src/components/chart/MiniProgress.vue +57 -57
  144. package/src/components/chart/Radar.vue +80 -80
  145. package/src/components/chart/RankingList.vue +60 -60
  146. package/src/components/chart/Trend.vue +79 -79
  147. package/src/components/chart/index.less +9 -9
  148. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  149. package/src/components/input/IInput.vue +66 -66
  150. package/src/components/menu/SideMenu.vue +75 -75
  151. package/src/components/menu/menu.js +273 -273
  152. package/src/components/tool/AStepItem.vue +60 -60
  153. package/src/layouts/CommonLayout.vue +56 -56
  154. package/src/lib.js +1 -1
  155. package/src/mock/extend/index.js +84 -84
  156. package/src/mock/goods/index.js +108 -108
  157. package/src/pages/dashboard/workplace/WorkPlace.vue +141 -141
  158. package/src/pages/system/dictionary/index.vue +44 -44
  159. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  160. package/src/pages/system/monitor/operLog/index.vue +37 -37
  161. package/src/services/api/cas.js +79 -79
  162. package/src/store/modules/setting.js +119 -119
  163. package/src/utils/errorCode.js +6 -6
  164. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
  165. package/.idea/MarsCodeWorkspaceAppSettings.xml +0 -7
  166. package/.idea/google-java-format.xml +0 -6
  167. package/.idea/inspectionProfiles/Project_Default.xml +0 -24
  168. package/.idea/jsLinters/eslint.xml +0 -6
  169. package/.idea/vue2-client.iml +0 -12
  170. package/.vscode/settings.json +0 -28
@@ -0,0 +1,944 @@
1
+ import Token from './Token'
2
+ import Expression from './Expression'
3
+ import Delegate from './Delegate'
4
+ import ExpressionType from '../enums/ExpressionType'
5
+ import TokenType from '../enums/TokenType'
6
+
7
+ /**
8
+ * 表达式入口
9
+ */
10
+ export default class Program {
11
+ // 源程序
12
+ SOURCE
13
+ SOURCE_LENGTH
14
+ /**
15
+ * Token队列,用于回退
16
+ */
17
+ tokens = []
18
+ /**
19
+ * 字符串处理环节堆栈,双引号进入字符串处理环节,“{}”中间部分脱离字符串处理环节
20
+ */
21
+ inStrings = []
22
+
23
+ /**
24
+ * 当前获取到的字符位置
25
+ */
26
+ pos = 0
27
+
28
+ /**
29
+ * 当前是否在字符串处理环节
30
+ */
31
+ inString = false
32
+
33
+ constructor (source) {
34
+ this.SOURCE = source
35
+ this.SOURCE_LENGTH = this.SOURCE.length
36
+ }
37
+
38
+ /**
39
+ * 调用解析过程
40
+ */
41
+ parse () {
42
+ // 执行完以下方法后就已经诞生了一个完整的执行流程,也就是被翻译成了一套完整的指令集。
43
+ return this.createDelegate(this.expression())
44
+ }
45
+
46
+ parseExpression (expression) {
47
+ // 执行完以下方法后就已经诞生了一个完整的执行流程,也就是被翻译成了一套完整的指令集。
48
+ return this.createDelegate(expression)
49
+ }
50
+
51
+ /**
52
+ * 编译,产生可执行单元Delegate
53
+ */
54
+ createDelegate (expression) {
55
+ return new Delegate(expression, this.SOURCE)
56
+ }
57
+
58
+ /**
59
+ * 获取完整表达式
60
+ */
61
+ expression () {
62
+ const expression = this.CommaExp()
63
+ if (this.pos < this.SOURCE_LENGTH) {
64
+ throw new Error(this.GetExceptionMessage('需要逗号结尾!'))
65
+ }
66
+ return expression
67
+ }
68
+
69
+ /**
70
+ * 逗号表达式=赋值表达式(,赋值表达式)*
71
+ */
72
+ CommaExp () {
73
+ const exps = []
74
+
75
+ const first = this.AssignExp()
76
+ exps.push(first)
77
+
78
+ let t = this.GetToken()
79
+
80
+ // 没有结束
81
+ while (t.getType() === TokenType.Oper && (t.getValue() === ',' || t.getValue() === ';' || t.getValue() === '\n')) {
82
+ const r = this.AssignExp()
83
+ exps.push(r)
84
+ t = this.GetToken()
85
+ }
86
+
87
+ this.tokens.push(t)
88
+
89
+ return Expression.Comma(exps, this.pos)
90
+ }
91
+
92
+ /**
93
+ * 赋值表达式=对象属性=一般表达式|一般表达式
94
+ */
95
+ AssignExp () {
96
+ let t = this.GetToken()
97
+
98
+ // 把第一个Token的位置记录下来,方便后面回退
99
+ const firstPos = t.getStartPos()
100
+
101
+ if (t.getType() !== TokenType.Identy) {
102
+ this.pos = firstPos
103
+ this.tokens.length = 0 // Clear the tokens array
104
+ this.inString = false
105
+ return this.Exp()
106
+ }
107
+
108
+ let objExp = Expression.Identity(t.getValue(), this.pos)
109
+ objExp = this.ObjectPath(objExp)
110
+
111
+ // 只能给对象属性或者变量赋值
112
+ if (objExp.type !== ExpressionType.Property && objExp.type !== ExpressionType.Identity) {
113
+ this.pos = firstPos
114
+ this.tokens.length = 0
115
+ this.inString = false
116
+ return this.Exp()
117
+ }
118
+
119
+ t = this.GetToken()
120
+ // 支持 = 和 <- 作为赋值运算符
121
+ if (t.getType() !== TokenType.Oper || (t.getValue() !== '=' && t.getValue() !== '<-')) {
122
+ this.pos = firstPos
123
+ this.tokens.length = 0
124
+ this.inString = false
125
+ return this.Exp()
126
+ }
127
+
128
+ const exp = this.Exp()
129
+
130
+ // 如果是属性赋值
131
+ if (objExp.type === ExpressionType.Property) {
132
+ // 从属性Expression中获取对象及属性名
133
+ const name = objExp.value
134
+ objExp = objExp.children[0]
135
+ return Expression.Assign(objExp, exp, name, this.pos)
136
+ } else {
137
+ // Identity 变量赋值
138
+ return Expression.Assign(null, exp, objExp.value, this.pos)
139
+ }
140
+ }
141
+
142
+ Exp () {
143
+ const v = this.Logic()
144
+
145
+ // 是':',表示条件,否则直接返回单结果
146
+ let t = this.GetToken()
147
+ if (t.getType() === TokenType.Oper && t.getValue() === ':') {
148
+ // 第一项转换
149
+ const result = this.Logic()
150
+
151
+ // 下一个是",",继续读取下一个条件结果串,由于是右结合,只能采用递归
152
+ t = this.GetToken()
153
+ if (t.getType() === TokenType.Oper && t.getValue() === ',') {
154
+ // 第二项转换
155
+ const sExp = this.Exp()
156
+ // 返回
157
+ return Expression.Condition(v, result, sExp, this.SOURCE, this.pos)
158
+ } else {
159
+ throw new Error(this.GetExceptionMessage('必须有默认值!'))
160
+ }
161
+ } else {
162
+ this.tokens.push(t) // Put the token back
163
+ return v
164
+ }
165
+ }
166
+
167
+ Logic () {
168
+ let t = this.GetToken()
169
+
170
+ // !表达式
171
+ const hasNot = t.getType() === TokenType.Oper && t.getValue() === '!'
172
+ if (!hasNot) {
173
+ this.tokens.push(t) // Put the token back if it's not '!'
174
+ }
175
+
176
+ let v = this.Compare()
177
+ if (hasNot) {
178
+ v = Expression.Not(v, this.SOURCE, this.pos)
179
+ }
180
+
181
+ t = this.GetToken()
182
+ while (t.getType() === TokenType.Oper && (t.getValue() === '&&' || t.getValue() === '||')) {
183
+ // 第二项转换
184
+ const exp = this.Logic()
185
+
186
+ // 执行
187
+ if (t.getValue() === '&&') {
188
+ v = Expression.And(v, exp, this.SOURCE, this.pos)
189
+ } else {
190
+ v = Expression.Or(v, exp, this.SOURCE, this.pos)
191
+ }
192
+
193
+ t = this.GetToken()
194
+ }
195
+
196
+ this.tokens.push(t) // Put the token back
197
+ return v
198
+ }
199
+
200
+ Compare () {
201
+ const left = this.Math()
202
+ const t = this.GetToken()
203
+
204
+ if (t.getType() === TokenType.Oper && (
205
+ t.getValue() === '>' || t.getValue() === '>=' ||
206
+ t.getValue() === '<' || t.getValue() === '<=' || t.getValue() === '=>')) {
207
+ if (t.getValue() === '=>') {
208
+ this.tokens.push(t) // Push back the token for lambda handling
209
+ return this.Lambda()
210
+ }
211
+
212
+ const rExp = this.Math()
213
+
214
+ switch (t.getValue()) {
215
+ case '>':
216
+ return Expression.GreaterThan(left, rExp, this.SOURCE, this.pos)
217
+ case '>=':
218
+ return Expression.GreaterThanOrEqual(left, rExp, this.SOURCE, this.pos)
219
+ case '<':
220
+ return Expression.LessThan(left, rExp, this.SOURCE, this.pos)
221
+ case '<=':
222
+ return Expression.LessThanOrEqual(left, rExp, this.SOURCE, this.pos)
223
+ }
224
+ } else if (t.getType() === TokenType.Oper && (
225
+ t.getValue() === '==' || t.getValue() === '!=')) {
226
+ const rExp = this.Math()
227
+
228
+ // 相等比较
229
+ if (t.getValue() === '==') {
230
+ return Expression.Equal(left, rExp, this.SOURCE, this.pos)
231
+ } else {
232
+ return Expression.NotEqual(left, rExp, this.SOURCE, this.pos)
233
+ }
234
+ }
235
+
236
+ // 返回当前的表达式结果
237
+ this.tokens.push(t) // Push the token back
238
+ return left
239
+ }
240
+
241
+ Math () {
242
+ let v = this.Mul()
243
+ let t = this.GetToken()
244
+
245
+ while (t.getType() === TokenType.Oper && (t.getValue() === '+' || t.getValue() === '-')) {
246
+ // 转换操作数2为数字
247
+ const r = this.Mul()
248
+
249
+ // 开始运算
250
+ if (t.getValue() === '+') {
251
+ v = Expression.Add(v, r, this.SOURCE, this.pos)
252
+ } else {
253
+ v = Expression.Subtract(v, r, this.SOURCE, this.pos)
254
+ }
255
+
256
+ t = this.GetToken()
257
+ }
258
+
259
+ this.tokens.push(t) // Push the token back
260
+ return v
261
+ }
262
+
263
+ Lambda () {
264
+ let t = this.GetToken()
265
+ if (t.getValue() !== '=>' || t.getValue() == null) {
266
+ throw new Error(this.GetExceptionMessage('lambda必须以=>开始'))
267
+ }
268
+
269
+ t = this.GetToken()
270
+ if (t.getValue() !== '{' || t.getValue() == null) {
271
+ throw new Error(this.GetExceptionMessage('lambda必须以{开始'))
272
+ }
273
+
274
+ // 取lambda中的表达式
275
+ const exp = this.CommaExp()
276
+
277
+ t = this.GetToken()
278
+ if (t.getValue() !== '}' || t.getValue() == null) {
279
+ throw new Error(this.GetExceptionMessage('lambda必须以}结束'))
280
+ }
281
+
282
+ return Expression.Lambda(exp, this.pos)
283
+ }
284
+
285
+ Mul () {
286
+ let v = this.UnarySub()
287
+ let t = this.GetToken()
288
+
289
+ while (t.getType() === TokenType.Oper && (t.getValue() === '*' || t.getValue() === '/' || t.getValue() === '%')) {
290
+ // Convert the second operand to a number
291
+ const r = this.UnarySub()
292
+
293
+ // Perform the operation
294
+ if (t.getValue() === '*') {
295
+ v = Expression.Multiply(v, r, this.SOURCE, this.pos)
296
+ } else if (t.getValue() === '/') {
297
+ v = Expression.Divide(v, r, this.SOURCE, this.pos)
298
+ } else {
299
+ v = Expression.Modulo(v, r, this.SOURCE, this.pos)
300
+ }
301
+
302
+ t = this.GetToken()
303
+ }
304
+
305
+ this.tokens.push(t)
306
+ return v
307
+ }
308
+
309
+ UnarySub () {
310
+ const t = this.GetToken()
311
+ if (t.getType() === TokenType.Oper && t.getValue() === '-') {
312
+ const r = this.Item()
313
+ return Expression.Subtract(Expression.Constant(0, this.pos), r, this.SOURCE, this.pos)
314
+ }
315
+ this.tokens.push(t) // Push the token back into the queue
316
+ return this.Item()
317
+ }
318
+
319
+ Item () {
320
+ const objName = ''
321
+ // 获取对象表达式
322
+ let objExp = this.ItemHead(objName)
323
+ // 获取对象路径表达式
324
+ objExp = this.ObjectPath(objExp)
325
+ return objExp
326
+ }
327
+
328
+ ItemHead (name) {
329
+ let t = this.GetToken()
330
+
331
+ if (t.getType() === TokenType.Oper && t.getValue() === '(') {
332
+ const result = this.CommaExp()
333
+ t = this.GetToken()
334
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ')') {
335
+ throw new Error(this.GetExceptionMessage('括号不匹配'))
336
+ }
337
+ return result
338
+ } else if (t.getType() === TokenType.Oper && t.getValue() === '{') {
339
+ // JSON object
340
+ return this.Json()
341
+ } else if (t.getType() === TokenType.Oper && t.getValue() === '[') {
342
+ // JSON array
343
+ return this.JsonArray()
344
+ } else if (t.getType() === TokenType.Oper && t.getValue() === '"') {
345
+ // String concatenation sequence
346
+ return this.StringUnion()
347
+ } else if (t.getType() === TokenType.Int || t.getType() === TokenType.Double || t.getType() === TokenType.Bool) {
348
+ return Expression.Constant(t.getValue(), this.pos)
349
+ } else if (t.getType() === TokenType.Identy) {
350
+ const objName = t.getValue()
351
+
352
+ switch (objName) {
353
+ case 'return':
354
+ return Expression.Return(this.Exp(), this.pos)
355
+ case 'try':
356
+ this.tokens.push(t) // Revert the token back to the queue
357
+ return this.Try()
358
+ case 'throw':
359
+ return Expression.Throw(this.Exp(), this.pos)
360
+ case 'validate':
361
+ return this.Validate()
362
+ case 'assert':
363
+ return Expression.Assert(this.Exp(), this.pos)
364
+ case 'break':
365
+ return Expression.Break(this.pos, undefined)
366
+ case 'continue':
367
+ return Expression.Continue(this.pos, undefined)
368
+ }
369
+
370
+ // Return the object name
371
+ name += objName
372
+ // Process the object name
373
+ return this.ObjectName(objName)
374
+ } else if (t.getType() === TokenType.Null) {
375
+ return Expression.Constant(null, this.pos)
376
+ }
377
+
378
+ throw new Error(this.GetExceptionMessage('单词类型错误:' + t.getType()))
379
+ }
380
+
381
+ /**
382
+ * TryCatch := try {expression} (catch(Exception类 名){表达式})* finally{表达式}?
383
+ */
384
+ Try () {
385
+ let t = this.GetToken()
386
+ if (t.getValue() !== 'try') {
387
+ throw new Error(this.GetExceptionMessage('try-catch必须以try开始'))
388
+ }
389
+
390
+ t = this.GetToken()
391
+ if (t.getValue() !== '{') {
392
+ throw new Error(this.GetExceptionMessage('try块必须以{开始'))
393
+ }
394
+
395
+ // Get the expression inside the try block
396
+ const tryExp = this.CommaExp()
397
+
398
+ t = this.GetToken()
399
+ if (t.getValue() !== '}') {
400
+ throw new Error(this.GetExceptionMessage('try块必须以}结束'))
401
+ }
402
+
403
+ // Handle the catch part
404
+ const catches = this.Catch()
405
+
406
+ // Handle finally
407
+ let finallyExp
408
+ t = this.GetToken()
409
+ if (t.getValue()) {
410
+ if (t.getValue() === 'finally') {
411
+ t = this.GetToken()
412
+ if (t.getValue() !== '{') {
413
+ throw new Error(this.GetExceptionMessage('finally块必须以{开始'))
414
+ }
415
+
416
+ // Get the expression inside the finally block
417
+ finallyExp = this.CommaExp()
418
+ t = this.GetToken()
419
+ if (t.getValue() !== '}') {
420
+ throw new Error(this.GetExceptionMessage('finally块必须以}结束'))
421
+ }
422
+ t = this.GetToken()
423
+ }
424
+ }
425
+
426
+ this.tokens.push(t)
427
+
428
+ // Return the exception handling expression
429
+ return Expression.Try(tryExp, catches, this.pos, finallyExp)
430
+ }
431
+
432
+ /**
433
+ * catch部分处理
434
+ */
435
+ Catch () {
436
+ const result = []
437
+ let t = this.GetToken()
438
+
439
+ while (t.getValue() === 'catch') {
440
+ t = this.GetToken()
441
+ if (t.getValue() !== '(') {
442
+ throw new Error(this.GetExceptionMessage('catch块参数必须以(开始'))
443
+ }
444
+
445
+ // Get the class name
446
+ t = this.GetToken()
447
+ const className = t.getValue()
448
+
449
+ // Get the variable name
450
+ t = this.GetToken()
451
+ const varName = t.getValue()
452
+
453
+ t = this.GetToken()
454
+ if (t.getValue() !== ')') {
455
+ throw new Error(this.GetExceptionMessage('catch块参数必须以)结束'))
456
+ }
457
+
458
+ // Get the opening curly brace
459
+ t = this.GetToken()
460
+ if (t.getValue() !== '{') {
461
+ throw new Error(this.GetExceptionMessage('catch块必须以{开始'))
462
+ }
463
+
464
+ // Get the expression inside the catch block
465
+ const catchExp = this.CommaExp()
466
+ result.push(Expression.Catch(className, varName, catchExp, this.pos))
467
+
468
+ // Get the closing curly brace
469
+ t = this.GetToken()
470
+ if (t.getValue() !== '}') {
471
+ throw new Error(this.GetExceptionMessage('catch块必须以}结束'))
472
+ }
473
+
474
+ // Get the next token
475
+ t = this.GetToken()
476
+ }
477
+
478
+ this.tokens.push(t)
479
+ return result
480
+ }
481
+
482
+ /**
483
+ * Validate block handling
484
+ */
485
+ Validate () {
486
+ const t = this.GetToken()
487
+ if (t.getValue() !== '{') {
488
+ throw new Error(this.GetExceptionMessage('validate只接收Json对象'))
489
+ }
490
+
491
+ // Get the expression in the validate block
492
+ const exp = this.Json()
493
+
494
+ // Return Validate processing expression
495
+ return Expression.Validate(exp, this.pos)
496
+ }
497
+
498
+ /**
499
+ * JSON Object ::= {} | {propertyName: propertyValue, propertyName: propertyValue}
500
+ */
501
+ Json () {
502
+ const children = []
503
+
504
+ let t = this.GetToken()
505
+ // Empty object, return directly
506
+ if (t.getType() === TokenType.Oper && t.getValue() === '}') {
507
+ return Expression.Json(children, this.pos)
508
+ }
509
+
510
+ this.tokens.push(t)
511
+ children.push(this.Attr())
512
+ t = this.GetToken()
513
+
514
+ // If it's a comma, continue checking the next property
515
+ while (t.getType() === TokenType.Oper && t.getValue() === ',') {
516
+ const nextT = this.GetToken()
517
+ if (nextT.getType() === TokenType.Oper && nextT.getValue() === '}') {
518
+ t = nextT
519
+ break
520
+ }
521
+ this.tokens.push(nextT)
522
+ children.push(this.Attr())
523
+ t = this.GetToken()
524
+ }
525
+
526
+ if (t.getType() !== TokenType.Oper || t.getValue() !== '}') {
527
+ throw new Error(this.GetExceptionMessage('JSON对象构建错误'))
528
+ }
529
+
530
+ return Expression.Json(children, this.pos)
531
+ }
532
+
533
+ /**
534
+ * JSON Array ::= []
535
+ */
536
+ JsonArray () {
537
+ let t = this.GetToken()
538
+ // Empty array: use Array node so each evaluation returns a new [], not a shared Constant
539
+ if (t.getType() === TokenType.Oper && t.getValue() === ']') {
540
+ return Expression.Array([], this.pos)
541
+ }
542
+
543
+ // Loop to get array contents
544
+ this.tokens.push(t)
545
+ const ps = this.Params()
546
+ t = this.GetToken()
547
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ']') {
548
+ throw new Error(this.GetExceptionMessage('JSON集合构建错误'))
549
+ }
550
+
551
+ return Expression.Array(ps, this.pos)
552
+ }
553
+
554
+ /**
555
+ * Attribute-Value Pair ::= propertyName: propertyValue
556
+ */
557
+ Attr () {
558
+ const name = this.GetToken()
559
+ let value
560
+ if (name.getType() === TokenType.Identy) {
561
+ value = name.getValue()
562
+ } else if (name.getType() === TokenType.Oper && name.getValue() === '"') {
563
+ const expression = this.StringUnion().children[1]
564
+ value = expression.value
565
+ } else {
566
+ throw new Error(this.GetExceptionMessage('JSON对象的key必须是属性名或字符串'))
567
+ }
568
+
569
+ const t = this.GetToken()
570
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ':') {
571
+ throw new Error(this.GetExceptionMessage('JSON构建错误'))
572
+ }
573
+
574
+ const exp = this.Exp()
575
+ return Expression.Attr(value, exp, this.pos)
576
+ }
577
+
578
+ /**
579
+ * Parse string concatenation sequence
580
+ */
581
+ StringUnion () {
582
+ let exp = Expression.Constant('', this.pos)
583
+ let t = this.GetToken()
584
+ // Object sequence
585
+ while ((t.getType() === TokenType.Oper && t.getValue() === '{') || t.getType() === TokenType.String) {
586
+ // If it's a string, return the concatenated result
587
+ if (t.getType() === TokenType.String) {
588
+ exp = Expression.Concat(exp, Expression.Constant(t.getValue(), this.pos), this.SOURCE, this.pos)
589
+ } else {
590
+ // Handle content inside the {}
591
+ const objExp = this.Exp()
592
+ t = this.GetToken()
593
+ if (t.getType() !== TokenType.Oper || t.getValue() !== '}') {
594
+ throw new Error(this.GetExceptionMessage("缺少'}'"))
595
+ }
596
+ // String concatenation
597
+ exp = Expression.Concat(exp, objExp, this.SOURCE, this.pos)
598
+ }
599
+ t = this.GetToken()
600
+ }
601
+ this.tokens.push(t)
602
+ return exp
603
+ }
604
+
605
+ /**
606
+ * Get object and object expression by name
607
+ */
608
+ ObjectName (objName) {
609
+ return Expression.Identity(objName, this.pos)
610
+ }
611
+
612
+ /**
613
+ * Object path parsing, handles method calls, properties, and array indices
614
+ */
615
+ ObjectPath (inExp) {
616
+ let objExp = this.ArrayIndex(inExp)
617
+ let t = this.GetToken()
618
+ while (t.getType() === TokenType.Oper && t.getValue() === '.') {
619
+ const nameToken = this.GetToken()
620
+ const n = this.GetToken()
621
+ if (n.getType() === TokenType.Oper && n.getValue() === '(') {
622
+ const name = nameToken.getValue()
623
+ if (name === 'each') {
624
+ objExp = this.For(objExp)
625
+ } else {
626
+ objExp = this.MethodCall(name, objExp)
627
+ }
628
+ } else {
629
+ this.tokens.push(n)
630
+ const pi = nameToken.getValue()
631
+ objExp = Expression.Property(objExp, pi, this.pos)
632
+ objExp = this.ArrayIndex(objExp)
633
+ }
634
+ t = this.GetToken()
635
+ }
636
+ this.tokens.push(t)
637
+
638
+ return objExp
639
+ }
640
+
641
+ /**
642
+ * Array index parsing with optional condition
643
+ */
644
+ ArrayIndex (objExp) {
645
+ let n = this.GetToken()
646
+ if (n.getType() === TokenType.Oper && n.getValue() === '[') {
647
+ const exp = this.Exp()
648
+ n = this.GetToken()
649
+ if (n.getType() !== TokenType.Oper || n.getValue() !== ']') {
650
+ throw new Error(this.GetExceptionMessage("缺少']'"))
651
+ }
652
+ return Expression.ArrayIndex(objExp, exp, this.SOURCE, this.pos)
653
+ }
654
+ this.tokens.push(n)
655
+ return objExp
656
+ }
657
+
658
+ /**
659
+ * For loop handling
660
+ */
661
+ For (obj) {
662
+ const exp = this.CommaExp()
663
+ const t = this.GetToken()
664
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ')') {
665
+ throw new Error(this.GetExceptionMessage('函数调用括号不匹配'))
666
+ }
667
+ return Expression.For(obj, exp, this.SOURCE, this.pos)
668
+ }
669
+
670
+ /**
671
+ * Method call handling with parameters
672
+ */
673
+ MethodCall (name, obj) {
674
+ let t = this.GetToken()
675
+ if (t.getType() === TokenType.Oper && t.getValue() === ')') {
676
+ const ps = []
677
+ return Expression.Call(obj, name, ps, this.pos)
678
+ }
679
+
680
+ this.tokens.push(t)
681
+ const ps = this.Params()
682
+ t = this.GetToken()
683
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ')') {
684
+ throw new Error(this.GetExceptionMessage('函数调用括号不匹配'))
685
+ }
686
+
687
+ return Expression.Call(obj, name, ps, this.pos)
688
+ }
689
+
690
+ /**
691
+ * Function parameter list handling
692
+ */
693
+ Params () {
694
+ const ps = []
695
+ let name = this.paramName()
696
+ let exp = this.Exp()
697
+ this.procParam(ps, exp, name)
698
+ let t = this.GetToken()
699
+ while (t.getType() === TokenType.Oper && t.getValue() === ',') {
700
+ name = this.paramName()
701
+ exp = this.Exp()
702
+ this.procParam(ps, exp, name)
703
+ t = this.GetToken()
704
+ }
705
+ this.tokens.push(t)
706
+ return ps
707
+ }
708
+
709
+ /**
710
+ * Parse parameter name
711
+ */
712
+ paramName () {
713
+ const t = this.GetToken()
714
+ if (t.getType() === TokenType.Identy) {
715
+ const t1 = this.GetToken()
716
+ if (t1.getValue() === ':') {
717
+ return t.getValue()
718
+ } else {
719
+ this.tokens.push(t)
720
+ this.tokens.push(t1)
721
+ return ''
722
+ }
723
+ } else {
724
+ this.tokens.push(t)
725
+ return ''
726
+ }
727
+ }
728
+
729
+ /**
730
+ * Process parameters, especially if it contains the "data" object
731
+ */
732
+ procParam (ps, exp, name) {
733
+ const delegate = this.createDelegate(exp)
734
+ if (delegate.containsKey('data')) {
735
+ ps.push(Expression.Constant(delegate, this.pos))
736
+ } else {
737
+ ps.push(Expression.Param(exp, name, this.pos))
738
+ }
739
+ }
740
+
741
+ /**
742
+ * Get exception message with position information
743
+ */
744
+ GetExceptionMessage (msg) {
745
+ const result = this.SOURCE.substring(0, this.pos) + ' <- ' + this.SOURCE.substring(this.pos)
746
+ return `${msg}:\n${result}`
747
+ }
748
+
749
+ GetToken () {
750
+ // If there are tokens in the queue, return the last one saved
751
+ if (this.tokens.length > 0) {
752
+ return this.tokens.shift()
753
+ }
754
+
755
+ const sPos = this.pos
756
+ let hasKeyword = this.pos < this.SOURCE_LENGTH
757
+ let value = null
758
+
759
+ if (hasKeyword) {
760
+ value = this.SOURCE.charAt(this.pos)
761
+ }
762
+
763
+ // If it's '{', save the previous state and change to non-string state
764
+ if (hasKeyword && value === '{') {
765
+ this.inStrings.push(this.inString)
766
+ this.inString = false
767
+ const str = this.SOURCE.substring(this.pos, this.pos + 1)
768
+ this.pos += 1
769
+ return new Token(TokenType.Oper, str, sPos)
770
+ }
771
+
772
+ // If in string state, process the string
773
+ if (this.inString) {
774
+ const startPos = this.pos
775
+ while (hasKeyword && value !== '{' && value !== '}' && value !== '"') {
776
+ if (value === '\\') {
777
+ const nextStrValue = this.SOURCE.charAt(this.pos + 1)
778
+ if (this.pos + 1 < this.SOURCE_LENGTH && ['{', '}', '"', '\\'].includes(nextStrValue)) {
779
+ this.pos++
780
+ } else {
781
+ break
782
+ }
783
+ }
784
+ this.pos++
785
+ if (this.pos < this.SOURCE_LENGTH) {
786
+ value = this.SOURCE.charAt(this.pos)
787
+ } else {
788
+ hasKeyword = false
789
+ }
790
+ }
791
+ if (!(hasKeyword && value === '{')) {
792
+ this.inString = this.inStrings.pop()
793
+ }
794
+ const t = new Token(TokenType.String, this.SOURCE.substring(startPos, this.pos)
795
+ .replace('\\$', '$')
796
+ .replace('\\{', '{')
797
+ .replace('\\}', '}')
798
+ .replace(/\\"/g, '"')
799
+ .replace('\\\\', '\\'), sPos)
800
+
801
+ if (hasKeyword && value === '"') {
802
+ this.pos++
803
+ }
804
+ return t
805
+ }
806
+
807
+ // Skip whitespace and comments
808
+ while (hasKeyword && (value === ' ' || value === '\n' || value === '\t' || (this.pos < this.SOURCE_LENGTH - 2 && value === '/' && this.SOURCE.charAt(this.pos + 1) === '/'))) {
809
+ if (value !== ' ' && value !== '\n' && value !== '\t') {
810
+ this.pos += 2
811
+ if (this.pos < this.SOURCE_LENGTH) {
812
+ value = this.SOURCE.charAt(this.pos)
813
+ } else {
814
+ hasKeyword = false
815
+ }
816
+ while (hasKeyword && value !== '\n') {
817
+ this.pos++
818
+ if (this.pos < this.SOURCE_LENGTH) {
819
+ value = this.SOURCE.charAt(this.pos)
820
+ } else {
821
+ hasKeyword = false
822
+ }
823
+ }
824
+ }
825
+ this.pos++
826
+ if (this.pos < this.SOURCE_LENGTH) {
827
+ value = this.SOURCE.charAt(this.pos)
828
+ } else {
829
+ hasKeyword = false
830
+ }
831
+ }
832
+
833
+ // If we are at the end of the source, return an "End" token
834
+ if (this.pos === this.SOURCE_LENGTH) {
835
+ return new Token(TokenType.End, null, sPos)
836
+ }
837
+
838
+ if (value !== null) {
839
+ // Handle number tokens
840
+ if (value >= '0' && value <= '9') {
841
+ const oldPos = this.pos
842
+ while (hasKeyword && value >= '0' && value <= '9') {
843
+ this.pos++
844
+ if (this.pos < this.SOURCE_LENGTH) {
845
+ value = this.SOURCE.charAt(this.pos)
846
+ } else {
847
+ hasKeyword = false
848
+ }
849
+ }
850
+
851
+ if (hasKeyword && value === '.') {
852
+ do {
853
+ this.pos++
854
+ if (this.pos < this.SOURCE_LENGTH) {
855
+ value = this.SOURCE.charAt(this.pos)
856
+ } else {
857
+ hasKeyword = false
858
+ }
859
+ } while (hasKeyword && value >= '0' && value <= '9')
860
+ const str = this.SOURCE.substring(oldPos, this.pos)
861
+ return new Token(TokenType.Double, parseFloat(str), sPos)
862
+ } else {
863
+ const str = this.SOURCE.substring(oldPos, this.pos)
864
+ return new Token(TokenType.Int, parseInt(str, 10), sPos)
865
+ }
866
+ } else if ((value >= 'a' && value <= 'z') || (value >= 'A' && value <= 'Z') || value === '_' || value === '$' || /[\u4e00-\u9fa5]/.test(value)) {
867
+ const oldPos = this.pos
868
+ while (hasKeyword && ((value >= 'a' && value <= 'z') || (value >= 'A' && value <= 'Z') || (value >= '0' && value <= '9') || value === '_' || value === '$' || /[\u4e00-\u9fa5]/.test(value))) {
869
+ this.pos++
870
+ if (this.pos < this.SOURCE_LENGTH) {
871
+ value = this.SOURCE.charAt(this.pos)
872
+ } else {
873
+ hasKeyword = false
874
+ }
875
+ }
876
+ const str = this.SOURCE.substring(oldPos, this.pos)
877
+ switch (str) {
878
+ case 'false':
879
+ case 'true':
880
+ return new Token(TokenType.Bool, Boolean(str), sPos)
881
+ case 'null':
882
+ return new Token(TokenType.Null, null, sPos)
883
+ default:
884
+ return new Token(TokenType.Identy, str, sPos)
885
+ }
886
+ } else if ((value === '&' && this.SOURCE.charAt(this.pos + 1) === '&') || (value === '|' && this.SOURCE.charAt(this.pos + 1) === '|')) {
887
+ const str = this.SOURCE.substring(this.pos, this.pos + 2)
888
+ this.pos += 2
889
+ return new Token(TokenType.Oper, str, sPos)
890
+ } else if (['+', '-', '*', '/', '%', '>', '!'].includes(value)) {
891
+ let str = ''
892
+ if (this.SOURCE.charAt(this.pos + 1) === '=') {
893
+ str = this.SOURCE.substring(this.pos, this.pos + 2)
894
+ this.pos += 2
895
+ } else {
896
+ str = this.SOURCE.substring(this.pos, this.pos + 1)
897
+ this.pos += 1
898
+ }
899
+ return new Token(TokenType.Oper, str, sPos)
900
+ } else if (value === '<') {
901
+ // 处理 <- (赋值运算符) 和 <=, <> 等
902
+ let str = ''
903
+ const nextChar = this.SOURCE.charAt(this.pos + 1)
904
+ if (nextChar === '-' || nextChar === '=' || nextChar === '>') {
905
+ str = this.SOURCE.substring(this.pos, this.pos + 2)
906
+ this.pos += 2
907
+ } else {
908
+ str = this.SOURCE.substring(this.pos, this.pos + 1)
909
+ this.pos += 1
910
+ }
911
+ return new Token(TokenType.Oper, str, sPos)
912
+ } else if (value === '=') {
913
+ let str
914
+ if (this.SOURCE.charAt(this.pos + 1) === '=' || this.SOURCE.charAt(this.pos + 1) === '>') {
915
+ str = this.SOURCE.substring(this.pos, this.pos + 2)
916
+ this.pos += 2
917
+ } else {
918
+ str = this.SOURCE.substring(this.pos, this.pos + 1)
919
+ this.pos += 1
920
+ }
921
+ return new Token(TokenType.Oper, str, sPos)
922
+ } else if ('()[],;.:@{}"'.includes(value)) {
923
+ if (value === '"') {
924
+ this.inStrings.push(false)
925
+ this.inString = true
926
+ } else if ((value === '{' || value === '}') && this.inStrings.length) {
927
+ if (value === '{') {
928
+ this.inStrings.push(false)
929
+ this.inString = false
930
+ } else {
931
+ this.inString = this.inStrings.pop()
932
+ }
933
+ }
934
+ const str = this.SOURCE.substring(this.pos, this.pos + 1)
935
+ this.pos += 1
936
+ return new Token(TokenType.Oper, str, sPos)
937
+ } else {
938
+ throw new Error(`Invalid token: '${value}'`)
939
+ }
940
+ }
941
+
942
+ throw new Error('Unknown error while parsing.')
943
+ }
944
+ }