|
|
@ -10,8 +10,8 @@ data class Rule ( |
|
|
|
var extra: String? |
|
|
|
var extra: String? |
|
|
|
) { |
|
|
|
) { |
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
val JS_PATTERN = Regex("""\{\{([^}]+?)\}\}""") |
|
|
|
val JS_PATTERN = Regex("""\{\{([^}]+?)}}""") |
|
|
|
val CONST_PATTERN = Regex("""\{(\$\.[^}]+?)\}""") |
|
|
|
val CONST_PATTERN = Regex("""\{(\$\.[^}]+?)}""") |
|
|
|
|
|
|
|
|
|
|
|
fun parse(input: String) = when { |
|
|
|
fun parse(input: String) = when { |
|
|
|
input.startsWith("$.") -> parseJSON(input) |
|
|
|
input.startsWith("$.") -> parseJSON(input) |
|
|
@ -69,7 +69,7 @@ data class Rule ( |
|
|
|
for (line in rawRule.splitNotBlank("\n")) { |
|
|
|
for (line in rawRule.splitNotBlank("\n")) { |
|
|
|
subRule.clear() |
|
|
|
subRule.clear() |
|
|
|
val baseRule = BaseRule(type = RuleType.JSON) |
|
|
|
val baseRule = BaseRule(type = RuleType.JSON) |
|
|
|
baseRule.template = CONST_PATTERN.replace(line) { match -> |
|
|
|
baseRule.template = CONST_PATTERN.replace(line.replace("%", "%%")) { match -> |
|
|
|
subRule.add(match.groupValues[1]) |
|
|
|
subRule.add(match.groupValues[1]) |
|
|
|
"%s" |
|
|
|
"%s" |
|
|
|
} |
|
|
|
} |
|
|
|