xiiregexbuilder

FPGA-Accelerated Regular Expression Matching Engine
commit e7faebb6ba14f20418524dd98261081bffad9d60
parent 93a0cc14179bd8a2756f5fd49b25358d299940ff
Author: Achuthan TM <achuthantm05@gmail.com>
Date:   Thu, 26 Mar 2026 10:00:00 +0530

Week 2: Integrate compiler passes in main (Part 1: Initial definitions)

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

diff --git a/src/main.cpp b/src/main.cpp @@ -0,0 +1,39 @@ +#include <iostream> +#include <fstream> +#include <string> +#include <vector> +#include <memory> +#include <regex> +#include <algorithm> +#include "lexer.h" +#include "parser.h" +#include "nfa.h" +#include "emitter.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] [output_dir]" << std::endl; + return 1; + } + + std::string regexFilename = argv[1]; + std::string testFilename = (argc > 2) ? argv[2] : ""; + std::string outputDir = (argc > 3) ? argv[3] : "output"; + + if (testFilename == "-" || testFilename == "none") { + testFilename = ""; + } + + std::ifstream regexFile(regexFilename); + if (!regexFile.is_open()) { + std::cerr << "Failed to open regex file: " << regexFilename << std::endl; + return 1; + } +