Ignore:
Timestamp:
Oct 11, 2015, 1:45:52 PM (4 years ago)
Author:
nmedfort
Message:

Back-up check in

File:
1 edited

Legend:

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

    r4684 r4829  
    55#include <re/re_alt.h>
    66#include <re/re_rep.h>
    7 #include <re/re_simplifier.h>
    8 #include <re/printer_re.h>
    9 #include <iostream>
     7#include <re/re_grapheme_boundary.hpp>
     8#include <re/re_name.h>
     9
    1010/*
    1111
     
    2929        }
    3030        re = makeSeq(list.begin(), list.end());
    31     }
    32     else if (Alt * alt = dyn_cast<Alt>(re)) {
     31    } else if (Alt * alt = dyn_cast<Alt>(re)) {
    3332        std::vector<RE*> list;
    3433        for (auto i = alt->begin(); i != alt->end(); ++i) {
     
    3635        }
    3736        re = makeAlt(list.begin(), list.end());
    38     }
    39     else if (Rep * rep = dyn_cast<Rep>(re)) {
     37    } else if (Rep * rep = dyn_cast<Rep>(re)) {
    4038        if ((rep->getLB() == 0) || (isNullable(rep->getRE()))) {
    4139            re = makeSeq();
     
    4745            re = makeRep(rep->getRE(), rep->getLB(), rep->getLB());
    4846        }
     47    } else if (Name * name = dyn_cast<Name>(re)) {
     48        if (name->getDefinition()) {
     49            name->setDefinition(removeNullablePrefix(name->getDefinition()));
     50        }
     51    } else if (GraphemeBoundary * g = dyn_cast<GraphemeBoundary>(re)) {
     52        g->setExpression(removeNullablePrefix(g->getExpression()));
    4953    }
    5054    return re;
     
    6266        }
    6367        re = makeSeq(list.begin(), list.end());
    64     }
    65     else if (Alt* alt = dyn_cast<Alt>(re)) {
     68    } else if (Alt* alt = dyn_cast<Alt>(re)) {
    6669        std::vector<RE*> list;
    6770        for (auto i = alt->begin(); i != alt->end(); ++i) {
     
    6972        }
    7073        re = makeAlt(list.begin(), list.end());
    71     }
    72     else if (Rep * rep = dyn_cast<Rep>(re)) {
     74    } else if (Rep * rep = dyn_cast<Rep>(re)) {
    7375        if ((rep->getLB() == 0) || (isNullable(rep->getRE()))) {
    7476            re = makeSeq();
     
    8082            re = makeRep(rep->getRE(), rep->getLB(), rep->getLB());
    8183        }
     84    } else if (Name * name = dyn_cast<Name>(re)) {
     85        if (name->getDefinition()) {
     86            name->setDefinition(removeNullableSuffix(name->getDefinition()));
     87        }
     88    } else if (GraphemeBoundary * g = dyn_cast<GraphemeBoundary>(re)) {
     89        g->setExpression(removeNullableSuffix(g->getExpression()));
    8290    }
    8391    return re;
     
    92100        }
    93101        return true;
    94     }
    95     else if (const Alt * re_alt = dyn_cast<const Alt>(re)) {
     102    } else if (const Alt * re_alt = dyn_cast<const Alt>(re)) {
    96103        for (const RE * re : *re_alt) {
    97104            if (isNullable(re)) {
     
    99106            }
    100107        }
    101     }
    102     else if (const Rep* re_rep = dyn_cast<const Rep>(re)) {
     108    } else if (const Rep* re_rep = dyn_cast<const Rep>(re)) {
    103109        return re_rep->getLB() == 0 ? true : isNullable(re_rep->getRE());
    104110    }
     
    110116    if (const Seq * seq = dyn_cast<const Seq>(re)) {
    111117        nullable = isNullable(seq->front()) ? true : hasNullablePrefix(seq->front());
    112     }
    113     else if (const Alt * alt = dyn_cast<const Alt>(re)) {
     118    } else if (const Alt * alt = dyn_cast<const Alt>(re)) {
    114119        for (const RE * re : *alt) {
    115120            if (hasNullablePrefix(re)) {
     
    118123            }
    119124        }
    120     }
    121     else if (const Rep * rep = dyn_cast<const Rep>(re)) {
     125    } else if (const Rep * rep = dyn_cast<const Rep>(re)) {
    122126        nullable = true;
    123127        if (rep->getLB() == rep->getUB()) {
     
    132136    if (const Seq * seq = dyn_cast<const Seq>(re)) {
    133137        nullable = isNullable(seq->back()) ? true : hasNullableSuffix(seq->back());
    134     }
    135     else if (const Alt * alt = dyn_cast<const Alt>(re)) {
     138    } else if (const Alt * alt = dyn_cast<const Alt>(re)) {
    136139        for (const RE * re : *alt) {
    137140            if (hasNullableSuffix(re)) {
     
    140143            }
    141144        }
    142     }
    143     else if (const Rep * rep = dyn_cast<const Rep>(re)) {
     145    } else if (const Rep * rep = dyn_cast<const Rep>(re)) {
    144146        nullable = true;
    145147        if (rep->getLB() == rep->getUB()) {
Note: See TracChangeset for help on using the changeset viewer.