Ignore:
Timestamp:
May 5, 2016, 11:08:09 AM (3 years ago)
Author:
cameron
Message:

Restructure regular expression command flags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4980 r5030  
    55 */
    66#include <re/re_compiler.h>
     7#include <re/re_toolchain.h>
    78//Regular Expressions
    89#include <re/re_name.h>
     
    3536#include <unordered_set>
    3637
    37 static cl::OptionCategory fREcompilationOptions("Regex Compilation Options", "These options control the compilation of regular expressions to Pablo.");
    38 static cl::opt<bool> InvertMatches("v", cl::init(false),
    39                      cl::desc("select non-matching lines"), cl::cat(fREcompilationOptions));
    40 static cl::alias InvertMatchesLong("invert-matches", cl::desc("Alias for -v"), cl::aliasopt(InvertMatches));
    41 
    42 static cl::opt<bool> DisableLog2BoundedRepetition("disable-log2-bounded-repetition", cl::init(false),
    43                      cl::desc("disable log2 optimizations for bounded repetition of bytes"), cl::cat(fREcompilationOptions));
    44 static cl::opt<bool> DisableIfHierarchy("disable-if-hierarchy-strategy", cl::init(false),
    45                      cl::desc("disable nested if hierarchy for generated Unicode classes (not recommended)"), cl::cat(fREcompilationOptions));
    46 static cl::opt<int> IfInsertionGap("if-insertion-gap", cl::init(3), cl::desc("minimum number of nonempty elements between inserted if short-circuit tests"), cl::cat(fREcompilationOptions));
    47 static cl::opt<bool> DisableMatchStar("disable-matchstar", cl::init(false),
    48                      cl::desc("disable MatchStar optimization"), cl::cat(fREcompilationOptions));
    49 static cl::opt<bool> DisableUnicodeMatchStar("disable-unicode-matchstar", cl::init(false),
    50                      cl::desc("disable Unicode MatchStar optimization"), cl::cat(fREcompilationOptions));
    51 static cl::opt<bool> DisableUnicodeLineBreak("disable-unicode-linebreak", cl::init(false),
    52                      cl::desc("disable Unicode line breaks - use LF only"), cl::cat(fREcompilationOptions));
    53 
    54 #ifndef DISABLE_PREGENERATED_UCD_FUNCTIONS
    55 static cl::opt<bool> UsePregeneratedUnicode("use-pregenerated-unicode", cl::init(false),
    56                      cl::desc("use fixed pregenerated Unicode character class sets instead"), cl::cat(fREcompilationOptions));
    57 #endif
    58 
    59 #define UNICODE_LINE_BREAK (!DisableUnicodeLineBreak)
     38
     39#define UNICODE_LINE_BREAK (!AlgorithmOptionIsSet(DisableUnicodeLineBreak))
    6040
    6141using namespace pablo;
     
    173153                    } else {
    174154                        #ifndef DISABLE_PREGENERATED_UCD_FUNCTIONS
    175                         if (UsePregeneratedUnicode) {
     155                        if (AlgorithmOptionIsSet(UsePregeneratedUnicode)) {
    176156                            const std::string functionName = UCD::resolvePropertyFunction(name);
    177157                            const UCD::ExternalProperty & ep = UCD::resolveExternalProperty(functionName);
     
    307287    if (LLVM_LIKELY(nameMap.size() > 0)) {
    308288        UCD::UCDCompiler ucdCompiler(mCCCompiler);
    309         if (LLVM_UNLIKELY(DisableIfHierarchy)) {
     289        if (LLVM_UNLIKELY(AlgorithmOptionIsSet(DisableIfHierarchy))) {
    310290            ucdCompiler.generateWithoutIfHierarchy(nameMap, mPB);
    311291        } else {
     
    377357}
    378358
    379 void RE_Compiler::finalizeMatchResult(MarkerType match_result) {
     359void RE_Compiler::finalizeMatchResult(MarkerType match_result, bool InvertMatches) {
    380360    PabloAST * match_follow = mPB.createMatchStar(markerVar(match_result), mAny);
    381361    if (InvertMatches) {
     
    613593
    614594MarkerType RE_Compiler::processLowerBound(RE * repeated, int lb, MarkerType marker, PabloBuilder & pb) {
    615     if (!mGraphemeBoundaryRule && isByteLength(repeated) && !DisableLog2BoundedRepetition) {
     595    if (!mGraphemeBoundaryRule && isByteLength(repeated) && !AlgorithmOptionIsSet(DisableLog2BoundedRepetition)) {
    616596        PabloAST * cc = markerVar(compile(repeated, pb));
    617597        PabloAST * cc_lb = consecutive_matches(cc, 1, lb, pb);
     
    630610
    631611MarkerType RE_Compiler::processBoundedRep(RE * repeated, int ub, MarkerType marker, PabloBuilder & pb) {
    632     if (!mGraphemeBoundaryRule && isByteLength(repeated) && ub > 1 && !DisableLog2BoundedRepetition) {
     612    if (!mGraphemeBoundaryRule && isByteLength(repeated) && ub > 1 && !AlgorithmOptionIsSet(DisableLog2BoundedRepetition)) {
    633613        // log2 upper bound for fixed length (=1) class
    634614        // Create a mask of positions reachable within ub from current marker.
     
    656636    // always use PostPosition markers for unbounded repetition.
    657637    PabloAST * base = markerVar(AdvanceMarker(marker, MarkerPosition::InitialPostPositionByte, pb));
    658     if (!mGraphemeBoundaryRule && isByteLength(repeated)  && !DisableMatchStar) {
     638    if (!mGraphemeBoundaryRule && isByteLength(repeated)  && !AlgorithmOptionIsSet(DisableMatchStar)) {
    659639        PabloAST * cc = markerVar(compile(repeated, pb));
    660640        PabloAST * mstar = nullptr;
    661641        mstar = pb.createMatchStar(base, cc, "unbounded");
    662642        return makeMarker(MarkerPosition::InitialPostPositionByte, mstar);
    663     } else if (isUnicodeUnitLength(repeated) && !DisableMatchStar && !DisableUnicodeMatchStar) {
     643    } else if (isUnicodeUnitLength(repeated) && !AlgorithmOptionIsSet(DisableMatchStar) && !AlgorithmOptionIsSet(DisableUnicodeMatchStar)) {
    664644        PabloAST * cc = markerVar(compile(repeated, pb));
    665645        PabloAST * mstar = nullptr;
Note: See TracChangeset for help on using the changeset viewer.