Changeset 6223


Ignore:
Timestamp:
Dec 12, 2018, 9:17:18 AM (2 months ago)
Author:
cameron
Message:

Contextual assertion simplifier from Jeremy Schwartz - initial check-in

Location:
icGREP/icgrep-devel/icgrep/re
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_alt.h

    r6195 r6223  
    119119}
    120120
    121 inline RE * makeAlt(RE::InitializerList list) {
     121inline RE * makeAlt(std::initializer_list<RE *> list) {
    122122    return makeAlt(list.begin(), list.end());
    123123}
    124124
    125 // An Alt with no members represent the empty set.
    126 inline bool isEmptySet(RE * r) {
    127     return llvm::isa<Alt>(r) && llvm::cast<Alt>(r)->empty();
    128 }
    129125}
    130126
  • icGREP/icgrep-devel/icgrep/re/re_diff.cpp

    r6169 r6223  
    77#include "re_diff.h"
    88#include <re/re_cc.h>
     9#include <re/re_seq.h>
    910#include <re/re_name.h>
     11#include <re/re_empty_set.h>
    1012#include <llvm/Support/Casting.h>
    1113
     
    1416namespace re {
    1517
     18#include <re/re_empty_set.h>
     19   
    1620RE * makeDiff(RE * lh, RE * rh) {
    17     return new Diff(lh, rh);
     21   
     22    if (LLVM_UNLIKELY(isEmptySeq(lh) && isEmptySeq(rh))) {
     23        return makeEmptySet();
     24    } else if (LLVM_UNLIKELY(isEmptySet(rh))) {
     25        return lh;
     26    } else if (LLVM_UNLIKELY(isEmptySet(lh))) {
     27        return makeEmptySet();
     28    } else {
     29        return new Diff(lh, rh);
     30    }
    1831}
    19    
     32
    2033}
  • icGREP/icgrep-devel/icgrep/re/re_intersect.h

    r6173 r6223  
    2020        return mRh;
    2121    }
     22    friend RE * makeIntersect(RE*, RE*);
    2223protected:
    23     friend RE * makeIntersect(RE*, RE*);
    2424    Intersect(RE * lh, RE * rh)
    2525    : RE(ClassTypeId::Intersect)
  • icGREP/icgrep-devel/icgrep/re/re_seq.h

    r6195 r6223  
    11/*
    2  *  Copyright (c) 2014 International Characters.
     2 *  Copyright (c) 2018 International Characters.
    33 *  This software is licensed to the public under the Open Software License 3.0.
    44 *  icgrep is a trademark of International Characters.
     
    1313#include <re/re_cc.h>
    1414#include <re/re_re.h>
     15#include <re/re_empty_set.h>
    1516#include <UCD/unicode_set.h>
    1617#include <llvm/Support/Casting.h>
     
    2627        return false;
    2728    }
    28     virtual ~Seq() {}
    2929protected:
    3030    friend Seq * makeSeq();
     
    4444    for (auto i = begin; i != end; ++i) {
    4545        RE * const item = *i;
    46         if (LLVM_UNLIKELY(llvm::isa<Seq>(item))) {
     46        if (LLVM_UNLIKELY(isEmptySet(item))) {
     47            return makeEmptySet();
     48        } else if (LLVM_UNLIKELY(llvm::isa<Seq>(item))) {
    4749            for (RE * const innerItem : *llvm::cast<Seq>(item)) {
    4850                seq->push_back(innerItem);
     
    5860}
    5961
    60 inline RE * makeSeq(RE::InitializerList list) {
     62inline RE * makeSeq(std::initializer_list<RE *> list) {
    6163    return makeSeq(list.begin(), list.end());
    6264}
  • icGREP/icgrep-devel/icgrep/re/re_toolchain.cpp

    r6208 r6223  
    3636
    3737#include <re/grapheme_clusters.h>
     38#include <re/re_contextual_simplification.h>
    3839#include <re/validation.h>
    3940#include <re/Unicode/decomposition.h>
     
    121122        r = simplifyRE(r);
    122123    }
     124    r = RE_ContextSimplifier().transformRE(r);
    123125    if (!DefiniteLengthBackReferencesOnly(r)) {
    124126        llvm::report_fatal_error("Future back reference support: references must be within a fixed distance from a fixed-length capture.");
Note: See TracChangeset for help on using the changeset viewer.