xiiregexbuilder

FPGA-Accelerated Regular Expression Matching Engine
commit 9639da9d4aebf625f01e8b3987447850881bf3c4
parent 88f2f9885887916d3d699c62abc091396341bdec
Author: RahulSannapureddy <rahul.sannapureddy@gmail.com>
Date:   Thu, 26 Mar 2026 19:13:50 +0530

Week 2: Add golden C++ reference regex engine (Part 1: Initial definitions)

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

diff --git a/src/golden.cpp b/src/golden.cpp @@ -0,0 +1,31 @@ +#include <iostream> +#include <fstream> +#include <string> +#include <vector> +#include <regex> +#include <iomanip> +#include <algorithm> + +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 < 3) { + std::cerr << "Usage: " << argv[0] << " <regex_file> <test_strings_file> [output_file]" << std::endl; + return 1; + } + + std::string regexFilename = argv[1]; + std::string testFilename = argv[2]; + std::string outputFilename = (argc > 3) ? argv[3] : "expected_matches.txt"; + + std::ifstream regexFile(regexFilename); + if (!regexFile.is_open()) { + std::cerr << "Failed to open " << regexFilename << std::endl; + return 1; + } +