commit 3bc50cb168985a7a7599fd9983ef1956e0c829c8 parent 19c4f1dea715e4e3d43732b20043d53ef87e7443 Author: Pranav Prabhu Kumble <kumblepranavprabhu@gmail.com> Date: Tue, 31 Mar 2026 09:59:59 +0530 Week 2: Add parser testing utility (Part 3: Finalizing) Diffstat:
| M | src/parser_tester.cpp | | | 23 | +++++++++++++++++++++++ |
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/parser_tester.cpp b/src/parser_tester.cpp @@ -72,3 +72,26 @@ int main(int argc, char* argv[]) { } std::cout << "Successfully built " << nfas.size() << " NFAs." << std::endl; + + // Optional Validation: NFA Simulation + if (!testStrings.empty()) { + std::cout << "\n--- NFA Simulation Results ---" << std::endl; + for (const auto& testStr : testStrings) { + std::cout << "String: \"" << testStr << "\"" << std::endl; + for (size_t i = 0; i < nfas.size(); ++i) { + bool matches = nfas[i]->simulate(testStr); + std::cout << " Regex [" << i << "] (" << originalRegexes[i] << "): " + << (matches ? "MATCH" : "NO MATCH") << std::endl; + } + std::cout << std::endl; + } + } + + // Future: Stage 3 — Verilog Emitter + // if (!nfas.empty()) { + // Emitter emitter(nfas); + // emitter.emit("output/"); + // } + + return 0; +}