Created
March 28, 2022 14:52
-
-
Save BruJu/440d7fd1d64df8229928c9ba71ce4ed0 to your computer and use it in GitHub Desktop.
Logic Rule Debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* istanbul ignore next */ | |
debugString(): string { | |
let strRules: string[] = []; | |
function debugMeta(info: MetaInfo | null): string { | |
if (info === null) return '.'; | |
return "<< " + termToString(info.target) + " " + info.kind + " " + termToString(info.value) + " >>"; | |
} | |
function debugLogcRule(rule: LogicRule): string { | |
let b = ""; | |
if (rule.dataBody === null) { | |
b += "."; | |
} else { | |
b += termToString(rule.dataBody); | |
} | |
b += " + " + debugMeta(rule.metaBody) + " = " + debugMeta(rule.metaHead); | |
return b; | |
} | |
for (const [activator, rules] of this.dataPredicateToRules) { | |
for (const rule of rules) { | |
strRules.push( | |
termToString(activator) + " >>> " + debugLogcRule(rule) | |
); | |
} | |
} | |
for (const [a, b] of Object.entries(this.metaToRules)) { | |
for (const [activator, rules] of b) { | |
for (const rule of rules) { | |
strRules.push( | |
a + " " + termToString(activator) + " >>> " + debugLogcRule(rule) | |
); | |
} | |
} | |
} | |
for (const rule of this.axioms) { | |
strRules.push( | |
" >>> " + debugLogcRule(rule) | |
); | |
} | |
return strRules.map(r => "• " + r).join("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment