From 8d01e09ca4c5a6b402e2ac7252ebc9f7617d9792 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Sat, 29 Mar 2025 22:56:15 +0100 Subject: [PATCH] index.ts actualy as test --- src/index.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/index.ts diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..bb91c23 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,38 @@ +/* eslint-disable no-console */ +import { writeFileSync } from 'fs'; +import { join } from 'path'; +import { HDLSignal } from './elements/HDLSignal'; +import { SignalExtractor } from './extractors/SignalExtractor'; +import { VHDLParser } from './parser/VHDLParser'; + +/** + * Main function to extract signals from a VHDL file and write them to a JSON file. + */ +async function main(): Promise { + const parser = new VHDLParser(); + await parser.init(); + + const filePath = join(__dirname, '../test/AsyncFIFO.vhd'); + const tree = await parser.parseFile(filePath); + + const extractor = new SignalExtractor(tree.rootNode, { + markerPrefix: '@', + stripPrefix: true, + }); + const signals: HDLSignal[] = extractor.extract(); + + const output = join(__dirname, '../test/signals.json'); + + writeFileSync( + output, + JSON.stringify( + signals.map((s) => s.info), + null, + 2, + ), + ); + + console.log('✅ Signals written to:', output); +} + +main().catch((e) => console.error('❌ Signal extraction failed:', e));