hqchart 1.1.12687 → 1.1.12706

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 (228) hide show
  1. package/lib/umychart.vue.js +94 -50
  2. package/package.json +15 -47
  3. package/src/jscommon/umychart.resource/js/codemirror/javascript.js +1 -1
  4. package/src/jscommon/umychart.uniapp.h5/umychart.uniapp.h5.js +409 -115
  5. package/src/jscommon/umychart.vue/umychart.vue.js +409 -115
  6. package/.babelrc +0 -6
  7. package/.vscode/settings.json +0 -4
  8. package/Makefile +0 -9
  9. package/README.md +0 -452
  10. package/index.js +0 -17
  11. package/postcss.config.js +0 -5
  12. package/src/index.html +0 -18
  13. package/src/jscommon/backup/announcement.png +0 -0
  14. package/src/jscommon/backup/announcement2.png +0 -0
  15. package/src/jscommon/backup/blocktrading.png +0 -0
  16. package/src/jscommon/backup/investor.png +0 -0
  17. package/src/jscommon/backup/pforecast.png +0 -0
  18. package/src/jscommon/backup/research.png +0 -0
  19. package/src/jscommon/backup/tradedetail.png +0 -0
  20. package/src/jscommon/backup/umychart - backup.js +0 -17631
  21. package/src/jscommon/backup/umychart.macro.js +0 -4
  22. package/src/jscommon/backup/umychart.macro.vue.js +0 -3
  23. package/src/jscommon/commonindextree.json +0 -92
  24. package/src/jscommon/index.html +0 -13
  25. package/src/jscommon/jschinamapdata.js +0 -3
  26. package/src/jscommon/umychart.NetworkFilterTest.js +0 -48803
  27. package/src/jscommon/umychart.aliYunnetwork.js +0 -47
  28. package/src/jscommon/umychart.cninfo.components/readme.txt +0 -1
  29. package/src/jscommon/umychart.complier.js +0 -25291
  30. package/src/jscommon/umychart.complier.node/umychart.complier.controller.js +0 -559
  31. package/src/jscommon/umychart.complier.node/umychart.complier.node.js +0 -7043
  32. package/src/jscommon/umychart.complier.node/umychart.data.node.js +0 -816
  33. package/src/jscommon/umychart.console.js +0 -12
  34. package/src/jscommon/umychart.deal.js +0 -1452
  35. package/src/jscommon/umychart.dragdiv.js +0 -48
  36. package/src/jscommon/umychart.index.data.js +0 -4132
  37. package/src/jscommon/umychart.js +0 -90257
  38. package/src/jscommon/umychart.keyboard.js +0 -1659
  39. package/src/jscommon/umychart.listctrl.js +0 -690
  40. package/src/jscommon/umychart.mind.js +0 -2203
  41. package/src/jscommon/umychart.network.js +0 -44
  42. package/src/jscommon/umychart.news.js +0 -823
  43. package/src/jscommon/umychart.node.build/buildall.bat +0 -1
  44. package/src/jscommon/umychart.node.build/umychart.node.bat +0 -1
  45. package/src/jscommon/umychart.node.build/umychart.node.export.js +0 -40
  46. package/src/jscommon/umychart.regressiontest.js +0 -400
  47. package/src/jscommon/umychart.report.js +0 -5803
  48. package/src/jscommon/umychart.scrollbar.js +0 -1345
  49. package/src/jscommon/umychart.stock.js +0 -4218
  50. package/src/jscommon/umychart.style.js +0 -618
  51. package/src/jscommon/umychart.testdata.js +0 -150
  52. package/src/jscommon/umychart.uniapp.build/buildall.bat +0 -1
  53. package/src/jscommon/umychart.uniapp.build/umychart.bat +0 -1
  54. package/src/jscommon/umychart.uniapp.build/umychart.export.js +0 -70
  55. package/src/jscommon/umychart.user.js +0 -137
  56. package/src/jscommon/umychart.version.js +0 -30
  57. package/src/jscommon/umychart.vue/umychart.aliYunnetwork.vue.js +0 -56
  58. package/src/jscommon/umychart.vue.build/buildall.bat +0 -4
  59. package/src/jscommon/umychart.vue.build/copy_codemirror.bat +0 -2
  60. package/src/jscommon/umychart.vue.build/umychart.aliYunnetwork.vue.export.js +0 -9
  61. package/src/jscommon/umychart.vue.build/umychart.dragdiv.bat +0 -1
  62. package/src/jscommon/umychart.vue.build/umychart.dragdiv.export.js +0 -6
  63. package/src/jscommon/umychart.vue.build/umychart.index.data.bat +0 -1
  64. package/src/jscommon/umychart.vue.build/umychart.index.data.export.js +0 -4
  65. package/src/jscommon/umychart.vue.build/umychart.listctrl.vue.export.js +0 -15
  66. package/src/jscommon/umychart.vue.build/umychart.regressiontest.vue.export.js +0 -7
  67. package/src/jscommon/umychart.vue.build/umychart.regressiontest.wechat.export.js +0 -12
  68. package/src/jscommon/umychart.vue.build/umychart.stock.bat +0 -1
  69. package/src/jscommon/umychart.vue.build/umychart.stock.vue.export.js +0 -16
  70. package/src/jscommon/umychart.vue.build/umychart.testdata.bat +0 -3
  71. package/src/jscommon/umychart.vue.build/umychart.testdata.vue.export.js +0 -7
  72. package/src/jscommon/umychart.vue.build/umychart.vue.bat +0 -8
  73. package/src/jscommon/umychart.vue.build/umychart.vue.export.js +0 -112
  74. package/src/jscommon/umychart.vue.components/empyt.vue +0 -51
  75. package/src/jscommon/umychart.vue.components/historydayline.vue +0 -240
  76. package/src/jscommon/umychart.vue.components/jsloader.adddialog.vue +0 -315
  77. package/src/jscommon/umychart.vue.components/jsloader.vue +0 -93
  78. package/src/jscommon/umychart.vue.components/jsvuecontainer.vue +0 -160
  79. package/src/jscommon/umychart.vue.components/jsvuecontainer2.0.vue +0 -391
  80. package/src/jscommon/umychart.vue.components/login.vue +0 -178
  81. package/src/jscommon/umychart.vue.components/queryContent.vue +0 -750
  82. package/src/jscommon/umychart.vue.components/readme.txt +0 -8
  83. package/src/jscommon/umychart.vue.components/searchsymbol.vue +0 -299
  84. package/src/jscommon/umychart.vue.components/simulatetrade.vue +0 -1471
  85. package/src/jscommon/umychart.vue.components/stockchart.vue +0 -343
  86. package/src/jscommon/umychart.vue.components/stockchartV2.vue +0 -195
  87. package/src/jscommon/umychart.vue.components/stockdeal.vue +0 -358
  88. package/src/jscommon/umychart.vue.components/stockdealcount.vue +0 -262
  89. package/src/jscommon/umychart.vue.components/stockdeallastest.vue +0 -316
  90. package/src/jscommon/umychart.vue.components/stockdrawtool.vue +0 -343
  91. package/src/jscommon/umychart.vue.components/stockfull.vue +0 -355
  92. package/src/jscommon/umychart.vue.components/stockinfo.demo.vue +0 -153
  93. package/src/jscommon/umychart.vue.components/stockinfo.vue +0 -685
  94. package/src/jscommon/umychart.vue.components/stockkline.demo.vue +0 -1904
  95. package/src/jscommon/umychart.vue.components/stockmultiorder.vue +0 -174
  96. package/src/jscommon/umychart.vue.components/stockmultiperiod.vue +0 -222
  97. package/src/jscommon/umychart.vue.components/stockorder.vue +0 -320
  98. package/src/jscommon/umychart.vue.components/stocktradeinfo.demo.vue +0 -250
  99. package/src/jscommon/umychart.vue.components/stocktradeinfo.vue +0 -1907
  100. package/src/jscommon/umychart.vue.components/test.vue +0 -0
  101. package/src/jscommon/umychart.wechat/getDate.wechat.js +0 -91
  102. package/src/jscommon/umychart.wechat/lighter.news.wechat.js +0 -262
  103. package/src/jscommon/umychart.wechat/readme.txt +0 -3
  104. package/src/jscommon/umychart.wechat/umychart.analyze.wechat.js +0 -551
  105. package/src/jscommon/umychart.wechat/umychart.apidraw.wechat.js +0 -126
  106. package/src/jscommon/umychart.wechat/umychart.bigV.wechat.js +0 -2510
  107. package/src/jscommon/umychart.wechat/umychart.chartframe.wechat.js +0 -2931
  108. package/src/jscommon/umychart.wechat/umychart.chartpaint.wechat.js +0 -9752
  109. package/src/jscommon/umychart.wechat/umychart.charttitle.wechat.js +0 -2023
  110. package/src/jscommon/umychart.wechat/umychart.complier.wechat.js +0 -14726
  111. package/src/jscommon/umychart.wechat/umychart.console.wechat.js +0 -8
  112. package/src/jscommon/umychart.wechat/umychart.coordinatedata.wechat.js +0 -3654
  113. package/src/jscommon/umychart.wechat/umychart.data.wechat.js +0 -2243
  114. package/src/jscommon/umychart.wechat/umychart.element.wechart.js +0 -132
  115. package/src/jscommon/umychart.wechat/umychart.explainer.wechat.js +0 -1077
  116. package/src/jscommon/umychart.wechat/umychart.extendchart.wechat.js +0 -1140
  117. package/src/jscommon/umychart.wechat/umychart.framesplit.wechat.js +0 -2247
  118. package/src/jscommon/umychart.wechat/umychart.hqIndexformula.wechat.js +0 -941
  119. package/src/jscommon/umychart.wechat/umychart.index.data.wechat.js +0 -3628
  120. package/src/jscommon/umychart.wechat/umychart.index.wechat.js +0 -4074
  121. package/src/jscommon/umychart.wechat/umychart.klineinfo.wechat.js +0 -836
  122. package/src/jscommon/umychart.wechat/umychart.markethot.js +0 -50
  123. package/src/jscommon/umychart.wechat/umychart.network.wechart.js +0 -62
  124. package/src/jscommon/umychart.wechat/umychart.news.wechat.js +0 -3568
  125. package/src/jscommon/umychart.wechat/umychart.regressiontest.wechat.js +0 -412
  126. package/src/jscommon/umychart.wechat/umychart.report.wechat.js +0 -3983
  127. package/src/jscommon/umychart.wechat/umychart.resource.wechat.js +0 -919
  128. package/src/jscommon/umychart.wechat/umychart.shareimage.wechat.js +0 -681
  129. package/src/jscommon/umychart.wechat/umychart.simulatetrade.wechat.js +0 -238
  130. package/src/jscommon/umychart.wechat/umychart.stock.wechat.js +0 -4035
  131. package/src/jscommon/umychart.wechat/umychart.style.wechat.js +0 -419
  132. package/src/jscommon/umychart.wechat/umychart.uniapp.canvas.helper.js +0 -99
  133. package/src/jscommon/umychart.wechat/umychart.user.wechat.js +0 -588
  134. package/src/jscommon/umychart.wechat/umychart.userlog.wechat.js +0 -240
  135. package/src/jscommon/umychart.wechat/umychart.vedio.wechat.js +0 -112
  136. package/src/jscommon/umychart.wechat/umychart.version.wechat.js +0 -36
  137. package/src/jscommon/umychart.wechat/umychart.wechat.3.0.js +0 -12051
  138. package/src/jscommon/umychart.wechat/umychart.wechat.js +0 -15460
  139. package/src/jscommon/umychart.worker.js +0 -114
  140. package/src/jscommon/umychart.ws.stock.js +0 -110
  141. package/src/jscommon/umychart_python/.vscode/launch.json +0 -15
  142. package/src/jscommon/umychart_python/__init__.py +0 -4
  143. package/src/jscommon/umychart_python/build.cmd +0 -2
  144. package/src/jscommon/umychart_python/setup.py +0 -25
  145. package/src/jscommon/umychart_python/umychart_cache_testcase.py +0 -165
  146. package/src/jscommon/umychart_python/umychart_complier_data.py +0 -781
  147. package/src/jscommon/umychart_python/umychart_complier_help.py +0 -175
  148. package/src/jscommon/umychart_python/umychart_complier_job.py +0 -193
  149. package/src/jscommon/umychart_python/umychart_complier_jsalgorithm.py +0 -4144
  150. package/src/jscommon/umychart_python/umychart_complier_jscomplier.py +0 -177
  151. package/src/jscommon/umychart_python/umychart_complier_jsexecute.py +0 -517
  152. package/src/jscommon/umychart_python/umychart_complier_jsparser.py +0 -864
  153. package/src/jscommon/umychart_python/umychart_complier_jssymboldata.py +0 -1238
  154. package/src/jscommon/umychart_python/umychart_complier_jssymboldata_cache.py +0 -146
  155. package/src/jscommon/umychart_python/umychart_complier_jssymboldata_json.py +0 -106
  156. package/src/jscommon/umychart_python/umychart_complier_pandas_help.py +0 -80
  157. package/src/jscommon/umychart_python/umychart_complier_scanner.py +0 -554
  158. package/src/jscommon/umychart_python/umychart_complier_testcase.py +0 -362
  159. package/src/jscommon/umychart_python/umychart_complier_util.py +0 -30
  160. package/src/jscommon/umychart_python/umychart_webtemplate.py +0 -131
  161. package/src/jscommon/umychart_python/updatehqchartweb.bat +0 -5
  162. package/src/jscommon/vendor.js +0 -2
  163. package/src/pages/block.list.demo.page/App.vue +0 -117
  164. package/src/pages/block.list.demo.page/index.js +0 -12
  165. package/src/pages/brushTool.demo.page/App.vue +0 -19
  166. package/src/pages/brushTool.demo.page/index.js +0 -12
  167. package/src/pages/container.demo.page/App.vue +0 -118
  168. package/src/pages/container.demo.page/index.js +0 -18
  169. package/src/pages/dataZoom.demo.page/App.vue +0 -265
  170. package/src/pages/dataZoom.demo.page/components/dataZoom.vue +0 -303
  171. package/src/pages/dataZoom.demo.page/index.js +0 -12
  172. package/src/pages/historydayline.demo.page/App.vue +0 -57
  173. package/src/pages/historydayline.demo.page/index.js +0 -12
  174. package/src/pages/hq.demo.page/App.vue +0 -163
  175. package/src/pages/hq.demo.page/index.js +0 -12
  176. package/src/pages/hqchart.black/App.vue +0 -90
  177. package/src/pages/hqchart.black/components/searchsymbol.vue +0 -299
  178. package/src/pages/hqchart.black/components/stockdrawtool.vue +0 -300
  179. package/src/pages/hqchart.black/components/stockfull.vue +0 -313
  180. package/src/pages/hqchart.black/components/stockinfo.vue +0 -428
  181. package/src/pages/hqchart.black/components/stockkline.demo.vue +0 -1652
  182. package/src/pages/hqchart.black/components/stocktradeinfo.vue +0 -1337
  183. package/src/pages/hqchart.black/index.js +0 -30
  184. package/src/pages/hqchart.black/router/candlestickChart.vue +0 -108
  185. package/src/pages/hqchart.black/router/pricePointsTable.vue +0 -294
  186. package/src/pages/hqchart.black/router/stockDeallas.vue +0 -417
  187. package/src/pages/hqchart.black/router/timeShareChart.vue +0 -108
  188. package/src/pages/hqchart.page/App.vue +0 -101
  189. package/src/pages/hqchart.page/index.js +0 -18
  190. package/src/pages/index/App.vue +0 -1408
  191. package/src/pages/index/index.js +0 -7
  192. package/src/pages/indexHq/App.vue +0 -110
  193. package/src/pages/indexHq/index.js +0 -18
  194. package/src/pages/login.demo.page/App.vue +0 -22
  195. package/src/pages/login.demo.page/index.js +0 -12
  196. package/src/pages/queryContent.demo.page/App.vue +0 -29
  197. package/src/pages/queryContent.demo.page/index.js +0 -18
  198. package/src/pages/ranking.black/App.vue +0 -199
  199. package/src/pages/ranking.black/index.js +0 -18
  200. package/src/pages/search.demo.page/App.vue +0 -28
  201. package/src/pages/search.demo.page/index.js +0 -12
  202. package/src/pages/simulatetrade.demo.page/app.vue +0 -121
  203. package/src/pages/simulatetrade.demo.page/index.js +0 -17
  204. package/src/pages/stockdeal.demo.page/App.vue +0 -63
  205. package/src/pages/stockdeal.demo.page/index.js +0 -19
  206. package/src/pages/stockdealcount.demo.page/App.vue +0 -37
  207. package/src/pages/stockdealcount.demo.page/index.js +0 -12
  208. package/src/pages/stockdeallastest.demo.page/App.vue +0 -74
  209. package/src/pages/stockdeallastest.demo.page/index.js +0 -18
  210. package/src/pages/stockinfo.demo.page/App.vue +0 -92
  211. package/src/pages/stockinfo.demo.page/index.html +0 -13
  212. package/src/pages/stockinfo.demo.page/index.js +0 -19
  213. package/src/pages/stockkline.demo.page/App.vue +0 -55
  214. package/src/pages/stockkline.demo.page/index.js +0 -18
  215. package/src/pages/stockmultiorder.demo.page/App.vue +0 -149
  216. package/src/pages/stockmultiorder.demo.page/index.js +0 -18
  217. package/src/pages/stockmultiperiod.demo.page/App.vue +0 -87
  218. package/src/pages/stockmultiperiod.demo.page/index.js +0 -18
  219. package/src/pages/stockorder.demo.page/App.vue +0 -69
  220. package/src/pages/stockorder.demo.page/index.js +0 -18
  221. package/src/pages/test/App.vue +0 -22
  222. package/src/pages/test/index.js +0 -7
  223. package/src/pages/tradeinfopage/app.vue +0 -40
  224. package/src/pages/tradeinfopage/index.js +0 -7
  225. package/src/pages/tradeinfopage/tradeinfo.html +0 -12
  226. package/src/utils/urlObj.js +0 -81
  227. package/src/vendor.js +0 -2
  228. package/webpack.config.js +0 -104
@@ -1,554 +0,0 @@
1
- # Copyright (c) 2018 jones
2
- #
3
- # http://www.apache.org/licenses/LICENSE-2.0
4
- #
5
- # 开源项目 https://github.com/jones2000/HQChart
6
- #
7
- # jones_2000@163.com
8
-
9
-
10
- #################################################################
11
- #
12
- #
13
- #
14
- ####################################################################
15
- import sys
16
- import unicodedata
17
- from collections import defaultdict
18
-
19
- from umychart_complier_util import xrange, unicode, uchr, uord
20
-
21
-
22
- class Messages:
23
- BadGetterArity = 'Getter must not have any formal parameters'
24
- BadSetterArity= 'Setter must have exactly one formal parameter'
25
- BadSetterRestParameter= 'Setter function argument must not be a rest parameter'
26
- ConstructorIsAsync= 'Class constructor may not be an async method'
27
- ConstructorSpecialMethod= 'Class constructor may not be an accessor'
28
- DeclarationMissingInitializer= 'Missing initializer in %0 declaration'
29
- DefaultRestParameter= 'Unexpected token ='
30
- DuplicateBinding= 'Duplicate binding %0'
31
- DuplicateConstructor= 'A class may only have one constructor'
32
- DuplicateProtoProperty= 'Duplicate __proto__ fields are not allowed in object literals'
33
- ForInOfLoopInitializer= '%0 loop variable declaration may not have an initializer'
34
- GeneratorInLegacyContext= 'Generator declarations are not allowed in legacy contexts'
35
- IllegalBreak= 'Illegal break statement'
36
- IllegalContinue= 'Illegal continue statement'
37
- IllegalExportDeclaration= 'Unexpected token'
38
- IllegalImportDeclaration= 'Unexpected token'
39
- IllegalLanguageModeDirective= 'Illegal \'use strict\' directive in function with non-simple parameter list'
40
- IllegalReturn= 'Illegal return statement'
41
- InvalidEscapedReservedWord= 'Keyword must not contain escaped characters'
42
- InvalidHexEscapeSequence= 'Invalid hexadecimal escape sequence'
43
- InvalidLHSInAssignment= 'Invalid left-hand side in assignment'
44
- InvalidLHSInForIn= 'Invalid left-hand side in for-in'
45
- InvalidLHSInForLoop= 'Invalid left-hand side in for-loop'
46
- InvalidModuleSpecifier= 'Unexpected token'
47
- InvalidRegExp= 'Invalid regular expression'
48
- LetInLexicalBinding= 'let is disallowed as a lexically bound name'
49
- MissingFromClause= 'Unexpected token'
50
- MultipleDefaultsInSwitch= 'More than one default clause in switch statement'
51
- NewlineAfterThrow= 'Illegal newline after throw'
52
- NoAsAfterImportNamespace= 'Unexpected token'
53
- NoCatchOrFinally= 'Missing catch or finally after try'
54
- ParameterAfterRestParameter= 'Rest parameter must be last formal parameter'
55
- Redeclaration= '%0 \'%1\' has already been declared'
56
- StaticPrototype= 'Classes may not have static property named prototype'
57
- StrictCatchVariable= 'Catch variable may not be eval or arguments in strict mode'
58
- StrictDelete= 'Delete of an unqualified identifier in strict mode.'
59
- StrictFunction= 'In strict mode code, functions can only be declared at top level or inside a block'
60
- StrictFunctionName= 'Function name may not be eval or arguments in strict mode'
61
- StrictLHSAssignment= 'Assignment to eval or arguments is not allowed in strict mode'
62
- StrictLHSPostfix= 'Postfix increment/decrement may not have eval or arguments operand in strict mode'
63
- StrictLHSPrefix= 'Prefix increment/decrement may not have eval or arguments operand in strict mode'
64
- StrictModeWith= 'Strict mode code may not include a with statement'
65
- StrictOctalLiteral= 'Octal literals are not allowed in strict mode.'
66
- StrictParamDupe= 'Strict mode function may not have duplicate parameter names'
67
- StrictParamName= 'Parameter name eval or arguments is not allowed in strict mode'
68
- StrictReservedWord= 'Use of future reserved word in strict mode'
69
- StrictVarName= 'Variable name may not be eval or arguments in strict mode'
70
- TemplateOctalLiteral= 'Octal literals are not allowed in template strings.'
71
- UnexpectedEOS= 'Unexpected end of input'
72
- UnexpectedIdentifier= 'Unexpected identifier'
73
- UnexpectedNumber= 'Unexpected number'
74
- UnexpectedReserved= 'Unexpected reserved word'
75
- UnexpectedString= 'Unexpected string'
76
- UnexpectedTemplate= 'Unexpected quasi %0'
77
- UnexpectedToken= 'Unexpected token %0'
78
- UnexpectedTokenIllegal= 'Unexpected token ILLEGAL'
79
- UnknownLabel= 'Undefined label \'%0\''
80
- UnterminatedRegExp= 'Invalid regular expression: missing /'
81
-
82
-
83
- # http://stackoverflow.com/questions/14245893/efficiently-list-all-characters-in-a-given-unicode-category
84
- U_CATEGORIES = defaultdict(list)
85
- for c in map(chr, range(sys.maxunicode + 1)):
86
- U_CATEGORIES[unicodedata.category(c)].append(c)
87
-
88
- UNICODE_LETTER = set(U_CATEGORIES['Lu'] + U_CATEGORIES['Ll'] +U_CATEGORIES['Lt'] + U_CATEGORIES['Lm'] +U_CATEGORIES['Lo'] + U_CATEGORIES['Nl'])
89
-
90
- UNICODE_OTHER_ID_START = set((
91
- # Other_ID_Start
92
- '\u1885', '\u1886', '\u2118', '\u212E', '\u309B', '\u309C',
93
- # New in Unicode 8.0
94
- '\u08B3', '\u0AF9', '\u13F8', '\u9FCD', '\uAB60', '\U00010CC0', '\U000108E0', '\U0002B820',
95
- # New in Unicode 9.0
96
- '\u1C80', '\U000104DB', '\U0001E922',
97
- '\U0001EE00', '\U0001EE06', '\U0001EE0A',
98
- ))
99
-
100
- UNICODE_OTHER_ID_CONTINUE = set((
101
- # Other_ID_Continue
102
- '\xB7', '\u0387', '\u1369', '\u136A', '\u136B', '\u136C',
103
- '\u136D', '\u136E', '\u136F', '\u1370', '\u1371', '\u19DA',
104
- # New in Unicode 8.0
105
- '\u08E3', '\uA69E', '\U00011730',
106
- # New in Unicode 9.0
107
- '\u08D4', '\u1DFB', '\uA8C5', '\U00011450',
108
- '\U0001EE03', '\U0001EE0B',
109
- ))
110
-
111
- UNICODE_COMBINING_MARK = set(U_CATEGORIES['Mn'] + U_CATEGORIES['Mc'])
112
- IDENTIFIER_START = UNICODE_LETTER.union(UNICODE_OTHER_ID_START).union(set(('$', '_', '\\')))
113
- UNICODE_CONNECTOR_PUNCTUATION = set(U_CATEGORIES['Pc'])
114
-
115
- DECIMAL_CONV = dict((c, n) for n, c in enumerate('0123456789'))
116
- OCTAL_CONV = dict((c, n) for n, c in enumerate('01234567'))
117
- HEX_CONV = dict((c, n) for n, c in enumerate('0123456789abcdef'))
118
- for n, c in enumerate('ABCDEF', 10):
119
- HEX_CONV[c] = n
120
-
121
- #空格
122
- WHITE_SPACE = set(('\x09', '\x0B', '\x0C', '\x20', '\xA0','\u1680', '\u180E', '\u2000', '\u2001', '\u2002','\u2003', '\u2004', '\u2005', '\u2006', '\u2007','\u2008', '\u2009', '\u200A', '\u202F', '\u205F','\u3000', '\uFEFF',))
123
- #换行
124
- LINE_TERMINATOR = set(('\x0A', '\x0D', '\u2028', '\u2029'))
125
- #数字
126
- UNICODE_DIGIT = set(U_CATEGORIES['Nd'])
127
- DECIMAL_DIGIT = set(DECIMAL_CONV.keys())
128
- OCTAL_DIGIT = set(OCTAL_CONV.keys())
129
- HEX_DIGIT = set(HEX_CONV.keys())
130
- #合法的起始字符
131
- IDENTIFIER_START = UNICODE_LETTER.union(UNICODE_OTHER_ID_START).union(set(('$', '_', '\\')))
132
- #合法的中间字符
133
- IDENTIFIER_PART = IDENTIFIER_START.union(UNICODE_COMBINING_MARK).union(UNICODE_DIGIT).union(UNICODE_CONNECTOR_PUNCTUATION).union(set(('\u200D', '\u200C'))).union(UNICODE_OTHER_ID_CONTINUE)
134
-
135
- class Character:
136
- @staticmethod # 返回ASCII字符
137
- def FromCodePoint(cp): return uchr(cp)
138
-
139
- @staticmethod # 是否是空格 https://tc39.github.io/ecma262/#sec-white-space
140
- def IsWhiteSpace(cp): return cp in WHITE_SPACE
141
-
142
- @staticmethod # 是否换行 https://tc39.github.io/ecma262/#sec-line-terminators
143
- def IsLineTerminator(cp): return cp in LINE_TERMINATOR
144
-
145
- @staticmethod # https://tc39.github.io/ecma262/#sec-names-and-keywords
146
- def IsIdentifierStart(cp): return cp in IDENTIFIER_START
147
-
148
- @staticmethod
149
- def IsIdentifierPart(cp): return cp in IDENTIFIER_PART
150
-
151
- @staticmethod # 0..9 https://tc39.github.io/ecma262/#sec-literals-numeric-literals
152
- def IsDecimalDigit(cp): return cp in DECIMAL_DIGIT
153
-
154
- @staticmethod
155
- def IsHexDigit(cp): return cp in HEX_DIGIT
156
-
157
- @staticmethod #0..7
158
- def IsOctalDigit(cp): return cp in OCTAL_DIGIT
159
-
160
-
161
-
162
- ######################################################################
163
- #
164
- # 错误信息类
165
- #
166
- ######################################################################
167
- class Error(Exception):
168
- def __init__(self, message, name=None, index=None, lineNumber=None, column=None, description=None):
169
- super(Error, self).__init__(message)
170
- self.Message = message
171
- self.Name = name
172
- self.Index = index
173
- self.LineNumber = lineNumber
174
- self.Column = column
175
- # self.description = description
176
-
177
- def ToString(self):
178
- return '%s: %s' % (self.__class__.__name__, self)
179
-
180
- def ToDict(self):
181
- d = dict((unicode(k), v) for k, v in self.__dict__.items() if v is not None)
182
- d['message'] = self.ToString()
183
- return d
184
-
185
- ######################################################################
186
- #
187
- # 编译异常, 错误类
188
- #
189
- ######################################################################
190
- class ErrorHandler:
191
- def __init__(self):
192
- self.Error=[]
193
-
194
- def RecordError(self, error):
195
- self.Error.append(error.ToDict())
196
-
197
- def CreateError(self, index, line, col, description):
198
- # msg='Line ' + line + ': ' + description
199
- msg = 'Line %s: %s' % (line, description)
200
- return Error(msg,index=index,lineNumber=line, column=col, description=description)
201
-
202
- def ThrowError(self, index, line, col, description):
203
- error=self.CreateError(index,line,col,description)
204
- raise error
205
-
206
- ######################################################################
207
- #
208
- # 扫描状态信息类
209
- #
210
- ######################################################################
211
- class ScannerState:
212
- def __init__(self, index=None, lineNumber=None, lineStart=None):
213
- self.Index = index
214
- self.LineNumber = lineNumber
215
- self.LineStart = lineStart
216
-
217
- class RawToken():
218
- def __init__(self, type=None, value=None, pattern=None, flags=None, regex=None, octal=None, cooked=None, head=None, tail=None, lineNumber=None, lineStart=None, start=None, end=None):
219
- self.Type = type
220
- self.Value = value
221
- #self.Pattern = pattern
222
- #self.Flags = flags
223
- #self.regex = regex
224
- #self.octal = octal
225
- #self.cooked = cooked
226
- #self.head = head
227
- #self.tail = tail
228
- self.LineNumber = lineNumber
229
- self.LineStart = lineStart
230
- self.Start = start
231
- self.End = end
232
-
233
-
234
- #######################################################################################
235
- #
236
- # 扫描类
237
- #
238
- #######################################################################################
239
- class Scanner:
240
- def __init__(self, code, ErrorHandler):
241
- self.Source=unicode(code) + '\x00'
242
- self.ErrorHandler=ErrorHandler
243
- self.Length=len(code)
244
- self.Index=0
245
- self.LineNumber=1 if (self.Length>0) else 0
246
- self.LineStart=0
247
- self.CurlyStack=[]
248
-
249
- def SaveState(self): # 保存当前扫描状态
250
- return ScannerState(index=self.Index, lineNumber=self.LineNumber, lineStart=self.LineStart)
251
-
252
- def RestoreState(self, state): #还原扫描状态
253
- self.Index=state.Index
254
- self.LineNumber=state.LineNumber
255
- self.LineStart=state.LineStart
256
-
257
- def IsEOF(self): #否是已经结束
258
- return self.Index>=self.Length
259
-
260
- def IsKeyword(self,id):
261
- return False
262
-
263
- def CodePointAt (self, i):
264
- return uord(self.Source[i:i + 2])
265
-
266
- def Lex(self):
267
- if (self.IsEOF()):
268
- return RawToken( type=2, value='', lineNumber=self.LineNumber, lineStart=self.LineStart, start=self.Index, end=self.Index ) # 2=EOF
269
- cp=self.Source[self.Index]
270
-
271
- # 变量名 或 关键字
272
- if (Character.IsIdentifierStart(cp)):
273
- return self.ScanIdentifier()
274
-
275
- # ( ) ; 开头 操作符扫描
276
- if cp in ('(', ')', ';'):
277
- return self.ScanPunctuator()
278
-
279
- # ' " 开头 字符串扫描
280
- if cp in ('\'', '"'):
281
- return self.ScanStringLiteral()
282
-
283
- # . 开头 浮点型
284
- if cp == '.':
285
- if Character.IsDecimalDigit(self.Source[self.Index + 1]):
286
- return self.ScanNumericLiteral()
287
- return self.ScanPunctuator()
288
-
289
- # 数字
290
- if Character.IsDecimalDigit(cp):
291
- return self.ScanNumericLiteral()
292
-
293
- cp1=ord(cp)
294
- if cp1 >= 0xD800 and cp1 < 0xDFFF :
295
- cp1 = self.CodePointAt(self.Index)
296
- cp = Character.FromCodePoint(cp1)
297
- if Character.IsIdentifierStart(cp):
298
- return self.ScanIdentifier()
299
-
300
- return self.ScanPunctuator()
301
-
302
- # 关键字 变量名 https://tc39.github.io/ecma262/#sec-names-and-keywords
303
- def ScanIdentifier(self):
304
- type=0
305
- start=self.Index
306
- # \\ 反斜杠
307
- id=self.GetComplexIdentifier() if self.Source[start] == '\\' else self.GetIdentifier()
308
-
309
- if len(id) == 1:
310
- type=3 # Identifier
311
- elif self.IsKeyword(id):
312
- type=4 # Keyword
313
- elif id=='null':
314
- type=5 # NullLiteral
315
- elif id=='true' or id=='false':
316
- type=1 # BooleanLiteral
317
- else:
318
- type=3 # Identifier
319
-
320
- if type!=3 and start+len(id)!=self.Index :
321
- # restore=self.Index
322
- self.Index=start
323
- raise Messages.InvalidEscapedReservedWord
324
- # self.Index=restore
325
-
326
- if id=='AND' or id=='OR' :
327
- type=7 #Punctuator*/
328
-
329
- return RawToken( type=type, value=id, lineNumber=self.LineNumber, lineStart=self.LineStart, start=start, end=self.Index )
330
-
331
- def GetIdentifier(self):
332
- start=self.Index # start 保存进来的位置
333
- self.Index+=1
334
- while not self.IsEOF():
335
- ch=self.Source[self.Index]
336
- if ch=='\\':
337
- self.Index=start
338
- return self.GetComplexIdentifier()
339
- else:
340
- cp = ord(ch)
341
- if cp >= 0xD800 and cp < 0xDFFF :
342
- self.Index=start
343
- return self.GetComplexIdentifier()
344
-
345
- if Character.IsIdentifierPart(ch):
346
- self.Index+=1
347
- else:
348
- break
349
-
350
- return self.Source[start:self.Index]
351
-
352
- # 操作符 https://tc39.github.io/ecma262/#sec-punctuators
353
- def ScanPunctuator(self):
354
- start=self.Index
355
- str=self.Source[self.Index]
356
- if str=='(':
357
- self.Index+=1
358
- elif str in (')',';',','):
359
- self.Index+=1
360
- else :
361
- str=self.Source[self.Index:self.Index+3]
362
- if str=='AND' :
363
- self.Index+=3
364
- else :
365
- str = self.Source[self.Index:self.Index+2]
366
- if str in ( '&&', '||', '==' , '!=', '<>', '<=', '>=', '=>', ':=', 'OR') :
367
- self.Index += 2
368
- else :
369
- str=self.Source[self.Index]
370
- if str in '<>=!+-*%&|^/:' :
371
- self.Index += 1
372
-
373
- if self.Index==start :
374
- self.ThrowUnexpectedToken()
375
-
376
- return RawToken( type=7, value=str, lineNumber=self.LineNumber, lineStart=self.LineStart, start=start, end=self.Index ) #7=Punctuator
377
-
378
- # 字符串 https://tc39.github.io/ecma262/#sec-literals-string-literals
379
- def ScanStringLiteral(self):
380
- start=self.Index
381
- quote=self.Source[self.Index]
382
-
383
- self.Index+=1
384
- # octal=False
385
- str=''
386
- while not self.IsEOF():
387
- ch=self.Source[self.Index]
388
- self.Index+=1
389
- if ch==quote:
390
- quote=''
391
- break
392
- elif ch=='\\': #字符串转义
393
- raise "not complete"
394
- elif Character.IsLineTerminator(ch) :
395
- break
396
- else :
397
- str+=ch
398
-
399
- if quote!='' :
400
- self.Index=start
401
- self.ThrowUnexpectedToken()
402
-
403
- return RawToken( type=8, value=str, lineNumber=self.LineNumber, lineStart=self.LineStart, start=start, end=self.Index) # 8=StringLiteral
404
-
405
- def ScanNumericLiteral(self) :
406
- start=self.Index
407
- ch=self.Source[self.Index]
408
- num=''
409
- if ch!='.' :
410
- num=self.Source[self.Index]
411
- self.Index+=1
412
- ch=self.Source[self.Index]
413
- # Hex number starts with '0x'. 16进制
414
- if num=='0' :
415
- if ch in ('x', 'X') :
416
- self.Index+=1
417
- return self.ScanHexLiteral(start)
418
-
419
- while Character.IsDecimalDigit(self.Source[self.Index]):
420
- num+=self.Source[self.Index]
421
- self.Index+=1
422
-
423
- ch=self.Source[self.Index]
424
-
425
- if ch=='.' :
426
- num+=self.Source[self.Index]
427
- self.Index+=1
428
- while Character.IsDecimalDigit(self.Source[self.Index]) :
429
- num+=self.Source[self.Index]
430
- self.Index+=1
431
-
432
- ch=self.Source[self.Index]
433
-
434
- # 科学计数法
435
- if ch in ('e', 'E'):
436
- num+=self.Source[self.Index]
437
- self.Index+=1
438
- ch=self.Source[self.Index]
439
- if ch in ('+' ,'-'):
440
- num+=self.Source[self.Index]
441
- self.Index+=1
442
- if Character.IsDecimalDigit(self.Source[self.Index]) :
443
- while Character.IsDecimalDigit(self.Source[self.Index]) :
444
- num+=self.Source[self.Index]
445
- self.Index+=1
446
- else :
447
- self.ThrowUnexpectedToken()
448
-
449
- if Character.IsIdentifierStart(self.Source[self.Index]) :
450
- self.ThrowUnexpectedToken()
451
-
452
- value = float(num)
453
- return RawToken( type=6, value=value, lineNumber=self.LineNumber, lineStart=self.LineStart, start=start, end=self.Index ) #6=NumericLiteral
454
-
455
- # 16进制数值
456
- def ScanHexLiteral(self, start):
457
- num = ''
458
- while not self.IsEOF() :
459
- if not Character.IsHexDigit(self.Source[self.Index]):
460
- break
461
-
462
- num += self.Source[self.Index]
463
- self.Index += 1
464
-
465
- if len(num) == 0:
466
- self.ThrowUnexpectedToken()
467
-
468
- if Character.IsIdentifierStart(self.Source[self.Index]):
469
- self.ThrowUnexpectedToken()
470
-
471
- return RawToken(type=6, value=int(num, 16), lineNumber=self.LineNumber, lineStart=self.LineStart, start=start, end=self.Index) # 6=NumericLiteral,
472
-
473
- # 不支持
474
- def GetComplexIdentifier(self):
475
- self.ThrowUnexpectedToken()
476
- return id
477
-
478
- # 空格 或 注释
479
- def ScanComments(self) :
480
- comments=[]
481
- start= self.Index==0
482
- while not self.IsEOF() :
483
- ch=self.Source[self.Index]
484
- if Character.IsWhiteSpace(ch) : # 过滤掉空格
485
- self.Index+=1
486
-
487
- elif Character.IsLineTerminator(ch):
488
- self.Index+=1
489
- if ch=='\r' and self.Source[self.Index]=='\n' :
490
- self.Index+=1 #回车+换行
491
-
492
- self.LineNumber+=1
493
- self.LineStart=self.Index
494
- start=True
495
-
496
- elif ch=='/' : # //注释
497
- ch=self.Source[self.Index+1]
498
- if ch=='/' :
499
- self.Index+=2
500
- comment=self.SkipSingleLineComment(2)
501
- start=True
502
- else :
503
- break
504
-
505
- elif ch== '{' : #{ } 注释
506
- self.Index += 1
507
- comment = self.SkipMultiLineComment()
508
- else :
509
- break
510
-
511
- return comments
512
-
513
- # 多行注释
514
- def SkipMultiLineComment(self) :
515
- comments = []
516
- while not self.IsEOF() :
517
- ch = self.Source[self.Index]
518
- if Character.IsLineTerminator(ch) :
519
- self.LineNumber+=1
520
- self.Index+=1
521
- self.LineStart = self.Index
522
- elif ch == '*' :
523
- if self.Source[self.Index + 1] == '/':
524
- self.Index += 2
525
- return comments
526
-
527
- self.Index+=1
528
- else :
529
- self.Index+=1
530
-
531
- return comments
532
-
533
-
534
- # 单行注释 https://tc39.github.io/ecma262/#sec-comments
535
- def SkipSingleLineComment(self, offset) :
536
- comments=[]
537
- while not self.IsEOF() :
538
- ch=self.Source[self.Index]
539
- self.Index+=1
540
- if Character.IsLineTerminator(ch) :
541
- if ch=='\r' and self.Source[self.Index] =='\n' :
542
- self.Index+=1
543
-
544
- self.LineNumber+=1
545
- self.LineStart=self.Index
546
- return comments
547
-
548
- return comments
549
-
550
- # 抛异常
551
- def ThrowUnexpectedToken(self, message= Messages.UnexpectedTokenIllegal) :
552
- return self.ErrorHandler.ThrowError(self.Index, self.LineNumber, self.Index - self.LineStart + 1, message)
553
-
554
-