xiiregexbuilder

FPGA-Accelerated Regular Expression Matching Engine
commit e298cda282f22b28115114d4c1aabc3c0b2572fb
parent b98cdd2ed1a02ffcd879c0abad800b27a10d02bd
Author: Pranav Prabhu Kumble <kumblepranavprabhu@gmail.com>
Date:   Fri, 27 Mar 2026 04:27:41 +0530

Week 2: Add parser testing utility (Part 1: Initial definitions)

Diffstat:
Asrc/parser_tester.cpp | 32++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/parser_tester.cpp b/src/parser_tester.cpp @@ -0,0 +1,32 @@ +#include <iostream> +#include <fstream> +#include <string> +#include <vector> +#include <algorithm> +#include "lexer.h" +#include "parser.h" +#include "nfa.h" + +std::string trim(const std::string& str) { + size_t first = str.find_first_not_of(" \t\r\n"); + if (first == std::string::npos) return ""; + size_t last = str.find_last_not_of(" \t\r\n"); + return str.substr(first, (last - first + 1)); +} + +int main(int argc, char* argv[]) { + if (argc < 2) { + std::cerr << "Usage: " << argv[0] << " <regex_file> [test_strings_file]" << std::endl; + return 1; + } + + std::string regexFilename = argv[1]; + std::ifstream regexFile(regexFilename); + if (!regexFile.is_open()) { + std::cerr << "Failed to open " << regexFilename << std::endl; + return 1; + } + + // Optional: Test strings for validation + std::string testFilename = (argc > 2) ? argv[2] : ""; + std::vector<std::string> testStrings;