MCPcopy Create free account
hub / github.com/danja/dogalog / validatePrologCode

Function validatePrologCode

src/livecoding/codeValidator.js:8–20  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

6 * @returns {{ valid: boolean, clauses?: Array, error?: Error }}
7 */
8export function validatePrologCode(text) {
9 try {
10 const trimmed = text.trim();
11 if (trimmed.length === 0) {
12 return { valid: true, clauses: [] };
13 }
14 const normalized = trimmed.endsWith('.') ? trimmed : `${trimmed}.`;
15 const clauses = parseProgram(normalized);
16 return { valid: true, clauses };
17 } catch (error) {
18 return { valid: false, error };
19 }
20}

Callers 2

evaluateMethod · 0.90

Calls 1

parseProgramFunction · 0.90

Tested by

no test coverage detected