refactor: extract Evidence DSL to @arbiter/evidence-dsl package
The Evidence DSL (ADR-000) compiles a natural DSL into core rule configurations — it is a separate concern from the engine. The AST had zero runtime coupling to the core (DSLCompiler takes the arbiter as a duck-typed argument; ip-utils were the only shared code, now local to the DSL package). This extraction removes the DSL surface from the core artifact entirely: - src/ast/ (748K, ~60 files) moved to @arbiter/evidence-dsl@1.0.0 - ip-utils moved with it (only the DSL consumed them) - generate-parser script + peggy devDep moved to the DSL package - the 8 DSL-consuming tests now import from @arbiter/evidence-dsl (deep-path exports: DSLCompiler, parser/*, generator/*, validation/*, interpreter/*) - package.json gains the devDependency, drops build:ast/generate:parser Tarball: AST-free. Rigor 251/251, full suite 838/776/0.
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Script to generate the DSL parser from Peggy grammar
|
||||
*/
|
||||
|
||||
import peggy from 'peggy';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const grammarPath = path.join(__dirname, '../src/ast/grammar/dsl.peggy');
|
||||
const outputPath = path.join(__dirname, '../src/ast/parser/GeneratedParser.js');
|
||||
|
||||
console.log('Generating DSL parser from Peggy grammar...');
|
||||
console.log('Grammar:', grammarPath);
|
||||
console.log('Output:', outputPath);
|
||||
|
||||
try {
|
||||
// Read the grammar file
|
||||
const grammar = fs.readFileSync(grammarPath, 'utf8');
|
||||
|
||||
// Generate the parser
|
||||
const parserSource = peggy.generate(grammar, {
|
||||
format: 'es',
|
||||
output: 'source',
|
||||
grammarSource: 'dsl.peggy'
|
||||
});
|
||||
|
||||
// Write the generated parser
|
||||
fs.writeFileSync(outputPath, parserSource);
|
||||
|
||||
console.log('✅ Parser generated successfully!');
|
||||
console.log('Generated file:', outputPath);
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Error generating parser:');
|
||||
console.error(error.message);
|
||||
|
||||
if (error.format) {
|
||||
console.error('\nFormatted error:');
|
||||
console.error(error.format([
|
||||
{ source: 'dsl.peggy', text: fs.readFileSync(grammarPath, 'utf8') }
|
||||
]));
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user