void findBaseState ();
void hoist_tags();
void hoist_tags_and_skip(const opt_t *opts);
- void count_used_labels (std::set<label_t> & used, label_t prolog, label_t start, bool force_start, bool fFlag) const;
+ void count_used_labels(std::set<label_t> &used, label_t start, label_t initial, bool force_start, bool fFlag) const;
void emit_body (OutputFile &, uint32_t &, const std::set<label_t> & used_labels, label_t initial) const;
void emit_dot(OutputFile &o, bool last_cond) const;
return ast;
}
-const AST *ast_iter(const AST *r, uint32_t n, uint32_t m)
+const AST *ast_iter(const AST *a, uint32_t n, uint32_t m)
{
- AST *ast = new AST(r->line, r->column, AST::ITER);
- ast->iter.ast = r;
+ AST *ast = new AST(a->line, a->column, AST::ITER);
+ ast->iter.ast = a;
ast->iter.min = n;
ast->iter.max = m;
return ast;
return ast;
}
-const AST *ast_cap(const AST *r)
+const AST *ast_cap(const AST *a)
{
- AST *ast = new AST(r->line, r->column, AST::CAP);
- ast->cap = r;
+ AST *ast = new AST(a->line, a->column, AST::CAP);
+ ast->cap = a;
return ast;
}
-const AST *ast_ref(const AST *r, const std::string &n)
+const AST *ast_ref(const AST *a, const std::string &n)
{
- AST *ast = new AST(r->line, r->column, AST::REF);
- ast->ref.ast = r;
+ AST *ast = new AST(a->line, a->column, AST::REF);
+ ast->ref.ast = a;
ast->ref.name = new std::string(n);
return ast;
}
-bool ast_need_wrap(const AST *ast)
+bool ast_need_wrap(const AST *a)
{
- switch (ast->type) {
+ switch (a->type) {
case AST::ITER:
case AST::NIL:
case AST::STR:
const AST *ast_cls(uint32_t l, uint32_t c, std::vector<ASTRange> *ranges, bool negated);
const AST *ast_dot(uint32_t l, uint32_t c);
const AST *ast_default(uint32_t l, uint32_t c);
-const AST *ast_alt(const AST *r1, const AST *r2);
-const AST *ast_cat(const AST *r1, const AST *r2);
-const AST *ast_iter(const AST *r, uint32_t n, uint32_t m);
-const AST *ast_diff(const AST *r1, const AST *r2);
+const AST *ast_alt(const AST *a1, const AST *a2);
+const AST *ast_cat(const AST *a1, const AST *a2);
+const AST *ast_iter(const AST *a, uint32_t n, uint32_t m);
+const AST *ast_diff(const AST *a1, const AST *a2);
const AST *ast_tag(uint32_t l, uint32_t c, const std::string *n, bool h);
-const AST *ast_cap(const AST *r);
-const AST *ast_ref(const AST *r, const std::string &n);
-bool ast_need_wrap(const AST *ast);
+const AST *ast_cap(const AST *a);
+const AST *ast_ref(const AST *a, const std::string &n);
+bool ast_need_wrap(const AST *a);
void validate_mode(Scanner::ParseMode mode, bool rflag, bool rules, Scanner &input);
void validate_ast(const specs_t &specs, bool cflag);
FILE * file;
std::string file_name;
- Input (const char * fn);
+ explicit Input (const char * fn);
~Input ();
bool open ();
Input & in;
Warn &warn;
- void fill (uint32_t);
+ void fill(uint32_t need);
void lex_end_of_comment(OutputFile &out);
void lex_tags(OutputFile &out, bool mtags);
void set_sourceline ();
std::string vartag_expr(tagver_t ver, const std::string &prefix, const std::string &expression);
std::string tagname(const Tag &tag);
-inline std::string indent(uint32_t n, const std::string s)
+inline std::string indent(uint32_t n, const std::string &s)
{
std::string ind;
for (; n --> 0; ind += s);
const std::string
&prefix = opts->tags_prefix,
&expression = opts->tags_expression;
- std::string name, expr;
+ std::string expr;
const std::vector<Tag> &tags = dfa.tags;
const tagver_t *fins = dfa.finvers;
Cases(const Span *spans, uint32_t nspans, bool skip);
~Cases();
void emit(OutputFile &o, uint32_t ind, const DFA &dfa) const;
- void used_labels(std::set<label_t> &used);
+ void used_labels(std::set<label_t> &used) const;
FORBID_COPY(Cases);
};
If * els;
Binary (const Span * s, uint32_t n, const State * next, bool skip);
~Binary ();
- void emit (OutputFile &o, uint32_t ind, const DFA &dfa);
- void used_labels (std::set<label_t> & used);
+ void emit (OutputFile &o, uint32_t ind, const DFA &dfa) const;
+ void used_labels (std::set<label_t> & used) const;
FORBID_COPY (Binary);
};
Linear(const Span *s, uint32_t n, const State *next, bool skip);
~Linear();
void add_branch(const Cond *cond, const State *to, tcid_t tags, bool skip);
- void emit(OutputFile &o, uint32_t ind, const DFA &dfa);
- void used_labels(std::set<label_t> &used);
+ void emit(OutputFile &o, uint32_t ind, const DFA &dfa) const;
+ void used_labels(std::set<label_t> &used) const;
FORBID_COPY(Linear);
};
} info;
If (type_t t, const Span * sp, uint32_t nsp, const State * next, bool skip);
~If ();
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa);
- void used_labels (std::set<label_t> & used);
+ void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void used_labels (std::set<label_t> & used) const;
};
struct SwitchIf
} info;
SwitchIf (const Span * sp, uint32_t nsp, const State * next, bool sflag, bool skip);
~SwitchIf ();
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa);
- void used_labels (std::set<label_t> & used);
+ void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void used_labels (std::set<label_t> & used) const;
};
struct GoBitmap
uint32_t hSpans, const bitmap_t * bm, const State * bm_state,
const State * next, bool sflag);
~GoBitmap ();
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa);
- void used_labels (std::set<label_t> & used);
+ void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void used_labels (std::set<label_t> & used) const;
FORBID_COPY (GoBitmap);
};
const State ** table;
CpgotoTable (const Span * span, uint32_t nSpans);
~CpgotoTable ();
- void emit (OutputFile & o, uint32_t ind);
- void used_labels (std::set<label_t> & used);
+ void emit (OutputFile & o, uint32_t ind) const;
+ void used_labels (std::set<label_t> & used) const;
private:
label_t max_label () const;
Cpgoto (const Span * span, uint32_t nSpans, const Span * hspan,
uint32_t hSpans, const State * next, bool sflag);
~Cpgoto ();
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa);
- void used_labels (std::set<label_t> & used);
+ void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void used_labels (std::set<label_t> & used) const;
FORBID_COPY (Cpgoto);
};
{
const State * from;
Cases * cases;
- Dot (const Span * sp, uint32_t nsp, const State * from);
+ Dot(const Span *sp, uint32_t nsp, const State *s);
~Dot ();
- void emit (OutputFile & o, const DFA &dfa);
+ void emit (OutputFile & o, const DFA &dfa) const;
FORBID_COPY (Dot);
};
Go ();
~Go ();
void init(const State* from, const opt_t *opts, bitmaps_t &bitmaps);
- void emit (OutputFile & o, uint32_t ind, const DFA &dfa);
- void used_labels (std::set<label_t> & used);
+ void emit (OutputFile & o, uint32_t ind, const DFA &dfa) const;
+ void used_labels (std::set<label_t> & used) const;
Go (const Go & g)
: nSpans (g.nSpans)
o.wind(ind).ws("}\n");
}
-void Binary::emit(OutputFile &o, uint32_t ind, const DFA &dfa)
+void Binary::emit(OutputFile &o, uint32_t ind, const DFA &dfa) const
{
output_if(o, ind, cond->compare, cond->value);
o.ws("{\n");
o.wind(ind).ws("}\n");
}
-void Linear::emit(OutputFile &o, uint32_t ind, const DFA &dfa)
+void Linear::emit(OutputFile &o, uint32_t ind, const DFA &dfa) const
{
for (uint32_t i = 0; i < nbranches; ++i) {
const Branch &b = branches[i];
}
}
-void If::emit(OutputFile &o, uint32_t ind, const DFA &dfa)
+void If::emit(OutputFile &o, uint32_t ind, const DFA &dfa) const
{
switch (type) {
case BINARY: info.binary->emit(o, ind, dfa); break;
}
}
-void SwitchIf::emit(OutputFile &o, uint32_t ind, const DFA &dfa)
+void SwitchIf::emit(OutputFile &o, uint32_t ind, const DFA &dfa) const
{
switch (type) {
case SWITCH: info.cases->emit(o, ind, dfa); break;
}
}
-void GoBitmap::emit (OutputFile & o, uint32_t ind, const DFA &dfa)
+void GoBitmap::emit (OutputFile & o, uint32_t ind, const DFA &dfa) const
{
const opt_t *opts = o.block().opts;
std::string yych = output_hgo (o, ind, dfa, hgo);
return max;
}
-void CpgotoTable::emit (OutputFile & o, uint32_t ind)
+void CpgotoTable::emit (OutputFile & o, uint32_t ind) const
{
const opt_t *opts = o.block().opts;
o.wind(ind).ws("static void *").wstring(opts->yytarget).ws("[256] = {\n");
o.wind(--ind).ws("};\n");
}
-void Cpgoto::emit (OutputFile & o, uint32_t ind, const DFA &dfa)
+void Cpgoto::emit (OutputFile & o, uint32_t ind, const DFA &dfa) const
{
std::string yych = output_hgo (o, ind, dfa, hgo);
o.ws("{\n");
o.wind(--ind).ws("}\n");
}
-void Dot::emit(OutputFile &o, const DFA &dfa)
+void Dot::emit(OutputFile &o, const DFA &dfa) const
{
const std::string &prefix = o.block().opts->tags_prefix;
const uint32_t n = cases->cases_size;
}
}
-void Go::emit (OutputFile & o, uint32_t ind, const DFA &dfa)
+void Go::emit (OutputFile & o, uint32_t ind, const DFA &dfa) const
{
if (type == DOT) {
info.dot->emit (o, dfa);
namespace re2c
{
-void Cases::used_labels (std::set<label_t> & used)
+void Cases::used_labels (std::set<label_t> & used) const
{
for (uint32_t i = 0; i < cases_size; ++i)
{
}
}
-void Binary::used_labels (std::set<label_t> & used)
+void Binary::used_labels (std::set<label_t> & used) const
{
thn->used_labels (used);
els->used_labels (used);
}
-void Linear::used_labels (std::set<label_t> & used)
+void Linear::used_labels (std::set<label_t> & used) const
{
for (uint32_t i = 0; i < nbranches; ++i) {
const State *to = branches[i].to;
}
}
-void If::used_labels (std::set<label_t> & used)
+void If::used_labels (std::set<label_t> & used) const
{
switch (type)
{
}
}
-void SwitchIf::used_labels (std::set<label_t> & used)
+void SwitchIf::used_labels (std::set<label_t> & used) const
{
switch (type)
{
}
}
-void GoBitmap::used_labels (std::set<label_t> & used)
+void GoBitmap::used_labels (std::set<label_t> & used) const
{
if (hgo != NULL)
{
}
}
-void CpgotoTable::used_labels (std::set<label_t> & used)
+void CpgotoTable::used_labels (std::set<label_t> & used) const
{
for (uint32_t i = 0; i < TABLE_SIZE; ++i)
{
}
}
-void Cpgoto::used_labels (std::set<label_t> & used)
+void Cpgoto::used_labels (std::set<label_t> & used) const
{
if (hgo != NULL)
{
table->used_labels (used);
}
-void Go::used_labels (std::set<label_t> & used)
+void Go::used_labels (std::set<label_t> & used) const
{
switch (type)
{
if (type == STAGS || type == MTAGS) delete tags;
}
-uint32_t OutputFragment::count_lines ()
+uint32_t OutputFragment::count_lines () const
{
uint32_t lines = 0;
const std::string content = stream.str ();
OutputFragment (type_t t, uint32_t i);
~OutputFragment ();
- uint32_t count_lines ();
+ uint32_t count_lines () const;
};
struct OutputBlock
}
}
-void printSpan(std::ostream& o, uint32_t lb, uint32_t ub, uint32_t szcunit, bool ebcdic, bool dot)
+void printSpan(std::ostream& o, uint32_t l, uint32_t u, uint32_t szcunit, bool ebcdic, bool dot)
{
o << "[";
- prtChOrHexForSpan(o, lb, szcunit, ebcdic, dot);
- if (ub - lb > 1) {
+ prtChOrHexForSpan(o, l, szcunit, ebcdic, dot);
+ if (u - l > 1) {
o << "-";
- prtChOrHexForSpan(o, ub - 1, szcunit, ebcdic, dot);
+ prtChOrHexForSpan(o, u - 1, szcunit, ebcdic, dot);
}
o << "]";
}
void unset_encoding(Enc::type_t t) { user.encoding.unset(t); }
void set_encoding_policy(Enc::policy_t p) { user.encoding.setPolicy(p); }
#define MUTOPT1 MUTOPT
-#define MUTOPT(type, name, value) void set_##name (type arg) { user.name = arg; diverge = true; }
+#define MUTOPT(type, name, value) void set_##name (const type &arg) { user.name = arg; diverge = true; }
RE2C_MUTOPTS
#undef MUTOPT1
#undef MUTOPT
}
}
-void Warn::fail (type_t t, uint32_t line, const char * s)
+void Warn::fail (type_t t, uint32_t line, const char * s) const
{
if (mask[t] & WARNING)
{
void set (type_t t, option_t o);
void set_all ();
void set_all_error ();
- void fail (type_t t, uint32_t line, const char * s);
+ void fail (type_t t, uint32_t line, const char * s) const;
void condition_order (uint32_t line);
void empty_class (uint32_t line);
#ifndef _RE2C_DFA_CFG_CFG_
#define _RE2C_DFA_CFG_CFG_
+#include "src/util/forbid_copy.h"
#include "src/dfa/dfa.h"
namespace re2c {
const Rule *rule;
cfg_bb_t(const cfg_ix_t *sb, const cfg_ix_t *se, tcmd_t *&c, const Rule *r);
+ FORBID_COPY(cfg_bb_t);
};
// control flow graph
namespace re2c
{
-static void closure_posix(const closure_t &clos1, closure_t &clos,
- closure_t *shadow, Tagpool &tagpool, const std::vector<Tag> &tags);
-static void closure_leftmost(const closure_t &clos1, closure_t &clos,
- closure_t *shadow, Tagpool &tagpool);
+static void closure_posix(const closure_t &init, closure_t &done, closure_t *shadow, Tagpool &tagpool, const std::vector<Tag> &tags);
+static void closure_leftmost(const closure_t &init, closure_t &done, closure_t *shadow, Tagpool &tagpool);
static int32_t compare_posix(const clos_t &c1, const clos_t &c2, Tagpool &tagpool, const std::vector<Tag> &tags);
static void prune(closure_t &clos, std::valarray<Rule> &rules);
static void lower_lookahead_to_transition(closure_t &clos);
fprintf(stderr, "}\n");
}
-uint32_t dump_dfa_t::index(const nfa_state_t *s)
+uint32_t dump_dfa_t::index(const nfa_state_t *s) const
{
return static_cast<uint32_t>(s - base);
}
void state0(const closure_t &clos);
void state(const closure_t &clos, size_t state, size_t symbol, bool isnew);
void final(size_t state, const nfa_state_t *port);
- uint32_t index(const nfa_state_t *s);
+ uint32_t index(const nfa_state_t *s) const;
FORBID_COPY(dump_dfa_t);
};
tagver_t *actlhs;
public:
- kernels_t(Tagpool &tagpool, tcpool_t &tcpool, const std::vector<Tag> &tags);
+ kernels_t(Tagpool &tagp, tcpool_t &tcp, const std::vector<Tag> &ts);
~kernels_t();
- void init(tagver_t v, size_t k);
+ void init(tagver_t v, size_t nkern);
size_t size() const;
const kernel_t* operator[](size_t idx) const;
result_t insert(const closure_t &clos, tcmd_t *acts, tagver_t maxver);
bool tcmd_t::topsort(tcmd_t **phead, uint32_t *indeg)
{
- tcmd_t
- *x0 = *phead, **px, *x,
- *y0 = NULL, **py, **py1;
+ tcmd_t *x0 = *phead, *x, *y0 = NULL, **py;
bool nontrivial_cycles = false;
// initialize in-degree
// reached end of list
if (!x0) break;
- px = &x0;
- py1 = py;
+ tcmd_t **px = &x0, **py1 = py;
for (x = x0; x; x = x->next) {
if (indeg[x->lhs] == 0) {
--indeg[x->rhs];
static bool equal(const tcmd_t &x, const tcmd_t &y);
static bool equal_history(const tagver_t *h, const tagver_t *g);
static bool topsort(tcmd_t **phead, uint32_t *indeg);
- static bool iscopy(const tcmd_t *cmd);
- static bool isset(const tcmd_t *cmd);
- static bool isadd(const tcmd_t *cmd);
+ static bool iscopy(const tcmd_t *x);
+ static bool isset(const tcmd_t *x);
+ static bool isadd(const tcmd_t *x);
FORBID_COPY(tcmd_t);
};
std::vector<Tag> &tags;
nfa_state_t *root;
- nfa_t(const RESpec &spec);
+ explicit nfa_t(const RESpec &spec);
~nfa_t();
FORBID_COPY(nfa_t);
struct RangeSuffix;
-void UTF8addContinuous(RangeSuffix * & p, utf8::rune l, utf8::rune h, uint32_t n);
-void UTF8splitByContinuity(RangeSuffix * & p, utf8::rune l, utf8::rune h, uint32_t n);
-void UTF8splitByRuneLength(RangeSuffix * & p, utf8::rune l, utf8::rune h);
+void UTF8addContinuous(RangeSuffix * & root, utf8::rune l, utf8::rune h, uint32_t n);
+void UTF8splitByContinuity(RangeSuffix * & root, utf8::rune l, utf8::rune h, uint32_t n);
+void UTF8splitByRuneLength(RangeSuffix * & root, utf8::rune l, utf8::rune h);
} // namespace re2c
path_t prefix;
ucf_size_t size;
- ucf_t(size_t nnodes): loops(nnodes), paths(),
+ explicit ucf_t(size_t nnodes): loops(nnodes), paths(),
prefix(0), size(ucf_size_t::from32(0u)) {}
};
const std::vector<Tag> &tags;
const tagver_t *finvers;
- Skeleton(const dfa_t &dfa, const opt_t *opts, size_t def,
+ Skeleton(const dfa_t &dfa, const opt_t *op, size_t def,
const std::string &dfa_name, const std::string &dfa_cond,
uint32_t dfa_line);
~Skeleton ();
citer_t cur;
public:
- wrap_citer_t(const container_t &c): beg(c.begin()), end(c.end()), cur(beg) {}
+ explicit wrap_citer_t(const container_t &c): beg(c.begin()), end(c.end()), cur(beg) {}
wrap_citer_t& operator++() { if (++cur == end) cur = beg; return *this; }
cpval_t operator->() const { return cur.operator->(); }
};