Update RuleAnalyzer.kt

平衡组区分内嵌{JSONPATH}和非内嵌JSONPATH
pull/1110/head
bushixuanqi 3 years ago committed by GitHub
parent 9180a4c40d
commit b2aefb0b8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/src/main/java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt

@ -10,6 +10,7 @@ class RuleAnalyzer(data: String, code:Boolean = false) {
private var start = 0 //每次处理字段的开始 private var start = 0 //每次处理字段的开始
private var startX = 0 //规则的开始 private var startX = 0 //规则的开始
private var innerStr: Boolean = false //true表示以平衡组的起点为规则起始,false表示不这样
private var step:Int = 0 //分割字符的长度 private var step:Int = 0 //分割字符的长度
val chompBalanced = if(code) ::chompCodeBalanced else ::chompRuleBalanced //设置平衡组函数,json或JavaScript时设置成chompCodeBalanced,否则为chompRuleBalanced val chompBalanced = if(code) ::chompCodeBalanced else ::chompRuleBalanced //设置平衡组函数,json或JavaScript时设置成chompCodeBalanced,否则为chompRuleBalanced
@ -229,7 +230,7 @@ class RuleAnalyzer(data: String, code:Boolean = false) {
} while (depth > 0 || otherDepth > 0) //拉出一个平衡字串 } while (depth > 0 || otherDepth > 0) //拉出一个平衡字串
return if(depth > 0 || otherDepth > 0) false else { return if(depth > 0 || otherDepth > 0) false else {
startX = this.pos //内嵌规则起始 if(innerStr)startX = this.pos //内嵌规则起始
this.pos = pos //同步位置 this.pos = pos //同步位置
true true
} }
@ -428,6 +429,8 @@ class RuleAnalyzer(data: String, code:Boolean = false) {
val start0 = pos //规则匹配前起点 val start0 = pos //规则匹配前起点
innerStr = true //设置平衡组以平衡组起点为规则起始点
val st = StringBuilder() val st = StringBuilder()
while (!isEmpty && consumeTo(inner)) { //拉取成功返回true,ruleAnalyzes里的字符序列索引变量pos后移相应位置,否则返回false,且isEmpty为true while (!isEmpty && consumeTo(inner)) { //拉取成功返回true,ruleAnalyzes里的字符序列索引变量pos后移相应位置,否则返回false,且isEmpty为true

Loading…
Cancel
Save