717ae1031e
Zanzibar-style authorization graph engine (direct/chain/TTU/defeasible/ binary modes, condensed snapshots, value relations) with 39 rigor test campaigns. Includes fixes for snapshot binary writer/reader format mismatch (snapshot-of-snapshot corruption), possibility write-boundary validation, empty-graph snapshot serialization, relation lookup cache direction collision, config-redefinition cache invalidation, binary threshold semantics, defeasible compiled routing, and comparator reason whitelisting.
52 lines
1.3 KiB
JavaScript
Executable File
52 lines
1.3 KiB
JavaScript
Executable File
#!/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);
|
|
}
|