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,931 @@
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
+ if (t.getType() !== TokenType.Oper || t.getValue() !== '=') {
121
+ this.pos = firstPos
122
+ this.tokens.length = 0
123
+ this.inString = false
124
+ return this.Exp()
125
+ }
126
+
127
+ const exp = this.Exp()
128
+
129
+ // 如果是属性赋值
130
+ if (objExp.type === ExpressionType.Property) {
131
+ // 从属性Expression中获取对象及属性名
132
+ const name = objExp.value
133
+ objExp = objExp.children[0]
134
+ return Expression.Assign(objExp, exp, name, this.pos)
135
+ } else {
136
+ // Identity 变量赋值
137
+ return Expression.Assign(null, exp, objExp.value, this.pos)
138
+ }
139
+ }
140
+
141
+ Exp () {
142
+ const v = this.Logic()
143
+
144
+ // 是':',表示条件,否则直接返回单结果
145
+ let t = this.GetToken()
146
+ if (t.getType() === TokenType.Oper && t.getValue() === ':') {
147
+ // 第一项转换
148
+ const result = this.Logic()
149
+
150
+ // 下一个是",",继续读取下一个条件结果串,由于是右结合,只能采用递归
151
+ t = this.GetToken()
152
+ if (t.getType() === TokenType.Oper && t.getValue() === ',') {
153
+ // 第二项转换
154
+ const sExp = this.Exp()
155
+ // 返回
156
+ return Expression.Condition(v, result, sExp, this.SOURCE, this.pos)
157
+ } else {
158
+ throw new Error(this.GetExceptionMessage('必须有默认值!'))
159
+ }
160
+ } else {
161
+ this.tokens.push(t) // Put the token back
162
+ return v
163
+ }
164
+ }
165
+
166
+ Logic () {
167
+ let t = this.GetToken()
168
+
169
+ // !表达式
170
+ const hasNot = t.getType() === TokenType.Oper && t.getValue() === '!'
171
+ if (!hasNot) {
172
+ this.tokens.push(t) // Put the token back if it's not '!'
173
+ }
174
+
175
+ let v = this.Compare()
176
+ if (hasNot) {
177
+ v = Expression.Not(v, this.SOURCE, this.pos)
178
+ }
179
+
180
+ t = this.GetToken()
181
+ while (t.getType() === TokenType.Oper && (t.getValue() === '&&' || t.getValue() === '||')) {
182
+ // 第二项转换
183
+ const exp = this.Logic()
184
+
185
+ // 执行
186
+ if (t.getValue() === '&&') {
187
+ v = Expression.And(v, exp, this.SOURCE, this.pos)
188
+ } else {
189
+ v = Expression.Or(v, exp, this.SOURCE, this.pos)
190
+ }
191
+
192
+ t = this.GetToken()
193
+ }
194
+
195
+ this.tokens.push(t) // Put the token back
196
+ return v
197
+ }
198
+
199
+ Compare () {
200
+ const left = this.Math()
201
+ const t = this.GetToken()
202
+
203
+ if (t.getType() === TokenType.Oper && (
204
+ t.getValue() === '>' || t.getValue() === '>=' ||
205
+ t.getValue() === '<' || t.getValue() === '<=' || t.getValue() === '=>')) {
206
+ if (t.getValue() === '=>') {
207
+ this.tokens.push(t) // Push back the token for lambda handling
208
+ return this.Lambda()
209
+ }
210
+
211
+ const rExp = this.Math()
212
+
213
+ switch (t.getValue()) {
214
+ case '>':
215
+ return Expression.GreaterThan(left, rExp, this.SOURCE, this.pos)
216
+ case '>=':
217
+ return Expression.GreaterThanOrEqual(left, rExp, this.SOURCE, this.pos)
218
+ case '<':
219
+ return Expression.LessThan(left, rExp, this.SOURCE, this.pos)
220
+ case '<=':
221
+ return Expression.LessThanOrEqual(left, rExp, this.SOURCE, this.pos)
222
+ }
223
+ } else if (t.getType() === TokenType.Oper && (
224
+ t.getValue() === '==' || t.getValue() === '!=')) {
225
+ const rExp = this.Math()
226
+
227
+ // 相等比较
228
+ if (t.getValue() === '==') {
229
+ return Expression.Equal(left, rExp, this.SOURCE, this.pos)
230
+ } else {
231
+ return Expression.NotEqual(left, rExp, this.SOURCE, this.pos)
232
+ }
233
+ }
234
+
235
+ // 返回当前的表达式结果
236
+ this.tokens.push(t) // Push the token back
237
+ return left
238
+ }
239
+
240
+ Math () {
241
+ let v = this.Mul()
242
+ let t = this.GetToken()
243
+
244
+ while (t.getType() === TokenType.Oper && (t.getValue() === '+' || t.getValue() === '-')) {
245
+ // 转换操作数2为数字
246
+ const r = this.Mul()
247
+
248
+ // 开始运算
249
+ if (t.getValue() === '+') {
250
+ v = Expression.Add(v, r, this.SOURCE, this.pos)
251
+ } else {
252
+ v = Expression.Subtract(v, r, this.SOURCE, this.pos)
253
+ }
254
+
255
+ t = this.GetToken()
256
+ }
257
+
258
+ this.tokens.push(t) // Push the token back
259
+ return v
260
+ }
261
+
262
+ Lambda () {
263
+ let t = this.GetToken()
264
+ if (t.getValue() !== '=>' || t.getValue() == null) {
265
+ throw new Error(this.GetExceptionMessage('lambda必须以=>开始'))
266
+ }
267
+
268
+ t = this.GetToken()
269
+ if (t.getValue() !== '{' || t.getValue() == null) {
270
+ throw new Error(this.GetExceptionMessage('lambda必须以{开始'))
271
+ }
272
+
273
+ // 取lambda中的表达式
274
+ const exp = this.CommaExp()
275
+
276
+ t = this.GetToken()
277
+ if (t.getValue() !== '}' || t.getValue() == null) {
278
+ throw new Error(this.GetExceptionMessage('lambda必须以}结束'))
279
+ }
280
+
281
+ return Expression.Lambda(exp, this.pos)
282
+ }
283
+
284
+ Mul () {
285
+ let v = this.UnarySub()
286
+ let t = this.GetToken()
287
+
288
+ while (t.getType() === TokenType.Oper && (t.getValue() === '*' || t.getValue() === '/' || t.getValue() === '%')) {
289
+ // Convert the second operand to a number
290
+ const r = this.UnarySub()
291
+
292
+ // Perform the operation
293
+ if (t.getValue() === '*') {
294
+ v = Expression.Multiply(v, r, this.SOURCE, this.pos)
295
+ } else if (t.getValue() === '/') {
296
+ v = Expression.Divide(v, r, this.SOURCE, this.pos)
297
+ } else {
298
+ v = Expression.Modulo(v, r, this.SOURCE, this.pos)
299
+ }
300
+
301
+ t = this.GetToken()
302
+ }
303
+
304
+ this.tokens.push(t)
305
+ return v
306
+ }
307
+
308
+ UnarySub () {
309
+ const t = this.GetToken()
310
+ if (t.getType() === TokenType.Oper && t.getValue() === '-') {
311
+ const r = this.Item()
312
+ return Expression.Subtract(Expression.Constant(0, this.pos), r, this.SOURCE, this.pos)
313
+ }
314
+ this.tokens.push(t) // Push the token back into the queue
315
+ return this.Item()
316
+ }
317
+
318
+ Item () {
319
+ const objName = ''
320
+ // 获取对象表达式
321
+ let objExp = this.ItemHead(objName)
322
+ // 获取对象路径表达式
323
+ objExp = this.ObjectPath(objExp)
324
+ return objExp
325
+ }
326
+
327
+ ItemHead (name) {
328
+ let t = this.GetToken()
329
+
330
+ if (t.getType() === TokenType.Oper && t.getValue() === '(') {
331
+ const result = this.CommaExp()
332
+ t = this.GetToken()
333
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ')') {
334
+ throw new Error(this.GetExceptionMessage('括号不匹配'))
335
+ }
336
+ return result
337
+ } else if (t.getType() === TokenType.Oper && t.getValue() === '{') {
338
+ // JSON object
339
+ return this.Json()
340
+ } else if (t.getType() === TokenType.Oper && t.getValue() === '[') {
341
+ // JSON array
342
+ return this.JsonArray()
343
+ } else if (t.getType() === TokenType.Oper && t.getValue() === '"') {
344
+ // String concatenation sequence
345
+ return this.StringUnion()
346
+ } else if (t.getType() === TokenType.Int || t.getType() === TokenType.Double || t.getType() === TokenType.Bool) {
347
+ return Expression.Constant(t.getValue(), this.pos)
348
+ } else if (t.getType() === TokenType.Identy) {
349
+ const objName = t.getValue()
350
+
351
+ switch (objName) {
352
+ case 'return':
353
+ return Expression.Return(this.Exp(), this.pos)
354
+ case 'try':
355
+ this.tokens.push(t) // Revert the token back to the queue
356
+ return this.Try()
357
+ case 'throw':
358
+ return Expression.Throw(this.Exp(), this.pos)
359
+ case 'validate':
360
+ return this.Validate()
361
+ case 'assert':
362
+ return Expression.Assert(this.Exp(), this.pos)
363
+ case 'break':
364
+ return Expression.Break(this.pos, undefined)
365
+ case 'continue':
366
+ return Expression.Continue(this.pos, undefined)
367
+ }
368
+
369
+ // Return the object name
370
+ name += objName
371
+ // Process the object name
372
+ return this.ObjectName(objName)
373
+ } else if (t.getType() === TokenType.Null) {
374
+ return Expression.Constant(null, this.pos)
375
+ }
376
+
377
+ throw new Error(this.GetExceptionMessage('单词类型错误:' + t.getType()))
378
+ }
379
+
380
+ /**
381
+ * TryCatch := try {expression} (catch(Exception类 名){表达式})* finally{表达式}?
382
+ */
383
+ Try () {
384
+ let t = this.GetToken()
385
+ if (t.getValue() !== 'try') {
386
+ throw new Error(this.GetExceptionMessage('try-catch必须以try开始'))
387
+ }
388
+
389
+ t = this.GetToken()
390
+ if (t.getValue() !== '{') {
391
+ throw new Error(this.GetExceptionMessage('try块必须以{开始'))
392
+ }
393
+
394
+ // Get the expression inside the try block
395
+ const tryExp = this.CommaExp()
396
+
397
+ t = this.GetToken()
398
+ if (t.getValue() !== '}') {
399
+ throw new Error(this.GetExceptionMessage('try块必须以}结束'))
400
+ }
401
+
402
+ // Handle the catch part
403
+ const catches = this.Catch()
404
+
405
+ // Handle finally
406
+ let finallyExp
407
+ t = this.GetToken()
408
+ if (t.getValue()) {
409
+ if (t.getValue() === 'finally') {
410
+ t = this.GetToken()
411
+ if (t.getValue() !== '{') {
412
+ throw new Error(this.GetExceptionMessage('finally块必须以{开始'))
413
+ }
414
+
415
+ // Get the expression inside the finally block
416
+ finallyExp = this.CommaExp()
417
+ t = this.GetToken()
418
+ if (t.getValue() !== '}') {
419
+ throw new Error(this.GetExceptionMessage('finally块必须以}结束'))
420
+ }
421
+ t = this.GetToken()
422
+ }
423
+ }
424
+
425
+ this.tokens.push(t)
426
+
427
+ // Return the exception handling expression
428
+ return Expression.Try(tryExp, catches, this.pos, finallyExp)
429
+ }
430
+
431
+ /**
432
+ * catch部分处理
433
+ */
434
+ Catch () {
435
+ const result = []
436
+ let t = this.GetToken()
437
+
438
+ while (t.getValue() === 'catch') {
439
+ t = this.GetToken()
440
+ if (t.getValue() !== '(') {
441
+ throw new Error(this.GetExceptionMessage('catch块参数必须以(开始'))
442
+ }
443
+
444
+ // Get the class name
445
+ t = this.GetToken()
446
+ const className = t.getValue()
447
+
448
+ // Get the variable name
449
+ t = this.GetToken()
450
+ const varName = t.getValue()
451
+
452
+ t = this.GetToken()
453
+ if (t.getValue() !== ')') {
454
+ throw new Error(this.GetExceptionMessage('catch块参数必须以)结束'))
455
+ }
456
+
457
+ // Get the opening curly brace
458
+ t = this.GetToken()
459
+ if (t.getValue() !== '{') {
460
+ throw new Error(this.GetExceptionMessage('catch块必须以{开始'))
461
+ }
462
+
463
+ // Get the expression inside the catch block
464
+ const catchExp = this.CommaExp()
465
+ result.push(Expression.Catch(className, varName, catchExp, this.pos))
466
+
467
+ // Get the closing curly brace
468
+ t = this.GetToken()
469
+ if (t.getValue() !== '}') {
470
+ throw new Error(this.GetExceptionMessage('catch块必须以}结束'))
471
+ }
472
+
473
+ // Get the next token
474
+ t = this.GetToken()
475
+ }
476
+
477
+ this.tokens.push(t)
478
+ return result
479
+ }
480
+
481
+ /**
482
+ * Validate block handling
483
+ */
484
+ Validate () {
485
+ const t = this.GetToken()
486
+ if (t.getValue() !== '{') {
487
+ throw new Error(this.GetExceptionMessage('validate只接收Json对象'))
488
+ }
489
+
490
+ // Get the expression in the validate block
491
+ const exp = this.Json()
492
+
493
+ // Return Validate processing expression
494
+ return Expression.Validate(exp, this.pos)
495
+ }
496
+
497
+ /**
498
+ * JSON Object ::= {} | {propertyName: propertyValue, propertyName: propertyValue}
499
+ */
500
+ Json () {
501
+ const children = []
502
+
503
+ let t = this.GetToken()
504
+ // Empty object, return directly
505
+ if (t.getType() === TokenType.Oper && t.getValue() === '}') {
506
+ return Expression.Json(children, this.pos)
507
+ }
508
+
509
+ this.tokens.push(t)
510
+ children.push(this.Attr())
511
+ t = this.GetToken()
512
+
513
+ // If it's a comma, continue checking the next property
514
+ while (t.getType() === TokenType.Oper && t.getValue() === ',') {
515
+ const nextT = this.GetToken()
516
+ if (nextT.getType() === TokenType.Oper && nextT.getValue() === '}') {
517
+ t = nextT
518
+ break
519
+ }
520
+ this.tokens.push(nextT)
521
+ children.push(this.Attr())
522
+ t = this.GetToken()
523
+ }
524
+
525
+ if (t.getType() !== TokenType.Oper || t.getValue() !== '}') {
526
+ throw new Error(this.GetExceptionMessage('JSON对象构建错误'))
527
+ }
528
+
529
+ return Expression.Json(children, this.pos)
530
+ }
531
+
532
+ /**
533
+ * JSON Array ::= []
534
+ */
535
+ JsonArray () {
536
+ let t = this.GetToken()
537
+ // Empty array: use Array node so each evaluation returns a new [], not a shared Constant
538
+ if (t.getType() === TokenType.Oper && t.getValue() === ']') {
539
+ return Expression.Array([], this.pos)
540
+ }
541
+
542
+ // Loop to get array contents
543
+ this.tokens.push(t)
544
+ const ps = this.Params()
545
+ t = this.GetToken()
546
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ']') {
547
+ throw new Error(this.GetExceptionMessage('JSON集合构建错误'))
548
+ }
549
+
550
+ return Expression.Array(ps, this.pos)
551
+ }
552
+
553
+ /**
554
+ * Attribute-Value Pair ::= propertyName: propertyValue
555
+ */
556
+ Attr () {
557
+ const name = this.GetToken()
558
+ let value
559
+ if (name.getType() === TokenType.Identy) {
560
+ value = name.getValue()
561
+ } else if (name.getType() === TokenType.Oper && name.getValue() === '"') {
562
+ const expression = this.StringUnion().children[1]
563
+ value = expression.value
564
+ } else {
565
+ throw new Error(this.GetExceptionMessage('JSON对象的key必须是属性名或字符串'))
566
+ }
567
+
568
+ const t = this.GetToken()
569
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ':') {
570
+ throw new Error(this.GetExceptionMessage('JSON构建错误'))
571
+ }
572
+
573
+ const exp = this.Exp()
574
+ return Expression.Attr(value, exp, this.pos)
575
+ }
576
+
577
+ /**
578
+ * Parse string concatenation sequence
579
+ */
580
+ StringUnion () {
581
+ let exp = Expression.Constant('', this.pos)
582
+ let t = this.GetToken()
583
+ // Object sequence
584
+ while ((t.getType() === TokenType.Oper && t.getValue() === '{') || t.getType() === TokenType.String) {
585
+ // If it's a string, return the concatenated result
586
+ if (t.getType() === TokenType.String) {
587
+ exp = Expression.Concat(exp, Expression.Constant(t.getValue(), this.pos), this.SOURCE, this.pos)
588
+ } else {
589
+ // Handle content inside the {}
590
+ const objExp = this.Exp()
591
+ t = this.GetToken()
592
+ if (t.getType() !== TokenType.Oper || t.getValue() !== '}') {
593
+ throw new Error(this.GetExceptionMessage("缺少'}'"))
594
+ }
595
+ // String concatenation
596
+ exp = Expression.Concat(exp, objExp, this.SOURCE, this.pos)
597
+ }
598
+ t = this.GetToken()
599
+ }
600
+ this.tokens.push(t)
601
+ return exp
602
+ }
603
+
604
+ /**
605
+ * Get object and object expression by name
606
+ */
607
+ ObjectName (objName) {
608
+ return Expression.Identity(objName, this.pos)
609
+ }
610
+
611
+ /**
612
+ * Object path parsing, handles method calls, properties, and array indices
613
+ */
614
+ ObjectPath (inExp) {
615
+ let objExp = this.ArrayIndex(inExp)
616
+ let t = this.GetToken()
617
+ while (t.getType() === TokenType.Oper && t.getValue() === '.') {
618
+ const nameToken = this.GetToken()
619
+ const n = this.GetToken()
620
+ if (n.getType() === TokenType.Oper && n.getValue() === '(') {
621
+ const name = nameToken.getValue()
622
+ if (name === 'each') {
623
+ objExp = this.For(objExp)
624
+ } else {
625
+ objExp = this.MethodCall(name, objExp)
626
+ }
627
+ } else {
628
+ this.tokens.push(n)
629
+ const pi = nameToken.getValue()
630
+ objExp = Expression.Property(objExp, pi, this.pos)
631
+ objExp = this.ArrayIndex(objExp)
632
+ }
633
+ t = this.GetToken()
634
+ }
635
+ this.tokens.push(t)
636
+
637
+ return objExp
638
+ }
639
+
640
+ /**
641
+ * Array index parsing with optional condition
642
+ */
643
+ ArrayIndex (objExp) {
644
+ let n = this.GetToken()
645
+ if (n.getType() === TokenType.Oper && n.getValue() === '[') {
646
+ const exp = this.Exp()
647
+ n = this.GetToken()
648
+ if (n.getType() !== TokenType.Oper || n.getValue() !== ']') {
649
+ throw new Error(this.GetExceptionMessage("缺少']'"))
650
+ }
651
+ return Expression.ArrayIndex(objExp, exp, this.SOURCE, this.pos)
652
+ }
653
+ this.tokens.push(n)
654
+ return objExp
655
+ }
656
+
657
+ /**
658
+ * For loop handling
659
+ */
660
+ For (obj) {
661
+ const exp = this.CommaExp()
662
+ const t = this.GetToken()
663
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ')') {
664
+ throw new Error(this.GetExceptionMessage('函数调用括号不匹配'))
665
+ }
666
+ return Expression.For(obj, exp, this.SOURCE, this.pos)
667
+ }
668
+
669
+ /**
670
+ * Method call handling with parameters
671
+ */
672
+ MethodCall (name, obj) {
673
+ let t = this.GetToken()
674
+ if (t.getType() === TokenType.Oper && t.getValue() === ')') {
675
+ const ps = []
676
+ return Expression.Call(obj, name, ps, this.pos)
677
+ }
678
+
679
+ this.tokens.push(t)
680
+ const ps = this.Params()
681
+ t = this.GetToken()
682
+ if (t.getType() !== TokenType.Oper || t.getValue() !== ')') {
683
+ throw new Error(this.GetExceptionMessage('函数调用括号不匹配'))
684
+ }
685
+
686
+ return Expression.Call(obj, name, ps, this.pos)
687
+ }
688
+
689
+ /**
690
+ * Function parameter list handling
691
+ */
692
+ Params () {
693
+ const ps = []
694
+ let name = this.paramName()
695
+ let exp = this.Exp()
696
+ this.procParam(ps, exp, name)
697
+ let t = this.GetToken()
698
+ while (t.getType() === TokenType.Oper && t.getValue() === ',') {
699
+ name = this.paramName()
700
+ exp = this.Exp()
701
+ this.procParam(ps, exp, name)
702
+ t = this.GetToken()
703
+ }
704
+ this.tokens.push(t)
705
+ return ps
706
+ }
707
+
708
+ /**
709
+ * Parse parameter name
710
+ */
711
+ paramName () {
712
+ const t = this.GetToken()
713
+ if (t.getType() === TokenType.Identy) {
714
+ const t1 = this.GetToken()
715
+ if (t1.getValue() === ':') {
716
+ return t.getValue()
717
+ } else {
718
+ this.tokens.push(t)
719
+ this.tokens.push(t1)
720
+ return ''
721
+ }
722
+ } else {
723
+ this.tokens.push(t)
724
+ return ''
725
+ }
726
+ }
727
+
728
+ /**
729
+ * Process parameters, especially if it contains the "data" object
730
+ */
731
+ procParam (ps, exp, name) {
732
+ const delegate = this.createDelegate(exp)
733
+ if (delegate.containsKey('data')) {
734
+ ps.push(Expression.Constant(delegate, this.pos))
735
+ } else {
736
+ ps.push(Expression.Param(exp, name, this.pos))
737
+ }
738
+ }
739
+
740
+ /**
741
+ * Get exception message with position information
742
+ */
743
+ GetExceptionMessage (msg) {
744
+ const result = this.SOURCE.substring(0, this.pos) + ' <- ' + this.SOURCE.substring(this.pos)
745
+ return `${msg}:\n${result}`
746
+ }
747
+
748
+ GetToken () {
749
+ // If there are tokens in the queue, return the last one saved
750
+ if (this.tokens.length > 0) {
751
+ return this.tokens.shift()
752
+ }
753
+
754
+ const sPos = this.pos
755
+ let hasKeyword = this.pos < this.SOURCE_LENGTH
756
+ let value = null
757
+
758
+ if (hasKeyword) {
759
+ value = this.SOURCE.charAt(this.pos)
760
+ }
761
+
762
+ // If it's '{', save the previous state and change to non-string state
763
+ if (hasKeyword && value === '{') {
764
+ this.inStrings.push(this.inString)
765
+ this.inString = false
766
+ const str = this.SOURCE.substring(this.pos, this.pos + 1)
767
+ this.pos += 1
768
+ return new Token(TokenType.Oper, str, sPos)
769
+ }
770
+
771
+ // If in string state, process the string
772
+ if (this.inString) {
773
+ const startPos = this.pos
774
+ while (hasKeyword && value !== '{' && value !== '}' && value !== '"') {
775
+ if (value === '\\') {
776
+ const nextStrValue = this.SOURCE.charAt(this.pos + 1)
777
+ if (this.pos + 1 < this.SOURCE_LENGTH && ['{', '}', '"', '\\'].includes(nextStrValue)) {
778
+ this.pos++
779
+ } else {
780
+ break
781
+ }
782
+ }
783
+ this.pos++
784
+ if (this.pos < this.SOURCE_LENGTH) {
785
+ value = this.SOURCE.charAt(this.pos)
786
+ } else {
787
+ hasKeyword = false
788
+ }
789
+ }
790
+ if (!(hasKeyword && value === '{')) {
791
+ this.inString = this.inStrings.pop()
792
+ }
793
+ const t = new Token(TokenType.String, this.SOURCE.substring(startPos, this.pos)
794
+ .replace('\\$', '$')
795
+ .replace('\\{', '{')
796
+ .replace('\\}', '}')
797
+ .replace(/\\"/g, '"')
798
+ .replace('\\\\', '\\'), sPos)
799
+
800
+ if (hasKeyword && value === '"') {
801
+ this.pos++
802
+ }
803
+ return t
804
+ }
805
+
806
+ // Skip whitespace and comments
807
+ while (hasKeyword && (value === ' ' || value === '\n' || value === '\t' || (this.pos < this.SOURCE_LENGTH - 2 && value === '/' && this.SOURCE.charAt(this.pos + 1) === '/'))) {
808
+ if (value !== ' ' && value !== '\n' && value !== '\t') {
809
+ this.pos += 2
810
+ if (this.pos < this.SOURCE_LENGTH) {
811
+ value = this.SOURCE.charAt(this.pos)
812
+ } else {
813
+ hasKeyword = false
814
+ }
815
+ while (hasKeyword && value !== '\n') {
816
+ this.pos++
817
+ if (this.pos < this.SOURCE_LENGTH) {
818
+ value = this.SOURCE.charAt(this.pos)
819
+ } else {
820
+ hasKeyword = false
821
+ }
822
+ }
823
+ }
824
+ this.pos++
825
+ if (this.pos < this.SOURCE_LENGTH) {
826
+ value = this.SOURCE.charAt(this.pos)
827
+ } else {
828
+ hasKeyword = false
829
+ }
830
+ }
831
+
832
+ // If we are at the end of the source, return an "End" token
833
+ if (this.pos === this.SOURCE_LENGTH) {
834
+ return new Token(TokenType.End, null, sPos)
835
+ }
836
+
837
+ if (value !== null) {
838
+ // Handle number tokens
839
+ if (value >= '0' && value <= '9') {
840
+ const oldPos = this.pos
841
+ while (hasKeyword && value >= '0' && value <= '9') {
842
+ this.pos++
843
+ if (this.pos < this.SOURCE_LENGTH) {
844
+ value = this.SOURCE.charAt(this.pos)
845
+ } else {
846
+ hasKeyword = false
847
+ }
848
+ }
849
+
850
+ if (hasKeyword && value === '.') {
851
+ do {
852
+ this.pos++
853
+ if (this.pos < this.SOURCE_LENGTH) {
854
+ value = this.SOURCE.charAt(this.pos)
855
+ } else {
856
+ hasKeyword = false
857
+ }
858
+ } while (hasKeyword && value >= '0' && value <= '9')
859
+ const str = this.SOURCE.substring(oldPos, this.pos)
860
+ return new Token(TokenType.Double, parseFloat(str), sPos)
861
+ } else {
862
+ const str = this.SOURCE.substring(oldPos, this.pos)
863
+ return new Token(TokenType.Int, parseInt(str, 10), sPos)
864
+ }
865
+ } else if ((value >= 'a' && value <= 'z') || (value >= 'A' && value <= 'Z') || value === '_' || value === '$' || /[\u4e00-\u9fa5]/.test(value)) {
866
+ const oldPos = this.pos
867
+ while (hasKeyword && ((value >= 'a' && value <= 'z') || (value >= 'A' && value <= 'Z') || (value >= '0' && value <= '9') || value === '_' || value === '$' || /[\u4e00-\u9fa5]/.test(value))) {
868
+ this.pos++
869
+ if (this.pos < this.SOURCE_LENGTH) {
870
+ value = this.SOURCE.charAt(this.pos)
871
+ } else {
872
+ hasKeyword = false
873
+ }
874
+ }
875
+ const str = this.SOURCE.substring(oldPos, this.pos)
876
+ switch (str) {
877
+ case 'false':
878
+ case 'true':
879
+ return new Token(TokenType.Bool, Boolean(str), sPos)
880
+ case 'null':
881
+ return new Token(TokenType.Null, null, sPos)
882
+ default:
883
+ return new Token(TokenType.Identy, str, sPos)
884
+ }
885
+ } else if ((value === '&' && this.SOURCE.charAt(this.pos + 1) === '&') || (value === '|' && this.SOURCE.charAt(this.pos + 1) === '|')) {
886
+ const str = this.SOURCE.substring(this.pos, this.pos + 2)
887
+ this.pos += 2
888
+ return new Token(TokenType.Oper, str, sPos)
889
+ } else if (['+', '-', '*', '/', '%', '>', '<', '!'].includes(value)) {
890
+ let str = ''
891
+ if (this.SOURCE.charAt(this.pos + 1) === '=') {
892
+ str = this.SOURCE.substring(this.pos, this.pos + 2)
893
+ this.pos += 2
894
+ } else {
895
+ str = this.SOURCE.substring(this.pos, this.pos + 1)
896
+ this.pos += 1
897
+ }
898
+ return new Token(TokenType.Oper, str, sPos)
899
+ } else if (value === '=') {
900
+ let str
901
+ if (this.SOURCE.charAt(this.pos + 1) === '=' || this.SOURCE.charAt(this.pos + 1) === '>') {
902
+ str = this.SOURCE.substring(this.pos, this.pos + 2)
903
+ this.pos += 2
904
+ } else {
905
+ str = this.SOURCE.substring(this.pos, this.pos + 1)
906
+ this.pos += 1
907
+ }
908
+ return new Token(TokenType.Oper, str, sPos)
909
+ } else if ('()[],;.:@{}"'.includes(value)) {
910
+ if (value === '"') {
911
+ this.inStrings.push(false)
912
+ this.inString = true
913
+ } else if ((value === '{' || value === '}') && this.inStrings.length) {
914
+ if (value === '{') {
915
+ this.inStrings.push(false)
916
+ this.inString = false
917
+ } else {
918
+ this.inString = this.inStrings.pop()
919
+ }
920
+ }
921
+ const str = this.SOURCE.substring(this.pos, this.pos + 1)
922
+ this.pos += 1
923
+ return new Token(TokenType.Oper, str, sPos)
924
+ } else {
925
+ throw new Error(`Invalid token: '${value}'`)
926
+ }
927
+ }
928
+
929
+ throw new Error('Unknown error while parsing.')
930
+ }
931
+ }