MCPcopy Create free account
hub / github.com/Script-Hub-Org/Script-Hub / parse

Method parse

Rewrite-Parser.js:2655–2680  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2653 }
2654
2655 parse() {
2656 // console.log('=== 开始语法分析 ===')
2657 if (this.tokens.length === 0) {
2658 throw new Error('输入为空')
2659 }
2660 const expr = this.parseExpression()
2661
2662 // 检查是否有剩余的路由策略
2663 if (this.position < this.tokens.length) {
2664 const remainingTokens = this.tokens.slice(this.position)
2665 if (
2666 remainingTokens.length >= 2 &&
2667 remainingTokens[0].type === 'COMMA' &&
2668 this.ROUTING_POLICIES.includes(remainingTokens[1].value.toUpperCase())
2669 ) {
2670 this.consume() // 消费逗号
2671 const routingPolicyToken = this.consume()
2672 expr.routingPolicy = routingPolicyToken.value.toUpperCase()
2673 } else {
2674 throw new Error(`意外的令牌 '${this.peek().value}' 在位置 ${this.position}`)
2675 }
2676 }
2677
2678 // console.log('=== 语法分析完成 ===')
2679 return expr
2680 }
2681
2682 parseExpression() {
2683 const token = this.peek()

Callers 15

parseRuleFunction · 0.95
toObjMethod · 0.45
getjsonMethod · 0.45
loaddataMethod · 0.45
getdataMethod · 0.45
setdataMethod · 0.45
toObjMethod · 0.45
getjsonMethod · 0.45
loaddataMethod · 0.45
getdataMethod · 0.45
setdataMethod · 0.45
script-hub.jsFile · 0.45

Calls 3

parseExpressionMethod · 0.95
consumeMethod · 0.95
peekMethod · 0.95

Tested by

no test coverage detected