hqchart 1.1.12693 → 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.
- package/package.json +15 -47
- package/src/jscommon/umychart.resource/js/codemirror/javascript.js +1 -1
- package/.babelrc +0 -6
- package/.vscode/settings.json +0 -4
- package/Makefile +0 -9
- package/README.md +0 -452
- package/index.js +0 -17
- package/postcss.config.js +0 -5
- package/src/index.html +0 -18
- package/src/jscommon/backup/announcement.png +0 -0
- package/src/jscommon/backup/announcement2.png +0 -0
- package/src/jscommon/backup/blocktrading.png +0 -0
- package/src/jscommon/backup/investor.png +0 -0
- package/src/jscommon/backup/pforecast.png +0 -0
- package/src/jscommon/backup/research.png +0 -0
- package/src/jscommon/backup/tradedetail.png +0 -0
- package/src/jscommon/backup/umychart - backup.js +0 -17631
- package/src/jscommon/backup/umychart.macro.js +0 -4
- package/src/jscommon/backup/umychart.macro.vue.js +0 -3
- package/src/jscommon/commonindextree.json +0 -92
- package/src/jscommon/index.html +0 -13
- package/src/jscommon/jschinamapdata.js +0 -3
- package/src/jscommon/umychart.NetworkFilterTest.js +0 -48803
- package/src/jscommon/umychart.aliYunnetwork.js +0 -47
- package/src/jscommon/umychart.cninfo.components/readme.txt +0 -1
- package/src/jscommon/umychart.complier.js +0 -25293
- package/src/jscommon/umychart.complier.node/umychart.complier.controller.js +0 -559
- package/src/jscommon/umychart.complier.node/umychart.complier.node.js +0 -7043
- package/src/jscommon/umychart.complier.node/umychart.data.node.js +0 -816
- package/src/jscommon/umychart.console.js +0 -12
- package/src/jscommon/umychart.deal.js +0 -1452
- package/src/jscommon/umychart.dragdiv.js +0 -48
- package/src/jscommon/umychart.index.data.js +0 -4132
- package/src/jscommon/umychart.js +0 -90542
- package/src/jscommon/umychart.keyboard.js +0 -1659
- package/src/jscommon/umychart.listctrl.js +0 -690
- package/src/jscommon/umychart.mind.js +0 -2203
- package/src/jscommon/umychart.network.js +0 -44
- package/src/jscommon/umychart.news.js +0 -823
- package/src/jscommon/umychart.node.build/buildall.bat +0 -1
- package/src/jscommon/umychart.node.build/umychart.node.bat +0 -1
- package/src/jscommon/umychart.node.build/umychart.node.export.js +0 -40
- package/src/jscommon/umychart.regressiontest.js +0 -400
- package/src/jscommon/umychart.report.js +0 -5803
- package/src/jscommon/umychart.scrollbar.js +0 -1345
- package/src/jscommon/umychart.stock.js +0 -4218
- package/src/jscommon/umychart.style.js +0 -625
- package/src/jscommon/umychart.testdata.js +0 -150
- package/src/jscommon/umychart.uniapp.build/buildall.bat +0 -1
- package/src/jscommon/umychart.uniapp.build/umychart.bat +0 -1
- package/src/jscommon/umychart.uniapp.build/umychart.export.js +0 -70
- package/src/jscommon/umychart.user.js +0 -137
- package/src/jscommon/umychart.version.js +0 -30
- package/src/jscommon/umychart.vue/umychart.aliYunnetwork.vue.js +0 -56
- package/src/jscommon/umychart.vue.build/buildall.bat +0 -4
- package/src/jscommon/umychart.vue.build/copy_codemirror.bat +0 -2
- package/src/jscommon/umychart.vue.build/umychart.aliYunnetwork.vue.export.js +0 -9
- package/src/jscommon/umychart.vue.build/umychart.dragdiv.bat +0 -1
- package/src/jscommon/umychart.vue.build/umychart.dragdiv.export.js +0 -6
- package/src/jscommon/umychart.vue.build/umychart.index.data.bat +0 -1
- package/src/jscommon/umychart.vue.build/umychart.index.data.export.js +0 -4
- package/src/jscommon/umychart.vue.build/umychart.listctrl.vue.export.js +0 -15
- package/src/jscommon/umychart.vue.build/umychart.regressiontest.vue.export.js +0 -7
- package/src/jscommon/umychart.vue.build/umychart.regressiontest.wechat.export.js +0 -12
- package/src/jscommon/umychart.vue.build/umychart.stock.bat +0 -1
- package/src/jscommon/umychart.vue.build/umychart.stock.vue.export.js +0 -16
- package/src/jscommon/umychart.vue.build/umychart.testdata.bat +0 -3
- package/src/jscommon/umychart.vue.build/umychart.testdata.vue.export.js +0 -7
- package/src/jscommon/umychart.vue.build/umychart.vue.bat +0 -8
- package/src/jscommon/umychart.vue.build/umychart.vue.export.js +0 -112
- package/src/jscommon/umychart.vue.components/empyt.vue +0 -51
- package/src/jscommon/umychart.vue.components/historydayline.vue +0 -240
- package/src/jscommon/umychart.vue.components/jsloader.adddialog.vue +0 -315
- package/src/jscommon/umychart.vue.components/jsloader.vue +0 -93
- package/src/jscommon/umychart.vue.components/jsvuecontainer.vue +0 -160
- package/src/jscommon/umychart.vue.components/jsvuecontainer2.0.vue +0 -391
- package/src/jscommon/umychart.vue.components/login.vue +0 -178
- package/src/jscommon/umychart.vue.components/queryContent.vue +0 -750
- package/src/jscommon/umychart.vue.components/readme.txt +0 -8
- package/src/jscommon/umychart.vue.components/searchsymbol.vue +0 -299
- package/src/jscommon/umychart.vue.components/simulatetrade.vue +0 -1471
- package/src/jscommon/umychart.vue.components/stockchart.vue +0 -343
- package/src/jscommon/umychart.vue.components/stockchartV2.vue +0 -195
- package/src/jscommon/umychart.vue.components/stockdeal.vue +0 -358
- package/src/jscommon/umychart.vue.components/stockdealcount.vue +0 -262
- package/src/jscommon/umychart.vue.components/stockdeallastest.vue +0 -316
- package/src/jscommon/umychart.vue.components/stockdrawtool.vue +0 -343
- package/src/jscommon/umychart.vue.components/stockfull.vue +0 -355
- package/src/jscommon/umychart.vue.components/stockinfo.demo.vue +0 -153
- package/src/jscommon/umychart.vue.components/stockinfo.vue +0 -685
- package/src/jscommon/umychart.vue.components/stockkline.demo.vue +0 -1904
- package/src/jscommon/umychart.vue.components/stockmultiorder.vue +0 -174
- package/src/jscommon/umychart.vue.components/stockmultiperiod.vue +0 -222
- package/src/jscommon/umychart.vue.components/stockorder.vue +0 -320
- package/src/jscommon/umychart.vue.components/stocktradeinfo.demo.vue +0 -250
- package/src/jscommon/umychart.vue.components/stocktradeinfo.vue +0 -1907
- package/src/jscommon/umychart.vue.components/test.vue +0 -0
- package/src/jscommon/umychart.wechat/getDate.wechat.js +0 -91
- package/src/jscommon/umychart.wechat/lighter.news.wechat.js +0 -262
- package/src/jscommon/umychart.wechat/readme.txt +0 -3
- package/src/jscommon/umychart.wechat/umychart.analyze.wechat.js +0 -551
- package/src/jscommon/umychart.wechat/umychart.apidraw.wechat.js +0 -126
- package/src/jscommon/umychart.wechat/umychart.bigV.wechat.js +0 -2510
- package/src/jscommon/umychart.wechat/umychart.chartframe.wechat.js +0 -2942
- package/src/jscommon/umychart.wechat/umychart.chartpaint.wechat.js +0 -9752
- package/src/jscommon/umychart.wechat/umychart.charttitle.wechat.js +0 -2023
- package/src/jscommon/umychart.wechat/umychart.complier.wechat.js +0 -14726
- package/src/jscommon/umychart.wechat/umychart.console.wechat.js +0 -8
- package/src/jscommon/umychart.wechat/umychart.coordinatedata.wechat.js +0 -3654
- package/src/jscommon/umychart.wechat/umychart.data.wechat.js +0 -2243
- package/src/jscommon/umychart.wechat/umychart.element.wechart.js +0 -132
- package/src/jscommon/umychart.wechat/umychart.explainer.wechat.js +0 -1077
- package/src/jscommon/umychart.wechat/umychart.extendchart.wechat.js +0 -1140
- package/src/jscommon/umychart.wechat/umychart.framesplit.wechat.js +0 -2247
- package/src/jscommon/umychart.wechat/umychart.hqIndexformula.wechat.js +0 -941
- package/src/jscommon/umychart.wechat/umychart.index.data.wechat.js +0 -3628
- package/src/jscommon/umychart.wechat/umychart.index.wechat.js +0 -4074
- package/src/jscommon/umychart.wechat/umychart.klineinfo.wechat.js +0 -836
- package/src/jscommon/umychart.wechat/umychart.markethot.js +0 -50
- package/src/jscommon/umychart.wechat/umychart.network.wechart.js +0 -62
- package/src/jscommon/umychart.wechat/umychart.news.wechat.js +0 -3568
- package/src/jscommon/umychart.wechat/umychart.regressiontest.wechat.js +0 -412
- package/src/jscommon/umychart.wechat/umychart.report.wechat.js +0 -3983
- package/src/jscommon/umychart.wechat/umychart.resource.wechat.js +0 -919
- package/src/jscommon/umychart.wechat/umychart.shareimage.wechat.js +0 -681
- package/src/jscommon/umychart.wechat/umychart.simulatetrade.wechat.js +0 -238
- package/src/jscommon/umychart.wechat/umychart.stock.wechat.js +0 -4035
- package/src/jscommon/umychart.wechat/umychart.style.wechat.js +0 -419
- package/src/jscommon/umychart.wechat/umychart.uniapp.canvas.helper.js +0 -99
- package/src/jscommon/umychart.wechat/umychart.user.wechat.js +0 -588
- package/src/jscommon/umychart.wechat/umychart.userlog.wechat.js +0 -240
- package/src/jscommon/umychart.wechat/umychart.vedio.wechat.js +0 -112
- package/src/jscommon/umychart.wechat/umychart.version.wechat.js +0 -36
- package/src/jscommon/umychart.wechat/umychart.wechat.3.0.js +0 -12055
- package/src/jscommon/umychart.wechat/umychart.wechat.js +0 -15460
- package/src/jscommon/umychart.worker.js +0 -114
- package/src/jscommon/umychart.ws.stock.js +0 -110
- package/src/jscommon/umychart_python/.vscode/launch.json +0 -15
- package/src/jscommon/umychart_python/__init__.py +0 -4
- package/src/jscommon/umychart_python/build.cmd +0 -2
- package/src/jscommon/umychart_python/setup.py +0 -25
- package/src/jscommon/umychart_python/umychart_cache_testcase.py +0 -165
- package/src/jscommon/umychart_python/umychart_complier_data.py +0 -781
- package/src/jscommon/umychart_python/umychart_complier_help.py +0 -175
- package/src/jscommon/umychart_python/umychart_complier_job.py +0 -193
- package/src/jscommon/umychart_python/umychart_complier_jsalgorithm.py +0 -4144
- package/src/jscommon/umychart_python/umychart_complier_jscomplier.py +0 -177
- package/src/jscommon/umychart_python/umychart_complier_jsexecute.py +0 -517
- package/src/jscommon/umychart_python/umychart_complier_jsparser.py +0 -864
- package/src/jscommon/umychart_python/umychart_complier_jssymboldata.py +0 -1238
- package/src/jscommon/umychart_python/umychart_complier_jssymboldata_cache.py +0 -146
- package/src/jscommon/umychart_python/umychart_complier_jssymboldata_json.py +0 -106
- package/src/jscommon/umychart_python/umychart_complier_pandas_help.py +0 -80
- package/src/jscommon/umychart_python/umychart_complier_scanner.py +0 -554
- package/src/jscommon/umychart_python/umychart_complier_testcase.py +0 -362
- package/src/jscommon/umychart_python/umychart_complier_util.py +0 -30
- package/src/jscommon/umychart_python/umychart_webtemplate.py +0 -131
- package/src/jscommon/umychart_python/updatehqchartweb.bat +0 -5
- package/src/jscommon/vendor.js +0 -2
- package/src/pages/block.list.demo.page/App.vue +0 -117
- package/src/pages/block.list.demo.page/index.js +0 -12
- package/src/pages/brushTool.demo.page/App.vue +0 -19
- package/src/pages/brushTool.demo.page/index.js +0 -12
- package/src/pages/container.demo.page/App.vue +0 -118
- package/src/pages/container.demo.page/index.js +0 -18
- package/src/pages/dataZoom.demo.page/App.vue +0 -265
- package/src/pages/dataZoom.demo.page/components/dataZoom.vue +0 -303
- package/src/pages/dataZoom.demo.page/index.js +0 -12
- package/src/pages/historydayline.demo.page/App.vue +0 -57
- package/src/pages/historydayline.demo.page/index.js +0 -12
- package/src/pages/hq.demo.page/App.vue +0 -163
- package/src/pages/hq.demo.page/index.js +0 -12
- package/src/pages/hqchart.black/App.vue +0 -90
- package/src/pages/hqchart.black/components/searchsymbol.vue +0 -299
- package/src/pages/hqchart.black/components/stockdrawtool.vue +0 -300
- package/src/pages/hqchart.black/components/stockfull.vue +0 -313
- package/src/pages/hqchart.black/components/stockinfo.vue +0 -428
- package/src/pages/hqchart.black/components/stockkline.demo.vue +0 -1652
- package/src/pages/hqchart.black/components/stocktradeinfo.vue +0 -1337
- package/src/pages/hqchart.black/index.js +0 -30
- package/src/pages/hqchart.black/router/candlestickChart.vue +0 -108
- package/src/pages/hqchart.black/router/pricePointsTable.vue +0 -294
- package/src/pages/hqchart.black/router/stockDeallas.vue +0 -417
- package/src/pages/hqchart.black/router/timeShareChart.vue +0 -108
- package/src/pages/hqchart.page/App.vue +0 -101
- package/src/pages/hqchart.page/index.js +0 -18
- package/src/pages/index/App.vue +0 -1408
- package/src/pages/index/index.js +0 -7
- package/src/pages/indexHq/App.vue +0 -110
- package/src/pages/indexHq/index.js +0 -18
- package/src/pages/login.demo.page/App.vue +0 -22
- package/src/pages/login.demo.page/index.js +0 -12
- package/src/pages/queryContent.demo.page/App.vue +0 -29
- package/src/pages/queryContent.demo.page/index.js +0 -18
- package/src/pages/ranking.black/App.vue +0 -199
- package/src/pages/ranking.black/index.js +0 -18
- package/src/pages/search.demo.page/App.vue +0 -28
- package/src/pages/search.demo.page/index.js +0 -12
- package/src/pages/simulatetrade.demo.page/app.vue +0 -121
- package/src/pages/simulatetrade.demo.page/index.js +0 -17
- package/src/pages/stockdeal.demo.page/App.vue +0 -63
- package/src/pages/stockdeal.demo.page/index.js +0 -19
- package/src/pages/stockdealcount.demo.page/App.vue +0 -37
- package/src/pages/stockdealcount.demo.page/index.js +0 -12
- package/src/pages/stockdeallastest.demo.page/App.vue +0 -74
- package/src/pages/stockdeallastest.demo.page/index.js +0 -18
- package/src/pages/stockinfo.demo.page/App.vue +0 -92
- package/src/pages/stockinfo.demo.page/index.html +0 -13
- package/src/pages/stockinfo.demo.page/index.js +0 -19
- package/src/pages/stockkline.demo.page/App.vue +0 -55
- package/src/pages/stockkline.demo.page/index.js +0 -18
- package/src/pages/stockmultiorder.demo.page/App.vue +0 -149
- package/src/pages/stockmultiorder.demo.page/index.js +0 -18
- package/src/pages/stockmultiperiod.demo.page/App.vue +0 -87
- package/src/pages/stockmultiperiod.demo.page/index.js +0 -18
- package/src/pages/stockorder.demo.page/App.vue +0 -69
- package/src/pages/stockorder.demo.page/index.js +0 -18
- package/src/pages/test/App.vue +0 -22
- package/src/pages/test/index.js +0 -7
- package/src/pages/tradeinfopage/app.vue +0 -40
- package/src/pages/tradeinfopage/index.js +0 -7
- package/src/pages/tradeinfopage/tradeinfo.html +0 -12
- package/src/utils/urlObj.js +0 -81
- package/src/vendor.js +0 -2
- package/webpack.config.js +0 -104
|
@@ -1,864 +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
|
-
|
|
16
|
-
import sys
|
|
17
|
-
from umychart_complier_util import xrange, unicode, uchr, uord
|
|
18
|
-
from umychart_complier_scanner import Scanner, RawToken, ErrorHandler, Error, Messages
|
|
19
|
-
from umychart_complier_job import JS_EXECUTE_JOB_ID, JobItem
|
|
20
|
-
from umychart_complier_help import Variant
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
TOKEN_NAME={ }
|
|
24
|
-
TOKEN_NAME[1] = 'Boolean' # BooleanLiteral
|
|
25
|
-
TOKEN_NAME[2] = '<end>' # EOF
|
|
26
|
-
TOKEN_NAME[3] = 'Identifier' # Identifier
|
|
27
|
-
TOKEN_NAME[4] = 'Keyword' # Keyword
|
|
28
|
-
TOKEN_NAME[5] = 'Null' # NullLiteral
|
|
29
|
-
TOKEN_NAME[6] = 'Numeric' # NumericLiteral
|
|
30
|
-
TOKEN_NAME[7] = 'Punctuator' # Punctuator
|
|
31
|
-
TOKEN_NAME[8] = 'String' # StringLiteral
|
|
32
|
-
TOKEN_NAME[9] = 'RegularExpression' #RegularExpression
|
|
33
|
-
TOKEN_NAME[10] = 'Template' #Template
|
|
34
|
-
|
|
35
|
-
class BufferEntry():
|
|
36
|
-
def __init__(self, type, value, regex=None, range=None, loc=None):
|
|
37
|
-
self.Type = type
|
|
38
|
-
self.Value = value
|
|
39
|
-
#self.regex = regex
|
|
40
|
-
#self.range = range
|
|
41
|
-
#self.loc = loc
|
|
42
|
-
|
|
43
|
-
class Tokenizer():
|
|
44
|
-
def __init__(self, code) :
|
|
45
|
-
self.ErrorHandler=ErrorHandler() #错误信息处理类
|
|
46
|
-
self.Scanner=Scanner(code,self.ErrorHandler)
|
|
47
|
-
self.Buffer=[]
|
|
48
|
-
|
|
49
|
-
def GetNextToken(self) :
|
|
50
|
-
if len(self.Buffer) <=0 :
|
|
51
|
-
comments=self.Scanner.ScanComments()
|
|
52
|
-
if not self.Scanner.IsEOF() :
|
|
53
|
-
token=self.Scanner.Lex()
|
|
54
|
-
|
|
55
|
-
entry= BufferEntry( type=TOKEN_NAME[token.Type], value=self.Scanner.Source[token.Start: token.End])
|
|
56
|
-
|
|
57
|
-
self.Buffer.append(entry)
|
|
58
|
-
|
|
59
|
-
if len(self.Buffer) <=0 : return None
|
|
60
|
-
|
|
61
|
-
return self.Buffer.pop(0)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
class Syntax:
|
|
65
|
-
AssignmentExpression= 'AssignmentExpression'
|
|
66
|
-
AssignmentPattern= 'AssignmentPattern'
|
|
67
|
-
ArrayExpression= 'ArrayExpression'
|
|
68
|
-
ArrayPattern= 'ArrayPattern'
|
|
69
|
-
ArrowFunctionExpression= 'ArrowFunctionExpression'
|
|
70
|
-
AwaitExpression= 'AwaitExpression'
|
|
71
|
-
BlockStatement= 'BlockStatement'
|
|
72
|
-
BinaryExpression= 'BinaryExpression'
|
|
73
|
-
BreakStatement= 'BreakStatement'
|
|
74
|
-
CallExpression= 'CallExpression'
|
|
75
|
-
CatchClause= 'CatchClause'
|
|
76
|
-
ClassBody= 'ClassBody'
|
|
77
|
-
ClassDeclaration= 'ClassDeclaration'
|
|
78
|
-
ClassExpression= 'ClassExpression'
|
|
79
|
-
ConditionalExpression= 'ConditionalExpression'
|
|
80
|
-
ContinueStatement= 'ContinueStatement'
|
|
81
|
-
DoWhileStatement= 'DoWhileStatement'
|
|
82
|
-
DebuggerStatement= 'DebuggerStatement'
|
|
83
|
-
EmptyStatement= 'EmptyStatement'
|
|
84
|
-
ExportAllDeclaration= 'ExportAllDeclaration'
|
|
85
|
-
ExportDefaultDeclaration= 'ExportDefaultDeclaration'
|
|
86
|
-
ExportNamedDeclaration= 'ExportNamedDeclaration'
|
|
87
|
-
ExportSpecifier= 'ExportSpecifier'
|
|
88
|
-
ExpressionStatement= 'ExpressionStatement'
|
|
89
|
-
ForStatement= 'ForStatement'
|
|
90
|
-
ForOfStatement= 'ForOfStatement'
|
|
91
|
-
ForInStatement= 'ForInStatement'
|
|
92
|
-
FunctionDeclaration= 'FunctionDeclaration'
|
|
93
|
-
FunctionExpression= 'FunctionExpression'
|
|
94
|
-
Identifier= 'Identifier'
|
|
95
|
-
IfStatement= 'IfStatement'
|
|
96
|
-
ImportDeclaration= 'ImportDeclaration'
|
|
97
|
-
ImportDefaultSpecifier= 'ImportDefaultSpecifier'
|
|
98
|
-
ImportNamespaceSpecifier= 'ImportNamespaceSpecifier'
|
|
99
|
-
ImportSpecifier= 'ImportSpecifier'
|
|
100
|
-
Literal= 'Literal'
|
|
101
|
-
LabeledStatement= 'LabeledStatement'
|
|
102
|
-
LogicalExpression= 'LogicalExpression'
|
|
103
|
-
MemberExpression= 'MemberExpression'
|
|
104
|
-
MetaProperty= 'MetaProperty'
|
|
105
|
-
MethodDefinition= 'MethodDefinition'
|
|
106
|
-
NewExpression= 'NewExpression'
|
|
107
|
-
ObjectExpression= 'ObjectExpression'
|
|
108
|
-
ObjectPattern= 'ObjectPattern'
|
|
109
|
-
Program= 'Program'
|
|
110
|
-
Property= 'Property'
|
|
111
|
-
RestElement= 'RestElement'
|
|
112
|
-
ReturnStatement= 'ReturnStatement'
|
|
113
|
-
SequenceExpression= 'SequenceExpression'
|
|
114
|
-
SpreadElement= 'SpreadElement'
|
|
115
|
-
Super= 'Super'
|
|
116
|
-
SwitchCase= 'SwitchCase'
|
|
117
|
-
SwitchStatement= 'SwitchStatement'
|
|
118
|
-
TaggedTemplateExpression= 'TaggedTemplateExpression'
|
|
119
|
-
TemplateElement= 'TemplateElement'
|
|
120
|
-
TemplateLiteral= 'TemplateLiteral'
|
|
121
|
-
ThisExpression= 'ThisExpression'
|
|
122
|
-
ThrowStatement= 'ThrowStatement'
|
|
123
|
-
TryStatement= 'TryStatement'
|
|
124
|
-
UnaryExpression= 'UnaryExpression'
|
|
125
|
-
UpdateExpression= 'UpdateExpression'
|
|
126
|
-
VariableDeclaration= 'VariableDeclaration'
|
|
127
|
-
VariableDeclarator= 'VariableDeclarator'
|
|
128
|
-
WhileStatement= 'WhileStatement'
|
|
129
|
-
WithStatement= 'WithStatement'
|
|
130
|
-
YieldExpression= 'YieldExpression'
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
class Identifier():
|
|
134
|
-
def __init__(self, name):
|
|
135
|
-
self.Type = Syntax.Identifier
|
|
136
|
-
self.Name = name
|
|
137
|
-
|
|
138
|
-
class BinaryExpression():
|
|
139
|
-
def __init__(self, type, operator, left, right):
|
|
140
|
-
self.Type = type
|
|
141
|
-
self.Operator = operator
|
|
142
|
-
self.Left = left
|
|
143
|
-
self.Right = right
|
|
144
|
-
|
|
145
|
-
class Literal():
|
|
146
|
-
def __init__(self, value, raw):
|
|
147
|
-
self.Type = Syntax.Literal
|
|
148
|
-
self.Value = value
|
|
149
|
-
self.Raw = raw
|
|
150
|
-
|
|
151
|
-
class CallExpression():
|
|
152
|
-
def __init__(self, callee, arguments):
|
|
153
|
-
self.Type = Syntax.CallExpression
|
|
154
|
-
self.Callee = callee
|
|
155
|
-
self.Arguments = arguments
|
|
156
|
-
|
|
157
|
-
class AssignmentExpression():
|
|
158
|
-
def __init__(self, operator, left, right):
|
|
159
|
-
self.Type = Syntax.AssignmentExpression
|
|
160
|
-
self.Operator = operator
|
|
161
|
-
self.Left = left
|
|
162
|
-
self.Right = right
|
|
163
|
-
|
|
164
|
-
class Script():
|
|
165
|
-
def __init__(self, body, sourceType):
|
|
166
|
-
self.Type = Syntax.Program
|
|
167
|
-
self.SourceType = sourceType
|
|
168
|
-
self.Body = body
|
|
169
|
-
|
|
170
|
-
class SequenceExpression():
|
|
171
|
-
def __init__(self, expressions):
|
|
172
|
-
self.Type = Syntax.SequenceExpression
|
|
173
|
-
self.Expression = expressions
|
|
174
|
-
|
|
175
|
-
class ExpressionStatement():
|
|
176
|
-
def __init__(self, expression):
|
|
177
|
-
self.Type = Syntax.ExpressionStatement
|
|
178
|
-
self.Expression = expression
|
|
179
|
-
|
|
180
|
-
class UnaryExpression():
|
|
181
|
-
def __init__(self, operator, argument):
|
|
182
|
-
self.Type = Syntax.UnaryExpression
|
|
183
|
-
self.Prefix = True
|
|
184
|
-
self.Operator = operator
|
|
185
|
-
self.Argument = argument
|
|
186
|
-
|
|
187
|
-
class EmptyStatement():
|
|
188
|
-
def __init__(self):
|
|
189
|
-
self.Type = Syntax.EmptyStatement
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
class Node:
|
|
193
|
-
def __init__(self) :
|
|
194
|
-
self.IsNeedIndexData=False # 是否需要大盘数据
|
|
195
|
-
self.IsNeedLatestData=False # 是否需要最新的个股行情数据
|
|
196
|
-
self.IsNeedSymbolData=False # 是否需要下载股票数据
|
|
197
|
-
self.IsNeedMarginData = set() # 融资融券
|
|
198
|
-
self.IsNeedNewsAnalysisData = set() # 新闻统计数据
|
|
199
|
-
self.IsNeedBlockIncreaseData = set() # 是否需要市场涨跌股票数据统计
|
|
200
|
-
|
|
201
|
-
self.NeedFinanceData=[] # 需要下载的财务数据
|
|
202
|
-
|
|
203
|
-
def GetDataJobList(self) : #下载数据任务列表
|
|
204
|
-
jobs=[]
|
|
205
|
-
if self.IsNeedSymbolData :
|
|
206
|
-
jobs.append(JobItem(id=JS_EXECUTE_JOB_ID.JOB_DOWNLOAD_SYMBOL_DATA))
|
|
207
|
-
if self.IsNeedIndexData :
|
|
208
|
-
jobs.append(JobItem(id=JS_EXECUTE_JOB_ID.JOB_DOWNLOAD_INDEX_DATA))
|
|
209
|
-
if self.IsNeedLatestData :
|
|
210
|
-
jobs.append(JobItem(id=JS_EXECUTE_JOB_ID.JOB_DOWNLOAD_SYMBOL_LATEST_DATA))
|
|
211
|
-
|
|
212
|
-
# 涨跌停家数统计
|
|
213
|
-
for blockSymbol in self.IsNeedBlockIncreaseData :
|
|
214
|
-
jobs.append(JobItem(id=JS_EXECUTE_JOB_ID.JOB_DOWNLOAD_INDEX_INCREASE_DATA, symbol=blockSymbol ))
|
|
215
|
-
|
|
216
|
-
# 加载财务数据
|
|
217
|
-
for jobItem in self.NeedFinanceData :
|
|
218
|
-
if jobItem.ID == JS_EXECUTE_JOB_ID.JOB_DOWNLOAD_DIVIDEND_YIELD_DATA : # 股息率 需要总市值
|
|
219
|
-
jobs.append(JobItem(id=JS_EXECUTE_JOB_ID.JOB_DOWNLOAD_MARKETVALUE_DATA))
|
|
220
|
-
|
|
221
|
-
jobs.append(jobItem)
|
|
222
|
-
|
|
223
|
-
# 加载融资融券
|
|
224
|
-
for jobID in self.IsNeedMarginData :
|
|
225
|
-
jobs.append(JobItem(id=jobID))
|
|
226
|
-
|
|
227
|
-
# 加载新闻统计
|
|
228
|
-
for jobID in self.IsNeedNewsAnalysisData :
|
|
229
|
-
jobs.append(JobItem(id=jobID))
|
|
230
|
-
|
|
231
|
-
return jobs
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
def VerifySymbolVariable(self, varName):
|
|
235
|
-
if varName in ('INDEXA', 'INDEXC', 'INDEXH', 'INDEXL', "INDEXO", "INDEXV", 'INDEXDEC', 'INDEXADV') :
|
|
236
|
-
self.IsNeedIndexData=True
|
|
237
|
-
return
|
|
238
|
-
|
|
239
|
-
if varName in ('CLOSE','C','VOL','V','OPEN','O','HIGH','H','LOW','L','AMOUNT') :
|
|
240
|
-
self.IsNeedSymbolData=True
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
#流通股本(手)
|
|
244
|
-
if varName=='CAPITAL' :
|
|
245
|
-
item=JobItem(id=JS_EXECUTE_JOB_ID.JOB_DOWNLOAD_CAPITAL_DATA, varName=varName)
|
|
246
|
-
self.NeedFinanceData.append(item)
|
|
247
|
-
|
|
248
|
-
# 换手率
|
|
249
|
-
if varName == 'EXCHANGE' :
|
|
250
|
-
item=JobItem(id=JS_EXECUTE_JOB_ID.JOB_DOWNLOAD_EXCHANGE_DATA, varName=varName)
|
|
251
|
-
self.NeedFinanceData.append(item)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
def VerifySymbolFunction(self, callee,args) :
|
|
255
|
-
if callee.Name=='DYNAINFO' :
|
|
256
|
-
self.IsNeedLatestData=True
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
# 财务函数
|
|
260
|
-
if callee.Name=='FINANCE' :
|
|
261
|
-
jobID=JS_EXECUTE_JOB_ID.GetFinnanceJobID(args[0].Value)
|
|
262
|
-
item=JobItem(id=jobID, funcName=callee.Name, args=args)
|
|
263
|
-
self.NeedFinanceData.append(item)
|
|
264
|
-
return
|
|
265
|
-
|
|
266
|
-
if callee.Name == 'MARGIN' :
|
|
267
|
-
jobID = JS_EXECUTE_JOB_ID.GetMarginJobID(args[0].Value)
|
|
268
|
-
if jobID not in self.IsNeedMarginData :
|
|
269
|
-
self.IsNeedMarginData.add(jobID)
|
|
270
|
-
return
|
|
271
|
-
|
|
272
|
-
if callee.Name == 'NEWS' :
|
|
273
|
-
jobID = JS_EXECUTE_JOB_ID.GetNewsAnalysisID(args[0].Value)
|
|
274
|
-
if jobID not in self.IsNeedNewsAnalysisData :
|
|
275
|
-
self.IsNeedNewsAnalysisData.add(jobID)
|
|
276
|
-
return
|
|
277
|
-
|
|
278
|
-
if callee.Name in ( 'COST', 'WINNER', 'PPART', 'COSTEX', 'LWINNER', 'PWINNER' ) : # 筹码需要流通股
|
|
279
|
-
argItem=Variant()
|
|
280
|
-
argItem.Value=7
|
|
281
|
-
item=JobItem(id=JS_EXECUTE_JOB_ID.JOB_DOWNLOAD_FLOW_EQUITY_DATA, funcName=callee.Name, args=[argItem])
|
|
282
|
-
self.NeedFinanceData.append(item)
|
|
283
|
-
return
|
|
284
|
-
|
|
285
|
-
if callee.Name == 'BETA' : # beta需要下载上证指数
|
|
286
|
-
self.IsNeedIndexData = True
|
|
287
|
-
return
|
|
288
|
-
|
|
289
|
-
if callee.Name == 'UPCOUNT' or callee.Name == 'DOWNCOUNT' : # 上涨下跌个数
|
|
290
|
-
blockSymbol = args[0].Value
|
|
291
|
-
if blockSymbol not in self.IsNeedBlockIncreaseData:
|
|
292
|
-
self.IsNeedBlockIncreaseData.add(blockSymbol)
|
|
293
|
-
return
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
def ExpressionStatement(self, expression) :
|
|
297
|
-
return ExpressionStatement(expression=expression) # { Type:Syntax.ExpressionStatement, Expression:expression }
|
|
298
|
-
|
|
299
|
-
def Script(self, body) :
|
|
300
|
-
return Script(body=body, sourceType='通达信脚本') #{Type:Syntax.Program, Body:body, SourceType:'通达信脚本' }
|
|
301
|
-
|
|
302
|
-
def SequenceExpression(self, expression) :
|
|
303
|
-
return SequenceExpression(expressions=expression) # {Type:Syntax.SequenceExpression, Expression:expression }
|
|
304
|
-
|
|
305
|
-
def BinaryExpression(self, operator, left, right) :
|
|
306
|
-
logical = operator in ( '||' ,'&&' ,'AND' , 'OR')
|
|
307
|
-
type = Syntax.LogicalExpression if logical else Syntax.BinaryExpression
|
|
308
|
-
return BinaryExpression(type=type, operator=operator, left=left, right=right) # { Type:type, Operator:operator, Left:left, Right:right }
|
|
309
|
-
|
|
310
|
-
def Literal(self,value,raw) :
|
|
311
|
-
return Literal(value=value, raw=raw) # { Type:Syntax.Literal, Value:value, Raw:raw }
|
|
312
|
-
|
|
313
|
-
def Identifier(self, name) :
|
|
314
|
-
self.VerifySymbolVariable(name)
|
|
315
|
-
return Identifier(name=name) # { Type:Syntax.Identifier, Name:name}
|
|
316
|
-
|
|
317
|
-
def AssignmentExpression(self, operator, left, right) :
|
|
318
|
-
return AssignmentExpression(operator=operator, left=left, right=right) # { Type:Syntax.AssignmentExpression, Operator:operator, Left:left, Right:right }
|
|
319
|
-
|
|
320
|
-
def UnaryExpression(self, operator, argument) :
|
|
321
|
-
return UnaryExpression(operator=operator,argument=argument) # { Type:Syntax.UnaryExpression, Operator:operator, Argument:argument, Prefix:True }
|
|
322
|
-
|
|
323
|
-
def EmptyStatement(self) :
|
|
324
|
-
return EmptyStatement() # { Type:Syntax.EmptyStatement }
|
|
325
|
-
|
|
326
|
-
def CallExpression(self, callee, args) :
|
|
327
|
-
self.VerifySymbolFunction(callee, args)
|
|
328
|
-
return CallExpression(callee=callee, arguments=args) # { Type:Syntax.CallExpression, Callee:callee, Arguments:args }
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
####################################################################################
|
|
332
|
-
#
|
|
333
|
-
# 语法分析
|
|
334
|
-
#
|
|
335
|
-
#######################################################################################
|
|
336
|
-
class Marker():
|
|
337
|
-
def __init__(self, index=None, line=None, column=None):
|
|
338
|
-
self.Index = index
|
|
339
|
-
self.Line = line
|
|
340
|
-
self.Column = column
|
|
341
|
-
|
|
342
|
-
class Context(object):
|
|
343
|
-
def __init__(self, isModule=False, allowAwait=False, allowIn=True, allowStrictDirective=True, allowYield=True, firstCoverInitializedNameError=None, isAssignmentTarget=False, isBindingElement=False, inFunctionBody=False, inIteration=False, inSwitch=False, labelSet=None, strict=False):
|
|
344
|
-
self.IsModule = isModule
|
|
345
|
-
self.AllowAwait = allowAwait
|
|
346
|
-
self.AllowIn = allowIn
|
|
347
|
-
self.AllowStrictDirective = allowStrictDirective
|
|
348
|
-
self.AllowYield = allowYield
|
|
349
|
-
self.FirstCoverInitializedNameError = firstCoverInitializedNameError
|
|
350
|
-
self.IsAssignmentTarget = isAssignmentTarget
|
|
351
|
-
self.IsBindingElement = isBindingElement
|
|
352
|
-
self.InFunctionBody = inFunctionBody
|
|
353
|
-
self.InIteration = inIteration
|
|
354
|
-
self.InSwitch = inSwitch
|
|
355
|
-
self.LabelSet = {} if labelSet is None else labelSet
|
|
356
|
-
self.Strict = strict
|
|
357
|
-
|
|
358
|
-
class JSParser:
|
|
359
|
-
def __init__(self, code, options={}, delegate=None) :
|
|
360
|
-
self.ErrorHandler=ErrorHandler()
|
|
361
|
-
self.Scanner=Scanner(code, self.ErrorHandler)
|
|
362
|
-
self.Node= Node() #节点创建
|
|
363
|
-
|
|
364
|
-
self.LookAhead=RawToken(type=2, value='', lineNumber=self.Scanner.LineNumber, lineStart=0, start=0, end=0 )
|
|
365
|
-
self.HasLineTerminator=False
|
|
366
|
-
self.Context = Context(isModule=False, allowAwait=False, allowIn=True, allowStrictDirective=True, allowYield= True,
|
|
367
|
-
firstCoverInitializedNameError=None, isAssignmentTarget=False, isBindingElement=False, inFunctionBody=False,
|
|
368
|
-
inIteration=False,inSwitch=False, labelSet= {}, strict=False)
|
|
369
|
-
|
|
370
|
-
self.OperatorPrecedence = {
|
|
371
|
-
')': 0,
|
|
372
|
-
';': 0,
|
|
373
|
-
',': 0,
|
|
374
|
-
']': 0,
|
|
375
|
-
'||': 1,
|
|
376
|
-
'OR':1,
|
|
377
|
-
'&&': 2,
|
|
378
|
-
'AND':2,
|
|
379
|
-
'|': 3,
|
|
380
|
-
'^': 4,
|
|
381
|
-
'&': 5,
|
|
382
|
-
'==': 6,
|
|
383
|
-
'!=': 6,
|
|
384
|
-
'<>': 6,
|
|
385
|
-
'===': 6,
|
|
386
|
-
'=': 6,
|
|
387
|
-
'!==': 6,
|
|
388
|
-
'<': 7,
|
|
389
|
-
'>': 7,
|
|
390
|
-
'<=': 7,
|
|
391
|
-
'>=': 7,
|
|
392
|
-
'<<': 8,
|
|
393
|
-
'>>': 8,
|
|
394
|
-
'>>>': 8,
|
|
395
|
-
'+': 9,
|
|
396
|
-
'-': 9,
|
|
397
|
-
'*': 11,
|
|
398
|
-
'/': 11,
|
|
399
|
-
'%': 11,
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
self.StartMarker = Marker(index=0, line=self.Scanner.LineNumber, column=0)
|
|
403
|
-
self.LastMarker = Marker(index=0, line=self.Scanner.LineNumber, column=0)
|
|
404
|
-
|
|
405
|
-
def Initialize(self) :
|
|
406
|
-
self.NextToken()
|
|
407
|
-
self.LastMarker=Marker(index=self.Scanner.Index, line=self.Scanner.LineNumber, column=self.Scanner.Index-self.Scanner.LineStart)
|
|
408
|
-
|
|
409
|
-
def CreateNode(self) :
|
|
410
|
-
return Marker(index=self.StartMarker.Index, line=self.StartMarker.Line, column=self.StartMarker.Column)
|
|
411
|
-
|
|
412
|
-
def StartNode(self, token, lastLineStart=0):
|
|
413
|
-
column = token.Start - token.LineStart
|
|
414
|
-
line = token.LineNumber
|
|
415
|
-
if column < 0 :
|
|
416
|
-
column += lastLineStart
|
|
417
|
-
line-=1
|
|
418
|
-
|
|
419
|
-
return Marker(index=token.Start, line= line, column=column)
|
|
420
|
-
|
|
421
|
-
def Match(self, value) :
|
|
422
|
-
return self.LookAhead.Type==7 and self.LookAhead.Value==value # 7=Punctuator
|
|
423
|
-
|
|
424
|
-
def Expect(self, value) :
|
|
425
|
-
token=self.NextToken()
|
|
426
|
-
if token.Type!=7 or token.Value!=value : # 7=Punctuator
|
|
427
|
-
self.ThrowUnexpectedToken(token)
|
|
428
|
-
|
|
429
|
-
# 是否是赋值操作符
|
|
430
|
-
def MatchAssign(self) :
|
|
431
|
-
if self.LookAhead.Type!=7 :
|
|
432
|
-
return False #7=Punctuator
|
|
433
|
-
op=self.LookAhead.Value
|
|
434
|
-
return op in (':', ':=')
|
|
435
|
-
|
|
436
|
-
def GetTokenRaw(self, token) :
|
|
437
|
-
return self.Scanner.Source[token.Start : token.End]
|
|
438
|
-
|
|
439
|
-
def NextToken(self) :
|
|
440
|
-
token=self.LookAhead
|
|
441
|
-
self.LastMarker.Index=self.Scanner.Index
|
|
442
|
-
self.LastMarker.Line=self.Scanner.LineNumber
|
|
443
|
-
self.LastMarker.Column=self.Scanner.Index-self.Scanner.LineStart
|
|
444
|
-
self.CollectComments() # 过滤注释 空格
|
|
445
|
-
|
|
446
|
-
if self.Scanner.Index != self.StartMarker.Index :
|
|
447
|
-
self.StartMarker.Index = self.Scanner.Index
|
|
448
|
-
self.StartMarker.Line = self.Scanner.LineNumber
|
|
449
|
-
self.StartMarker.Column = self.Scanner.Index - self.Scanner.LineStart
|
|
450
|
-
|
|
451
|
-
next=self.Scanner.Lex()
|
|
452
|
-
self.HasLineTerminator= token.LineNumber!=next.LineNumber
|
|
453
|
-
if next and self.Context.Strict and next.Type==3 : #3=Identifier
|
|
454
|
-
print ('[JSParser::NextToken] not support')
|
|
455
|
-
|
|
456
|
-
self.LookAhead=next
|
|
457
|
-
|
|
458
|
-
return token
|
|
459
|
-
|
|
460
|
-
def CollectComments(self) :
|
|
461
|
-
self.Scanner.ScanComments()
|
|
462
|
-
|
|
463
|
-
def ParseScript(self) :
|
|
464
|
-
node=self.CreateNode()
|
|
465
|
-
body=self.ParseDirectivePrologues()
|
|
466
|
-
|
|
467
|
-
while self.LookAhead.Type!=2: #2=/*EOF*/)
|
|
468
|
-
body.append(self.ParseStatementListItem())
|
|
469
|
-
|
|
470
|
-
return self.Finalize(node,self.Node.Script(body))
|
|
471
|
-
|
|
472
|
-
# https://tc39.github.io/ecma262/#sec-directive-prologues-and-the-use-strict-directive
|
|
473
|
-
def ParseDirective(self):
|
|
474
|
-
token=self.LookAhead
|
|
475
|
-
node=self.CreateNode()
|
|
476
|
-
expr=self.ParseExpression()
|
|
477
|
-
return None
|
|
478
|
-
|
|
479
|
-
def ParseDirectivePrologues(self) :
|
|
480
|
-
firstRestricted=None
|
|
481
|
-
body=[]
|
|
482
|
-
while True :
|
|
483
|
-
token=self.LookAhead
|
|
484
|
-
if token.Type!=8 : #8=/*StringLiteral*
|
|
485
|
-
break
|
|
486
|
-
statement = self.ParseDirective()
|
|
487
|
-
body.append(statement)
|
|
488
|
-
|
|
489
|
-
return body
|
|
490
|
-
|
|
491
|
-
# https://tc39.github.io/ecma262/#sec-block
|
|
492
|
-
def ParseStatementListItem(self) :
|
|
493
|
-
statement=None
|
|
494
|
-
self.Context.IsAssignmentTarget=True
|
|
495
|
-
self.Context.IsBindingElement=True
|
|
496
|
-
if self.LookAhead.Type==4 : # 4=/*Keyword*/
|
|
497
|
-
pass
|
|
498
|
-
else :
|
|
499
|
-
statement=self.ParseStatement()
|
|
500
|
-
|
|
501
|
-
return statement
|
|
502
|
-
|
|
503
|
-
# https://tc39.github.io/ecma262/#sec-ecmascript-language-statements-and-declarations
|
|
504
|
-
def ParseStatement(self):
|
|
505
|
-
statement=None
|
|
506
|
-
type = self.LookAhead.Type
|
|
507
|
-
if type in (1,5,6,8,10,9) : # BooleanLiteral, NullLiteral, NumericLiteral, StringLiteral, Template, RegularExpression
|
|
508
|
-
statement = self.ParseExpressionStatement()
|
|
509
|
-
|
|
510
|
-
elif type==7 : # 7=/* Punctuator */:
|
|
511
|
-
value = self.LookAhead.Value
|
|
512
|
-
if value == '(' :
|
|
513
|
-
statement = self.ParseExpressionStatement()
|
|
514
|
-
elif value == ';' :
|
|
515
|
-
statement = self.ParseEmptyStatement()
|
|
516
|
-
else :
|
|
517
|
-
statement = self.ParseExpressionStatement()
|
|
518
|
-
|
|
519
|
-
elif type==3 : # 3=/* Identifier */:
|
|
520
|
-
statement = self.ParseLabelledStatement()
|
|
521
|
-
|
|
522
|
-
elif type==4: # 4= /* Keyword */
|
|
523
|
-
print('[JSParser::ParseStatementListItem] not support Keyword')
|
|
524
|
-
else :
|
|
525
|
-
statement="error"
|
|
526
|
-
|
|
527
|
-
return statement
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
# https://tc39.github.io/ecma262/#sec-empty-statement
|
|
531
|
-
def ParseEmptyStatement(self):
|
|
532
|
-
node=self.CreateNode()
|
|
533
|
-
self.Expect(';')
|
|
534
|
-
return self.Finalize(node, self.Node.EmptyStatement())
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
# https://tc39.github.io/ecma262/#sec-labelled-statements
|
|
538
|
-
def ParseLabelledStatement(self):
|
|
539
|
-
node=self.CreateNode()
|
|
540
|
-
expr=self.ParseExpression()
|
|
541
|
-
self.ConsumeSemicolon()
|
|
542
|
-
statement = self.Node.ExpressionStatement(expr)
|
|
543
|
-
|
|
544
|
-
return self.Finalize(node, statement)
|
|
545
|
-
|
|
546
|
-
# https://tc39.github.io/ecma262/#sec-comma-operator
|
|
547
|
-
def ParseExpression(self) :
|
|
548
|
-
startToken=self.LookAhead
|
|
549
|
-
expr=self.IsolateCoverGrammar(self.ParseAssignmentExpression)
|
|
550
|
-
if self.Match(',') :
|
|
551
|
-
expressions=[]
|
|
552
|
-
expressions.append(expr)
|
|
553
|
-
while self.LookAhead.Type!=2 : #/*EOF*/
|
|
554
|
-
if not self.Match(',') :
|
|
555
|
-
break
|
|
556
|
-
self.NextToken()
|
|
557
|
-
expressions.append(self.IsolateCoverGrammar(self.ParseAssignmentExpression))
|
|
558
|
-
|
|
559
|
-
expr=self.Finalize(self.StartNode(startToken),self.Node.SequenceExpression(expressions))
|
|
560
|
-
|
|
561
|
-
return expr
|
|
562
|
-
|
|
563
|
-
def ParseAssignmentExpression(self) :
|
|
564
|
-
expr=None
|
|
565
|
-
startToken=self.LookAhead
|
|
566
|
-
token=startToken
|
|
567
|
-
expr=self.ParseConditionalExpression()
|
|
568
|
-
|
|
569
|
-
if self.MatchAssign() :
|
|
570
|
-
if not self.Context.IsAssignmentTarget :
|
|
571
|
-
marker=expr.Marker
|
|
572
|
-
self.ThrowUnexpectedError(marker.Index,marker.Line,marker.Column,Messages.InvalidLHSInAssignment)
|
|
573
|
-
|
|
574
|
-
if not self.Match('=') and not self.Match(':') :
|
|
575
|
-
self.Context.IsAssignmentTarget=False
|
|
576
|
-
self.Context.IsBindingElement=False
|
|
577
|
-
else :
|
|
578
|
-
self.ReinterpretExpressionAsPattern(expr)
|
|
579
|
-
|
|
580
|
-
token=self.NextToken()
|
|
581
|
-
operator=token.Value
|
|
582
|
-
right=self.IsolateCoverGrammar(self.ParseAssignmentExpression)
|
|
583
|
-
expr=self.Finalize(self.StartNode(startToken), self.Node.AssignmentExpression(operator, expr, right))
|
|
584
|
-
self.Context.FirstCoverInitializedNameError=None
|
|
585
|
-
|
|
586
|
-
return expr
|
|
587
|
-
|
|
588
|
-
def ParseConditionalExpression(self) :
|
|
589
|
-
startToken=self.LookAhead
|
|
590
|
-
expr=self.InheritCoverGrammar(self.ParseBinaryExpression)
|
|
591
|
-
|
|
592
|
-
return expr
|
|
593
|
-
|
|
594
|
-
def ParseBinaryExpression(self) :
|
|
595
|
-
startToken=self.LookAhead
|
|
596
|
-
expr=self.InheritCoverGrammar(self.ParseExponentiationExpression)
|
|
597
|
-
token=self.LookAhead
|
|
598
|
-
prec=self.BinaryPrecedence(token)
|
|
599
|
-
if prec>0 :
|
|
600
|
-
self.NextToken()
|
|
601
|
-
self.Context.IsAssignmentTarget=False
|
|
602
|
-
self.Context.IsBindingElement=False
|
|
603
|
-
markers=[startToken,self.LookAhead]
|
|
604
|
-
left=expr
|
|
605
|
-
right=self.IsolateCoverGrammar(self.ParseExponentiationExpression)
|
|
606
|
-
stack=[left,token.Value,right]
|
|
607
|
-
precedences = [prec]
|
|
608
|
-
while True :
|
|
609
|
-
prec=self.BinaryPrecedence(self.LookAhead)
|
|
610
|
-
if prec<=0 :
|
|
611
|
-
break
|
|
612
|
-
|
|
613
|
-
while len(stack)>2 and prec<=precedences[-1] :
|
|
614
|
-
right=stack.pop()
|
|
615
|
-
operator=stack.pop()
|
|
616
|
-
precedences.pop()
|
|
617
|
-
left=stack.pop()
|
|
618
|
-
markers.pop()
|
|
619
|
-
node=self.StartNode(markers[-1])
|
|
620
|
-
stack.append(self.Finalize(node, self.Node.BinaryExpression(operator, left, right)))
|
|
621
|
-
|
|
622
|
-
# Shift
|
|
623
|
-
stack.append(self.NextToken().Value)
|
|
624
|
-
precedences.append(prec)
|
|
625
|
-
markers.append(self.LookAhead)
|
|
626
|
-
stack.append(self.IsolateCoverGrammar(self.ParseExponentiationExpression))
|
|
627
|
-
|
|
628
|
-
i=len(stack)-1
|
|
629
|
-
expr=stack[i]
|
|
630
|
-
lastMarker=markers.pop()
|
|
631
|
-
while i>1 :
|
|
632
|
-
marker=markers.pop()
|
|
633
|
-
lastLineStart=lastMarker and lastMarker.LineStart
|
|
634
|
-
node=self.StartNode(marker, lastLineStart)
|
|
635
|
-
operator=stack[i-1]
|
|
636
|
-
expr=self.Finalize(node, self.Node.BinaryExpression(operator, stack[i - 2], expr))
|
|
637
|
-
i-=2
|
|
638
|
-
lastMarker=marker
|
|
639
|
-
|
|
640
|
-
return expr
|
|
641
|
-
|
|
642
|
-
def ParseExponentiationExpression(self) :
|
|
643
|
-
startToken=self.LookAhead
|
|
644
|
-
expr=self.InheritCoverGrammar(self.ParseUnaryExpression)
|
|
645
|
-
|
|
646
|
-
return expr
|
|
647
|
-
|
|
648
|
-
def ParseUnaryExpression(self) :
|
|
649
|
-
expr=None
|
|
650
|
-
if self.Match('+') or self.Match('-') :
|
|
651
|
-
node=self.StartNode(self.LookAhead)
|
|
652
|
-
token=self.NextToken()
|
|
653
|
-
expr=self.InheritCoverGrammar(self.ParseUnaryExpression)
|
|
654
|
-
expr=self.Finalize(node, self.Node.UnaryExpression(token.Value, expr))
|
|
655
|
-
self.Context.IsAssignmentTarget=False
|
|
656
|
-
self.Context.IsBindingElement=False
|
|
657
|
-
else :
|
|
658
|
-
expr=self.ParseUpdateExpression()
|
|
659
|
-
|
|
660
|
-
return expr
|
|
661
|
-
|
|
662
|
-
# https://tc39.github.io/ecma262/#sec-update-expressions
|
|
663
|
-
def ParseUpdateExpression(self) :
|
|
664
|
-
startToken=self.LookAhead
|
|
665
|
-
expr=self.InheritCoverGrammar(self.ParseLeftHandSideExpressionAllowCall)
|
|
666
|
-
|
|
667
|
-
return expr
|
|
668
|
-
|
|
669
|
-
def ParseLeftHandSideExpressionAllowCall(self) :
|
|
670
|
-
startToken=self.LookAhead
|
|
671
|
-
expr=self.InheritCoverGrammar(self.ParsePrimaryExpression)
|
|
672
|
-
|
|
673
|
-
while True :
|
|
674
|
-
if self.Match('(') :
|
|
675
|
-
self.Context.IsBindingElement=False
|
|
676
|
-
self.Context.IsAssignmentTarget=False
|
|
677
|
-
args=self.ParseArguments() # 解析 调用参数
|
|
678
|
-
expr=self.Finalize(self.StartNode(startToken), self.Node.CallExpression(expr,args))
|
|
679
|
-
else :
|
|
680
|
-
break
|
|
681
|
-
|
|
682
|
-
return expr
|
|
683
|
-
|
|
684
|
-
# https://tc39.github.io/ecma262/#sec-left-hand-side-expressions
|
|
685
|
-
def ParseArguments(self) :
|
|
686
|
-
self.Expect('(')
|
|
687
|
-
args=[]
|
|
688
|
-
if not self.Match(')') :
|
|
689
|
-
while True :
|
|
690
|
-
expr=self.IsolateCoverGrammar(self.ParseAssignmentExpression)
|
|
691
|
-
args.append(expr)
|
|
692
|
-
|
|
693
|
-
if self.Match(')') :
|
|
694
|
-
break
|
|
695
|
-
|
|
696
|
-
self.ExpectCommaSeparator()
|
|
697
|
-
|
|
698
|
-
if self.Match(')'):
|
|
699
|
-
break
|
|
700
|
-
|
|
701
|
-
self.Expect(')')
|
|
702
|
-
return args
|
|
703
|
-
|
|
704
|
-
# Quietly expect a comma when in tolerant mode, otherwise delegates to expect().
|
|
705
|
-
def ExpectCommaSeparator(self) :
|
|
706
|
-
self.Expect(',')
|
|
707
|
-
|
|
708
|
-
# https://tc39.github.io/ecma262/#sec-primary-expression
|
|
709
|
-
def ParsePrimaryExpression(self) :
|
|
710
|
-
node=self.CreateNode()
|
|
711
|
-
type=self.LookAhead.Type
|
|
712
|
-
if type==3 : # Identifier
|
|
713
|
-
expr=self.Finalize(node, self.Node.Identifier(self.NextToken().Value))
|
|
714
|
-
elif type in (6,8) : # 6=NumericLiteral, 8=StringLiteral
|
|
715
|
-
self.Context.IsAssignmentTarget=False
|
|
716
|
-
self.Context.IsBindingElement=False
|
|
717
|
-
token=self.NextToken()
|
|
718
|
-
raw=self.GetTokenRaw(token)
|
|
719
|
-
expr=self.Finalize(node, self.Node.Literal(token.Value,raw))
|
|
720
|
-
elif type==7 : # 7=Punctuator
|
|
721
|
-
value=self.LookAhead.Value
|
|
722
|
-
if value=='(':
|
|
723
|
-
self.Context.IsBindingElement=False
|
|
724
|
-
expr=self.InheritCoverGrammar(self.ParseGroupExpression)
|
|
725
|
-
else :
|
|
726
|
-
self.ThrowUnexpectedToken(self.NextToken())
|
|
727
|
-
else :
|
|
728
|
-
self.ThrowUnexpectedToken(self.NextToken())
|
|
729
|
-
|
|
730
|
-
return expr
|
|
731
|
-
|
|
732
|
-
def ParseGroupExpression(self) :
|
|
733
|
-
self.Expect('(')
|
|
734
|
-
if self.Match(')') :
|
|
735
|
-
self.NextToken()
|
|
736
|
-
else :
|
|
737
|
-
startToken=self.LookAhead
|
|
738
|
-
params=[]
|
|
739
|
-
arrow=False
|
|
740
|
-
self.Context.IsBindingElement=True
|
|
741
|
-
expr=self.InheritCoverGrammar(self.ParseAssignmentExpression)
|
|
742
|
-
if self.Match(',') :
|
|
743
|
-
expressions=[]
|
|
744
|
-
self.Context.IsAssignmentTarget=False
|
|
745
|
-
expressions.append(expr)
|
|
746
|
-
while self.LookAhead.Type!=2 : # /* EOF */)
|
|
747
|
-
if not self.Match(',') :
|
|
748
|
-
break
|
|
749
|
-
|
|
750
|
-
self.NextToken()
|
|
751
|
-
if not self.Match(')') :
|
|
752
|
-
self.NextToken()
|
|
753
|
-
|
|
754
|
-
if not arrow :
|
|
755
|
-
self.Expect(')')
|
|
756
|
-
self.Context.IsBindingElement=False
|
|
757
|
-
|
|
758
|
-
return expr
|
|
759
|
-
|
|
760
|
-
# https://tc39.github.io/ecma262/#sec-expression-statement
|
|
761
|
-
def ParseExpressionStatement(self) :
|
|
762
|
-
node=self.CreateNode()
|
|
763
|
-
expr=self.ParseExpression()
|
|
764
|
-
self.ConsumeSemicolon()
|
|
765
|
-
|
|
766
|
-
return self.Finalize(node,self.Node.ExpressionStatement(expr))
|
|
767
|
-
|
|
768
|
-
def ConsumeSemicolon(self) :
|
|
769
|
-
if self.Match(';') :
|
|
770
|
-
self.NextToken()
|
|
771
|
-
elif not self.HasLineTerminator :
|
|
772
|
-
# if (this.LookAhead.Type!=2/*EOF*/ && !this.Match('}'))
|
|
773
|
-
|
|
774
|
-
self.LastMarker.Index=self.StartMarker.Index
|
|
775
|
-
self.LastMarker.Line=self.StartMarker.Line
|
|
776
|
-
self.LastMarker.Column=self.StartMarker.Column
|
|
777
|
-
|
|
778
|
-
def ReinterpretExpressionAsPattern(self, expr) :
|
|
779
|
-
if expr.Type in (Syntax.Identifier, Syntax.AssignmentExpression) :
|
|
780
|
-
pass
|
|
781
|
-
else :
|
|
782
|
-
pass
|
|
783
|
-
|
|
784
|
-
def Finalize(self,marker,node) :
|
|
785
|
-
node.Marker=Marker( line=marker.Line, column=marker.Column, index=marker.Index )
|
|
786
|
-
return node
|
|
787
|
-
|
|
788
|
-
def BinaryPrecedence(self, token) :
|
|
789
|
-
op = token.Value
|
|
790
|
-
|
|
791
|
-
if token.Type == 7 : # /* Punctuator */
|
|
792
|
-
precedence = self.OperatorPrecedence.get(op, 0)
|
|
793
|
-
else :
|
|
794
|
-
precedence = 0
|
|
795
|
-
|
|
796
|
-
return precedence
|
|
797
|
-
|
|
798
|
-
def IsolateCoverGrammar(self, parseFunction) :
|
|
799
|
-
previousIsBindingElement=self.Context.IsBindingElement
|
|
800
|
-
previousIsAssignmentTarget=self.Context.IsAssignmentTarget
|
|
801
|
-
previousFirstCoverInitializedNameError=self.Context.FirstCoverInitializedNameError
|
|
802
|
-
|
|
803
|
-
self.Context.IsBindingElement=True
|
|
804
|
-
self.Context.IsAssignmentTarget=True
|
|
805
|
-
self.Context.FirstCoverInitializedNameError=None
|
|
806
|
-
result=parseFunction()
|
|
807
|
-
|
|
808
|
-
if self.Context.FirstCoverInitializedNameError is not None :
|
|
809
|
-
# 错误 this.throwUnexpectedToken(this.context.firstCoverInitializedNameError);
|
|
810
|
-
pass
|
|
811
|
-
|
|
812
|
-
self.Context.IsBindingElement=previousIsBindingElement
|
|
813
|
-
self.Context.IsAssignmentTarget=previousIsAssignmentTarget
|
|
814
|
-
self.Context.FirstCoverInitializedNameError=previousFirstCoverInitializedNameError
|
|
815
|
-
|
|
816
|
-
return result
|
|
817
|
-
|
|
818
|
-
def InheritCoverGrammar(self,parseFunction) :
|
|
819
|
-
previousIsBindingElement = self.Context.IsBindingElement
|
|
820
|
-
previousIsAssignmentTarget = self.Context.IsAssignmentTarget
|
|
821
|
-
previousFirstCoverInitializedNameError = self.Context.FirstCoverInitializedNameError
|
|
822
|
-
self.Context.IsBindingElement = True
|
|
823
|
-
self.Context.IsAssignmentTarget = True
|
|
824
|
-
self.Context.FirstCoverInitializedNameError = None
|
|
825
|
-
|
|
826
|
-
result = parseFunction()
|
|
827
|
-
|
|
828
|
-
self.Context.IsBindingElement = self.Context.IsBindingElement and previousIsBindingElement
|
|
829
|
-
self.Context.IsAssignmentTarget = self.Context.IsAssignmentTarget and previousIsAssignmentTarget
|
|
830
|
-
self.Context.FirstCoverInitializedNameError = previousFirstCoverInitializedNameError or self.Context.FirstCoverInitializedNameError
|
|
831
|
-
|
|
832
|
-
return result
|
|
833
|
-
|
|
834
|
-
def ThrowUnexpectedToken(self, token=None,message=None) :
|
|
835
|
-
raise self.UnexpectedTokenError(token,message)
|
|
836
|
-
|
|
837
|
-
def ThrowUnexpectedError(self, index,line,column,message=None) :
|
|
838
|
-
if message is not None :
|
|
839
|
-
msg=message
|
|
840
|
-
else :
|
|
841
|
-
msg="执行异常"
|
|
842
|
-
|
|
843
|
-
return self.ErrorHandler.ThrowError(index,line,column,msg)
|
|
844
|
-
|
|
845
|
-
def UnexpectedTokenError(self,token=None,message=None) :
|
|
846
|
-
msg=message or Messages.UnexpectedToken
|
|
847
|
-
value='ILLEGAL'
|
|
848
|
-
if token :
|
|
849
|
-
if not message :
|
|
850
|
-
pass
|
|
851
|
-
value=token.Value
|
|
852
|
-
|
|
853
|
-
msg=msg.replace("%0",unicode(value),1)
|
|
854
|
-
if token and isinstance(token.LineNumber, int) :
|
|
855
|
-
index=token.Start
|
|
856
|
-
line=token.LineNumber
|
|
857
|
-
lastMarkerLineStart=self.LastMarker.Index-self.LastMarker.Column
|
|
858
|
-
column=token.Start-lastMarkerLineStart+1
|
|
859
|
-
return self.ErrorHandler.CreateError(index,line,column,msg)
|
|
860
|
-
else :
|
|
861
|
-
index=self.LastMarker.Index
|
|
862
|
-
line=self.LastMarker.Line
|
|
863
|
-
column=self.LastMarker.Column+1
|
|
864
|
-
return self.ErrorHandler.CreateError(index,line,column,msg)
|