Currently only implemented for Castle suffixes.
return max_width;
}
+depth findMinWidth(const CastleProto &proto, u32 top) {
+ if (!contains(proto.repeats, top)) {
+ assert(0); // should not happen
+ return depth::infinity();
+ }
+ return proto.repeats.at(top).bounds.min;
+}
+
+depth findMaxWidth(const CastleProto &proto, u32 top) {
+ if (!contains(proto.repeats, top)) {
+ assert(0); // should not happen
+ return depth(0);
+ }
+ return proto.repeats.at(top).bounds.max;
+}
+
CastleProto::CastleProto(const PureRepeat &pr) {
assert(pr.reach.any());
assert(pr.reports.size() == 1);
std::set<ReportID> all_reports(const CastleProto &proto);
depth findMinWidth(const CastleProto &proto);
depth findMaxWidth(const CastleProto &proto);
+depth findMinWidth(const CastleProto &proto, u32 top);
+depth findMaxWidth(const CastleProto &proto, u32 top);
/**
* \brief Remap tops to be contiguous.
friend depth findMinWidth(const suffix_id &s);
friend depth findMaxWidth(const suffix_id &s);
+ friend depth findMinWidth(const suffix_id &s, u32 top);
+ friend depth findMaxWidth(const suffix_id &s, u32 top);
};
std::set<ReportID> all_reports(const suffix_id &s);
bool has_non_eod_accepts(const suffix_id &s);
depth findMinWidth(const suffix_id &s);
depth findMaxWidth(const suffix_id &s);
+depth findMinWidth(const suffix_id &s, u32 top);
+depth findMaxWidth(const suffix_id &s, u32 top);
size_t hash_value(const suffix_id &s);
/** \brief represents an engine to the left of a rose role */
}
}
+depth findMinWidth(const suffix_id &s, u32 top) {
+ assert(s.graph() || s.castle() || s.haig() || s.dfa());
+ // TODO: take top into account for non-castle suffixes.
+ if (s.graph()) {
+ return findMinWidth(*s.graph());
+ } else if (s.castle()) {
+ return findMinWidth(*s.castle(), top);
+ } else {
+ return s.dfa_min_width;
+ }
+}
+
depth findMaxWidth(const suffix_id &s) {
assert(s.graph() || s.castle() || s.haig() || s.dfa());
if (s.graph()) {
}
}
+depth findMaxWidth(const suffix_id &s, u32 top) {
+ assert(s.graph() || s.castle() || s.haig() || s.dfa());
+ // TODO: take top into account for non-castle suffixes.
+ if (s.graph()) {
+ return findMaxWidth(*s.graph());
+ } else if (s.castle()) {
+ return findMaxWidth(*s.castle(), top);
+ } else {
+ return s.dfa_max_width;
+ }
+}
+
bool has_eod_accepts(const suffix_id &s) {
assert(s.graph() || s.castle() || s.haig() || s.dfa());
if (s.graph()) {
}
if (g[v].suffix) {
- depth suffix_width = findMinWidth(g[v].suffix);
+ depth suffix_width = findMinWidth(g[v].suffix, g[v].suffix.top);
assert(suffix_width.is_reachable());
- DEBUG_PRINTF("%zu has suffix (width %s), can fire report at %u\n",
- g[v].idx, suffix_width.str().c_str(),
+ DEBUG_PRINTF("%zu has suffix with top %u (width %s), can fire "
+ "report at %u\n",
+ g[v].idx, g[v].suffix.top, suffix_width.str().c_str(),
w + suffix_width);
minWidth = min(minWidth, w + suffix_width);
}
if (has_non_eod_accepts(g[v].suffix)) {
return ROSE_BOUND_INF;
}
- depth suffix_width = findMaxWidth(g[v].suffix);
- DEBUG_PRINTF("suffix max width %s\n", suffix_width.str().c_str());
+ depth suffix_width = findMaxWidth(g[v].suffix, g[v].suffix.top);
+ DEBUG_PRINTF("suffix max width for top %u is %s\n", g[v].suffix.top,
+ suffix_width.str().c_str());
assert(suffix_width.is_reachable());
if (!suffix_width.is_finite()) {
DEBUG_PRINTF("suffix too wide\n");