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

Method parse

Rewrite-Parser.beta.js:3067–3092  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3065 }
3066
3067 parse() {
3068 // console.log('=== 开始语法分析 ===')
3069 if (this.tokens.length === 0) {
3070 throw new Error('输入为空')
3071 }
3072 const expr = this.parseExpression()
3073
3074 // 检查是否有剩余的路由策略
3075 if (this.position < this.tokens.length) {
3076 const remainingTokens = this.tokens.slice(this.position)
3077 if (
3078 remainingTokens.length >= 2 &&
3079 remainingTokens[0].type === 'COMMA' &&
3080 this.ROUTING_POLICIES.includes(remainingTokens[1].value.toUpperCase())
3081 ) {
3082 this.consume() // 消费逗号
3083 const routingPolicyToken = this.consume()
3084 expr.routingPolicy = routingPolicyToken.value.toUpperCase()
3085 } else {
3086 throw new Error(`意外的令牌 '${this.peek().value}' 在位置 ${this.position}`)
3087 }
3088 }
3089
3090 // console.log('=== 语法分析完成 ===')
3091 return expr
3092 }
3093
3094 parseExpression() {
3095 const token = this.peek()

Callers 8

parseRuleFunction · 0.95
parseLoonValueFunction · 0.45
toObjMethod · 0.45
getjsonMethod · 0.45
loaddataMethod · 0.45
getdataMethod · 0.45
setdataMethod · 0.45

Calls 3

parseExpressionMethod · 0.95
consumeMethod · 0.95
peekMethod · 0.95

Tested by

no test coverage detected