// might go to the same state, but have different tag sets
if (lb1 != lb2
|| b1->ub != b2->ub
- || b1->tags != 0
- || b2->tags != 0)
+ || b1->tags != ZERO_TAGS
+ || b2->tags != ZERO_TAGS)
{
return false;
}
void gen_goto_case(OutputFile &o, uint32_t ind, bool &readCh,
const State *to, const DFA &dfa, size_t tags)
{
- const bool multiline = readCh || (tags != 0);
+ const bool multiline = readCh || (tags != ZERO_TAGS);
if (multiline) {
o.ws("\n");
const State *to, const DFA &dfa, size_t tags)
{
const int32_t linecount = (readCh && to != NULL)
- + (tags != 0)
+ + (tags != ZERO_TAGS)
+ (to != NULL);
if (linecount > 1) {
void gen_settags(OutputFile &o, uint32_t ind, const DFA &dfa, size_t tags)
{
- if (tags != 0) {
+ if (tags != ZERO_TAGS) {
if (dfa.basetag) {
o.wstring(opts->input_api.stmt_dist(ind,
dfa.tagpool[tags], dfa.tags));
#include <vector>
#include "src/codegen/output.h"
+#include "src/ir/tagpool.h"
#include "src/util/c99_stdint.h"
#include "src/util/forbid_copy.h"
size_t tags;
void emit(OutputFile &o, uint32_t ind) const;
- inline Case(): ranges(), to(NULL), tags(0) {}
+ inline Case(): ranges(), to(NULL), tags(ZERO_TAGS) {}
FORBID_COPY(Case);
};
const State *to;
size_t tags;
- Branch(): cond(NULL), to(NULL), tags(0) {}
+ Branch(): cond(NULL), to(NULL), tags(ZERO_TAGS) {}
void init(const Cond *c, const State *s, size_t ts)
{
cond = c;
Go::Go ()
: nSpans (0)
, span (NULL)
- , tags (0)
+ , tags (ZERO_TAGS)
, type (EMPTY)
, info ()
{}
bool low_spans_have_tags = false;
for (uint32_t i = 0; i < nSpans - hSpans; ++i) {
- if (span[i].tags != 0) {
+ if (span[i].tags != ZERO_TAGS) {
low_spans_have_tags = true;
break;
}
s->go.span = allocate<Span> (1);
s->go.span[0].ub = ubChar;
s->go.span[0].to = move;
- s->go.span[0].tags = 0;
+ s->go.span[0].tags = ZERO_TAGS;
}
static uint32_t merge(Span *x, State *fg, State *bg)
for (;!(f == fe && b == be);) {
if (f->to == b->to && f->tags == b->tags) {
x->to = bg;
- x->tags = 0;
+ x->tags = ZERO_TAGS;
} else {
x->to = f->to;
x->tags = f->tags;
if (nsp > 0) {
Span *sp = s->go.span;
const size_t tags0 = sp[0].tags;
- bool common_tags = tags0 != 0;
+ bool common_tags = tags0 != ZERO_TAGS;
for (uint32_t i = 1; common_tags && i < nsp; ++i) {
common_tags &= sp[i].tags == tags0;
}
if (common_tags) {
s->go.tags = tags0;
for (uint32_t i = 0; i < nsp; ++i) {
- sp[i].tags = 0;
+ sp[i].tags = ZERO_TAGS;
}
}
}
bool *mask = new bool[ntags];
bool *fin = new bool[nrules];
- clos1.push_back(clos_t(nfa.root, static_cast<size_t>(0)));
+ clos1.push_back(clos_t(nfa.root, ZERO_TAGS));
closure(clos1, clos2, ktags, badtags, ntags);
find_state(clos2, clospool, tagpool);
: arcs(new size_t[nchars])
, tags(new size_t[nchars])
, rule(Rule::NONE)
- , rule_tags(0)
+ , rule_tags(ZERO_TAGS)
, fallback(false)
{}
~dfa_state_t()
static size_t fallback_tags(const dfa_t &dfa)
{
const size_t nstates = dfa.states.size();
- size_t tags = 0;
+ size_t tags = ZERO_TAGS;
for (size_t i = 0; i < nstates; ++i) {
const dfa_state_t *s = dfa.states[i];
if (s->fallback) { // see note [fallback states]
#include <vector>
#include "src/ir/tag.h"
+#include "src/ir/tagpool.h"
#include "src/parse/code.h"
#include "src/parse/loc.h"
#include "src/util/forbid_copy.h"
, ltag(0)
, htag(0)
, trail(Tag::NONE)
- , tags(0)
+ , tags(ZERO_TAGS)
, shadow()
{}
+#include <assert.h>
+
#include "src/ir/tagpool.h"
#include "src/util/hash32.h"
, lookup()
, buff(new bool[ntags]())
{
- // all-no tag set must have number 0
- insert(buff);
+ // all-zero tag configuration must have static number zero
+ assert(ZERO_TAGS == insert(buff));
}
Tagpool::~Tagpool()
{
if (t == o || o == 0) {
return t;
- } else if (t == 0) {
+ } else if (t == ZERO_TAGS) {
return o;
}
{
if (t == a) {
return t;
- } else if (t == 0 || a == 0) {
- return 0;
+ } else if (t == ZERO_TAGS || a == ZERO_TAGS) {
+ return ZERO_TAGS;
}
const bool *tags = operator[](t);
size_t Tagpool::andlinv(size_t t, size_t a)
{
- if (a == 0) {
+ if (a == ZERO_TAGS) {
return t;
- } else if (t == 0 || t == a) {
- return 0;
+ } else if (t == ZERO_TAGS || t == a) {
+ return ZERO_TAGS;
}
const bool *tags = operator[](t);
namespace re2c
{
+static const size_t ZERO_TAGS = 0;
+
struct eqtag_t
{
size_t ntags;