Ignore:
Timestamp:
Dec 9, 2014, 8:08:34 AM (5 years ago)
Author:
cameron
Message:

-e -f options for multiple regular expressions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/compiler.cpp

    r4287 r4328  
    1414#include <re/re_nullable.h>
    1515#include <re/re_simplifier.h>
     16#include <re/re_alt.h>
    1617#include <re/parsefailure.h>
    1718#include <re/re_parser.h>
    1819#include <re/re_compiler.h>
    19 #include "hrtime.h"
    2020#include <utf8_encoder.h>
    2121#include <cc/cc_compiler.h>
     
    4040namespace icgrep {
    4141
    42 LLVM_Gen_RetVal compile(const Encoding encoding, const std::string input_string, const bool show_compile_time, const bool enable_multiplexing) {
     42LLVM_Gen_RetVal compile(const Encoding encoding, const std::vector<std::string> regexps, const bool enable_multiplexing) {
     43    std::vector<RE *> REs;
    4344    RE * re_ast = nullptr;
    44     try
    45     {
    46         re_ast = RE_Parser::parse(input_string);
     45    for (int i = 0; i < regexps.size(); i++) {
     46        try
     47        {
     48            re_ast = RE_Parser::parse(regexps[i]);
     49        }
     50        catch (ParseFailure failure)
     51        {
     52            std::cerr << "REGEX PARSING FAILURE: " << failure.what() << std::endl;
     53            std::cerr << regexps[i] << std::endl;
     54            exit(1);
     55        }
     56        REs.push_back(re_ast);
    4757    }
    48     catch (ParseFailure failure)
    49     {
    50         std::cerr << "REGEX PARSING FAILURE: " << failure.what() << std::endl;
    51         std::cerr << input_string << std::endl;
    52         exit(1);
     58    if (REs.size() > 1) {
     59        re_ast = makeAlt(REs.begin(), REs.end());
    5360    }
    5461
     
    122129
    123130    PabloCompiler pablo_compiler(basisBits);
    124     unsigned long long cycles = 0;
    125     double timer = 0;
    126     if (show_compile_time)
    127     {
    128         cycles = get_hrcycles();
    129         timer = getElapsedTime();
    130     }
    131131
    132132    LLVM_Gen_RetVal retVal = pablo_compiler.compile(main);
    133     if (show_compile_time)
    134     {
    135         cycles = get_hrcycles() - cycles;
    136         timer = getElapsedTime() - timer;
    137         std::cout << "LLVM compile time -  cycles:       " << cycles  << std::endl;
    138         std::cout << "LLVM compile time -  milliseconds: " << timer << std::endl;
    139     }
    140133
    141134    PabloAST::release_memory();
Note: See TracChangeset for help on using the changeset viewer.