Changeset 4835


Ignore:
Timestamp:
Oct 14, 2015, 11:04:15 AM (2 years ago)
Author:
nmedfort
Message:

Minor changes to add grapheme boundary processing to RE analysis.

Location:
icGREP/icgrep-devel/icgrep
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_simplifier.cpp

    r4831 r4835  
    265265        if (isa<If>(stmt)) {
    266266            eliminateRedundantEquations(cast<If>(stmt)->getBody());
    267         }
    268         else if (isa<While>(stmt)) {
     267        } else if (isa<While>(stmt)) {
    269268            eliminateRedundantEquations(cast<While>(stmt)->getBody());
    270269        } else if (isa<Advance>(stmt)) {
  • icGREP/icgrep-devel/icgrep/re/re_analysis.cpp

    r4829 r4835  
    11#include "re_analysis.h"
    2 #include "re_cc.h"
    3 #include "re_name.h"
    4 #include "re_start.h"
    5 #include "re_end.h"
    6 #include "re_any.h"
    7 #include "re_seq.h"
    8 #include "re_alt.h"
    9 #include "re_rep.h"
    10 #include "re_diff.h"
    11 #include "re_intersect.h"
    12 #include "re_assertion.h"
     2#include <re/re_cc.h>
     3#include <re/re_name.h>
     4#include <re/re_start.h>
     5#include <re/re_end.h>
     6#include <re/re_any.h>
     7#include <re/re_seq.h>
     8#include <re/re_alt.h>
     9#include <re/re_rep.h>
     10#include <re/re_diff.h>
     11#include <re/re_intersect.h>
     12#include <re/re_assertion.h>
     13#include <re/re_grapheme_boundary.hpp>
    1314#include <iostream>
    1415#include <re/printer_re.h>
     
    2526        }
    2627        return true;
    27     }
    28     else if (const Seq * seq = dyn_cast<Seq>(re)) {
     28    } else if (const Seq * seq = dyn_cast<Seq>(re)) {
    2929        return (seq->size() == 1) && isByteLength(&seq[0]);
    30     }
    31     else if (const Rep * rep = dyn_cast<Rep>(re)) {
     30    } else if (const Rep * rep = dyn_cast<Rep>(re)) {
    3231        return (rep->getLB() == 1) && (rep->getUB() == 1) && isByteLength(rep->getRE());
    33     }
    34     else if (isa<Assertion>(re)) {
    35         return false;
    36     }
    37     else if (const Diff * diff = dyn_cast<Diff>(re)) {
     32    } else if (const Diff * diff = dyn_cast<Diff>(re)) {
    3833        return isByteLength(diff->getLH()) && isByteLength(diff->getRH());
    39     }
    40     else if (const Intersect * e = dyn_cast<Intersect>(re)) {
     34    } else if (const Intersect * e = dyn_cast<Intersect>(re)) {
    4135        return isByteLength(e->getLH()) && isByteLength(e->getRH());
    42     }
    43     else if (isa<Any>(re)) {
    44         return false;
    45     }
    46     else if (const Name * n = dyn_cast<Name>(re)) {
     36    } else if (const Name * n = dyn_cast<Name>(re)) {
    4737        return (n->getType() == Name::Type::Byte);
    4838    }
     
    5848        }
    5949        return true;
    60     }
    61     else if (const Seq * seq = dyn_cast<Seq>(re)) {
     50    } else if (const Seq * seq = dyn_cast<Seq>(re)) {
    6251        return (seq->size() == 1) && isUnicodeUnitLength(&seq[0]);
    63     }
    64     else if (const Rep * rep = dyn_cast<Rep>(re)) {
     52    } else if (const Rep * rep = dyn_cast<Rep>(re)) {
    6553        return (rep->getLB() == 1) && (rep->getUB() == 1) && isUnicodeUnitLength(rep->getRE());
    66     }
    67     else if (isa<Assertion>(re)) {
     54    } else if (isa<Assertion>(re)) {
    6855        return false;
    69     }
    70     else if (const Diff * diff = dyn_cast<Diff>(re)) {
     56    } else if (const Diff * diff = dyn_cast<Diff>(re)) {
    7157        return isUnicodeUnitLength(diff->getLH()) && isUnicodeUnitLength(diff->getRH());
    72     }
    73     else if (const Intersect * e = dyn_cast<Intersect>(re)) {
     58    } else if (const Intersect * e = dyn_cast<Intersect>(re)) {
    7459        return isUnicodeUnitLength(e->getLH()) && isUnicodeUnitLength(e->getRH());
    75     }
    76     else if (isa<Any>(re)) {
     60    } else if (isa<Any>(re)) {
    7761        return true;
    78     }
    79     else if (const Name * n = dyn_cast<Name>(re)) {
     62    } else if (const Name * n = dyn_cast<Name>(re)) {
    8063        // Eventually names might be set up for not unit length items.
    8164        return (n->getType() == Name::Type::Unicode || n->getType() == Name::Type::UnicodeProperty || n->getType() == Name::Type::Byte);
     65    } else if (const GraphemeBoundary * gb = dyn_cast<GraphemeBoundary>(re)) {
     66        return isUnicodeUnitLength(gb->getExpression());
    8267    }
    8368    return false; // otherwise
     
    142127                return std::make_pair(0, std::numeric_limits<int>::max());
    143128        }
     129    } else if (const GraphemeBoundary * gb = dyn_cast<GraphemeBoundary>(re)) {
     130        return std::make_pair(getUnicodeUnitLengthRange(gb->getExpression()).first, std::numeric_limits<int>::max());
    144131    }
    145132    return std::make_pair(1, 1);
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4833 r4835  
    478478    RE * asserted = a->getAsserted();
    479479    if (a->getKind() == Assertion::Kind::Lookbehind) {
    480         MarkerType m = marker;
    481480        MarkerType lookback = compile(asserted, pb);
    482         AlignMarkers(m, lookback, pb);
     481        AlignMarkers(marker, lookback, pb);
    483482        PabloAST * lb = markerVar(lookback);
    484483        if (a->getSense() == Assertion::Sense::Negative) {
    485484            lb = pb.createNot(lb);
    486485        }
    487         return makeMarker(markerPos(m), pb.createAnd(markerVar(marker), lb, "lookback"));
     486        return makeMarker(markerPos(marker), pb.createAnd(markerVar(marker), lb, "lookback"));
    488487    } else if (isUnicodeUnitLength(asserted)) {
    489488        MarkerType lookahead = compile(asserted, pb);
Note: See TracChangeset for help on using the changeset viewer.