-/* Generated by re2c 0.16 on Mon Feb 22 12:14:07 2016 */
+/* Generated by re2c 0.16 on Mon Feb 22 13:12:30 2016 */
#line 1 "../src/parse/lex.re"
#include "src/util/c99_stdint.h"
#include <stddef.h>
yylval.str = new std::string (tok, tok_len());
return TOKEN_ID;
} else {
- RegExp *r = NULL;
+ const RegExp *r = NULL;
const bool casing = opts->bCaseInsensitive || opts->bCaseInverted;
for (char *s = tok; s < cur; ++s) {
const uint32_t c = static_cast<uint8_t>(*s);
}
}
-RegExp *Scanner::lex_cls(bool neg)
+const RegExp *Scanner::lex_cls(bool neg)
{
Range *r = NULL, *s;
uint32_t u, l;
}
-RegExp *Scanner::lex_str(char quote, bool casing)
+const RegExp *Scanner::lex_str(char quote, bool casing)
{
- RegExp *r = NULL;
+ const RegExp *r = NULL;
for (bool end;;) {
const uint32_t c = lex_str_chr(quote, end);
if (end) {
static std::vector<std::string> condnames;
static re2c::SpecMap specMap;
static Spec spec;
-static RegExp *specNone = NULL;
+static const RegExp *specNone = NULL;
static RuleList specStar;
-static RegExp *star_default = NULL;
+static const RegExp *star_default = NULL;
static Scanner *in = NULL;
static Scanner::ParseMode parseMode;
static SetupMap ruleSetupMap;
void context_rule
( CondList * clist
, const Loc & loc
- , RegExp * expr
- , RegExp * look
+ , const RegExp * expr
+ , const RegExp * look
, const Code * code
, const std::string * newcond
)
condnames.push_back (*it);
}
- RegExp *rule = RegExp::rule
+ const RegExp *rule = RegExp::rule
( loc
, expr
, look
context_check(clist);
for(CondList::const_iterator it = clist->begin(); it != clist->end(); ++it)
{
- RegExp * def = RegExp::rule
+ const RegExp * def = RegExp::rule
( code->loc
, in->mkDefault ()
, RegExp::nil()
{
- re2c::RegExp * regexp;
+ const re2c::RegExp * regexp;
const re2c::Code * code;
char op;
re2c::ExtOp extop;
{
in->fatal("condition or '<*>' required when using -c switch");
}
- RegExp * rule = RegExp::rule
+ const RegExp * rule = RegExp::rule
( (yyvsp[(3) - (3)].code)->loc
, (yyvsp[(1) - (3)].regexp)
, (yyvsp[(2) - (3)].regexp)
{
if (opts->cFlag)
in->fatal("condition or '<*>' required when using -c switch");
- RegExp * def = RegExp::rule
+ const RegExp * def = RegExp::rule
( (yyvsp[(2) - (2)].code)->loc
, in->mkDefault ()
, RegExp::nil()
{
context_check(NULL);
- RegExp * rule = RegExp::rule
+ const RegExp * rule = RegExp::rule
( (yyvsp[(7) - (7)].code)->loc
, (yyvsp[(4) - (7)].regexp)
, (yyvsp[(5) - (7)].regexp)
assert((yyvsp[(7) - (7)].str));
context_check(NULL);
Loc loc (in->get_fname (), in->get_cline ());
- RegExp * rule = RegExp::rule
+ const RegExp * rule = RegExp::rule
( loc
, (yyvsp[(4) - (7)].regexp)
, (yyvsp[(5) - (7)].regexp)
{
for (RuleList::const_iterator itOp = specStar.begin(); itOp != specStar.end(); ++itOp)
{
- RegExp *r = RegExp::rule_copy(*itOp, rank_counter.next());
+ const RegExp *r = RegExp::rule_copy(*itOp, rank_counter.next());
it->second.add (r);
}
if (star_default)
{
- re2c::RegExp * regexp;
+ const re2c::RegExp * regexp;
const re2c::Code * code;
char op;
re2c::ExtOp extop;
{
nfa_state_t *m = n->value.ran.out;
size_t c = 0;
- for (Range *r = n->value.ran.ran; r; r = r->next ())
+ for (const Range *r = n->value.ran.ran; r; r = r->next ())
{
for (; charset[c] != r->lower(); ++c);
for (; charset[c] != r->upper(); ++c)
static uint32_t calc_size(const RegExp *re);
static nfa_state_t *compile(const RegExp *re, nfa_t &nfa, nfa_state_t *n);
-nfa_t::nfa_t(RegExp *re)
+nfa_t::nfa_t(const RegExp *re)
: max_size(calc_size(re))
, size(0)
, states(new nfa_state_t[max_size])
return s;
}
-
} // namespace re2c
struct
{
nfa_state_t *out;
- Range *ran;
+ const Range *ran;
} ran;
struct
{
value.alt.out2 = s2;
mark = false;
}
- void ran(nfa_state_t *s, Range *r)
+ void ran(nfa_state_t *s, const Range *r)
{
type = RAN;
value.ran.out = s;
nfa_state_t *states;
nfa_state_t *root;
- nfa_t(RegExp *re);
+ nfa_t(const RegExp *re);
~nfa_t();
FORBID_COPY(nfa_t);
namespace re2c {
-static RegExp * emit (RangeSuffix * p, RegExp * re);
+static const RegExp * emit (RangeSuffix * p, const RegExp * re);
free_list<RangeSuffix *> RangeSuffix::freeList;
-RegExp * to_regexp (RangeSuffix * p)
+const RegExp * to_regexp (RangeSuffix * p)
{
return p
? emit (p, NULL)
/*
* Build regexp from suffix tree.
*/
-RegExp * emit(RangeSuffix * p, RegExp * re)
+const RegExp * emit(RangeSuffix * p, const RegExp * re)
{
if (p == NULL)
return re;
else
{
- RegExp * regexp = NULL;
+ const RegExp * regexp = NULL;
for (; p != NULL; p = p->next)
{
- RegExp * re1 = doCat(RegExp::sym(Range::ran (p->l, p->h + 1)), re);
+ const RegExp * re1 = doCat(RegExp::sym(Range::ran (p->l, p->h + 1)), re);
regexp = doAlt(regexp, emit(p->child, re1));
}
return regexp;
FORBID_COPY (RangeSuffix);
};
-RegExp * to_regexp (RangeSuffix * p);
+const RegExp * to_regexp (RangeSuffix * p);
} // namespace re2c
namespace re2c {
-RegExp * UTF16Symbol(utf16::rune r)
+const RegExp * UTF16Symbol(utf16::rune r)
{
if (r <= utf16::MAX_1WORD_RUNE)
return RegExp::sym(Range::sym (r));
* them. We store partially built range in suffix tree, which
* allows to eliminate common suffixes while building.
*/
-RegExp * UTF16Range(const Range * r)
+const RegExp * UTF16Range(const Range * r)
{
RangeSuffix * root = NULL;
for (; r != NULL; r = r->next ())
class Range;
class RegExp;
-RegExp * UTF16Symbol(utf16::rune r);
-RegExp * UTF16Range(const Range * r);
+const RegExp * UTF16Symbol(utf16::rune r);
+const RegExp * UTF16Range(const Range * r);
} // namespace re2c
namespace re2c {
-RegExp * UTF8Symbol(utf8::rune r)
+const RegExp * UTF8Symbol(utf8::rune r)
{
uint32_t chars[utf8::MAX_RUNE_LENGTH];
const uint32_t chars_count = utf8::rune_to_bytes(chars, r);
- RegExp * re = RegExp::sym(Range::sym (chars[0]));
+ const RegExp * re = RegExp::sym(Range::sym (chars[0]));
for (uint32_t i = 1; i < chars_count; ++i)
re = RegExp::cat(re, RegExp::sym(Range::sym (chars[i])));
return re;
* them. We store partially built range in suffix tree, which
* allows to eliminate common suffixes while building.
*/
-RegExp * UTF8Range(const Range * r)
+const RegExp * UTF8Range(const Range * r)
{
RangeSuffix * root = NULL;
for (; r != NULL; r = r->next ())
class Range;
class RegExp;
-RegExp * UTF8Symbol(utf8::rune r);
-RegExp * UTF8Range(const Range * r);
+const RegExp * UTF8Symbol(utf8::rune r);
+const RegExp * UTF8Range(const Range * r);
} // namespace re2c
free_list<RegExp*> RegExp::flist;
-RegExp *doAlt(RegExp *re1, RegExp *re2)
+const RegExp *doAlt(const RegExp *re1, const RegExp *re2)
{
if (!re1) {
return re2;
return RegExp::alt(re1, re2);
}
-static RegExp *merge(RegExp *sym1, RegExp *sym2)
+static const RegExp *merge(const RegExp *sym1, const RegExp *sym2)
{
if (!sym1) {
return sym2;
sym2->pld.sym.range));
}
-static RegExp *lift_sym(RegExp *&re)
+static const RegExp *lift_sym(const RegExp *&re)
{
if (!re) {
return NULL;
}
if (re->tag == RegExp::SYM) {
- RegExp *sym = re;
+ const RegExp *sym = re;
re = NULL;
return sym;
}
if (re->tag == RegExp::ALT) {
// second alternative cannot be SYM by construction
- RegExp *alt1 = re->pld.alt.re1;
+ const RegExp *alt1 = re->pld.alt.re1;
if (alt1 && alt1->tag == RegExp::SYM) {
re = re->pld.alt.re2;
return alt1;
return NULL;
}
-RegExp *mkAlt(RegExp *re1, RegExp *re2)
+const RegExp *mkAlt(const RegExp *re1, const RegExp *re2)
{
- RegExp *sym1 = lift_sym(re1);
- RegExp *sym2 = lift_sym(re2);
+ const RegExp *sym1 = lift_sym(re1);
+ const RegExp *sym2 = lift_sym(re2);
return doAlt(
merge(sym1, sym2),
doAlt(re1, re2));
}
-RegExp *doCat(RegExp *re1, RegExp *re2)
+const RegExp *doCat(const RegExp *re1, const RegExp *re2)
{
if (!re1) {
return re2;
return RegExp::cat(re1, re2);
}
-RegExp *Scanner::schr(uint32_t c) const
+const RegExp *Scanner::schr(uint32_t c) const
{
if (!opts->encoding.encode(c)) {
fatalf("Bad code point: '0x%X'", c);
}
}
-RegExp *Scanner::ichr(uint32_t c) const
+const RegExp *Scanner::ichr(uint32_t c) const
{
if (is_alpha(c)) {
- RegExp *l = schr(to_lower_unsafe(c));
- RegExp *u = schr(to_upper_unsafe(c));
+ const RegExp *l = schr(to_lower_unsafe(c));
+ const RegExp *u = schr(to_upper_unsafe(c));
return mkAlt(l, u);
} else {
return schr(c);
}
}
-RegExp *Scanner::cls(Range *r) const
+const RegExp *Scanner::cls(const Range *r) const
{
if (!r) {
switch (opts->empty_class_policy) {
}
}
-RegExp *Scanner::mkDiff(RegExp *re1, RegExp *re2) const
+const RegExp *Scanner::mkDiff(const RegExp *re1, const RegExp *re2) const
{
if (re1 && re2
&& re1->tag == RegExp::SYM
return NULL;
}
-RegExp *Scanner::mkDot() const
+const RegExp *Scanner::mkDot() const
{
uint32_t c = '\n';
if (!opts->encoding.encode(c)) {
* Also note that default range doesn't respect encoding policy
* (the way invalid code points are treated).
*/
-RegExp *Scanner::mkDefault() const
+const RegExp *Scanner::mkDefault() const
{
return RegExp::sym(Range::ran(0,
opts->encoding.nCodeUnits()));
*/
// see note [counted repetition expansion]
-RegExp *repeat(RegExp *re, uint32_t n)
+const RegExp *repeat(const RegExp *re, uint32_t n)
{
- RegExp *r = NULL;
+ const RegExp *r = NULL;
for (uint32_t i = 0; i < n; ++i) {
r = doCat(r, re);
}
}
// see note [counted repetition expansion]
-RegExp *repeat_from_to(RegExp *re, uint32_t n, uint32_t m)
+const RegExp *repeat_from_to(const RegExp *re, uint32_t n, uint32_t m)
{
- RegExp *r1 = repeat(re, n);
- RegExp *r2 = NULL;
+ const RegExp *r1 = repeat(re, n);
+ const RegExp *r2 = NULL;
for (uint32_t i = n; i < m; ++i) {
r2 = mkAlt(
RegExp::nil(),
}
// see note [counted repetition expansion]
-RegExp *repeat_from(RegExp *re, uint32_t n)
+const RegExp *repeat_from(const RegExp *re, uint32_t n)
{
return doCat(
repeat(re, n),
RegExp::iter(re));
}
-RegExp* RegExp::rule(const Loc &loc, RegExp *r1, RegExp *r2,
+const RegExp* RegExp::rule(const Loc &loc, const RegExp *r1, const RegExp *r2,
rule_rank_t rank, const Code *code, const std::string *newcond)
{
RegExp *re = new RegExp(RULE);
// shallow-copies regexps, but deep-copies rule info
// used to duplicate <*> rules in conditions
-RegExp* RegExp::rule_copy(const RegExp *rule, rule_rank_t rank)
+const RegExp* RegExp::rule_copy(const RegExp *rule, rule_rank_t rank)
{
RegExp *re = new RegExp(RULE);
re->pld.rule.re = rule->pld.rule.re;
{
struct
{
- Range *range;
+ const Range *range;
} sym;
struct
{
- RegExp *re1;
- RegExp *re2;
+ const RegExp *re1;
+ const RegExp *re2;
} alt;
struct
{
- RegExp *re1;
- RegExp *re2;
+ const RegExp *re1;
+ const RegExp *re2;
} cat;
struct
{
- RegExp *re;
+ const RegExp *re;
} iter;
struct
{
- RegExp *re;
- RegExp *ctx;
+ const RegExp *re;
+ const RegExp *ctx;
RuleInfo *info;
} rule;
};
tag_t tag;
payload_t pld;
- static RegExp *nil()
+ static const RegExp *nil()
{
return new RegExp(NIL);
}
- static RegExp *sym(Range *r)
+ static const RegExp *sym(const Range *r)
{
RegExp *re = new RegExp(SYM);
re->pld.sym.range = r;
return re;
}
- static RegExp *alt(RegExp *r1, RegExp *r2)
+ static const RegExp *alt(const RegExp *r1, const RegExp *r2)
{
RegExp *re = new RegExp(ALT);
re->pld.alt.re1 = r1;
re->pld.alt.re2 = r2;
return re;
}
- static RegExp *cat(RegExp *r1, RegExp *r2)
+ static const RegExp *cat(const RegExp *r1, const RegExp *r2)
{
RegExp *re = new RegExp(CAT);
re->pld.cat.re1 = r1;
re->pld.cat.re2 = r2;
return re;
}
- static RegExp *iter(RegExp *r)
+ static const RegExp *iter(const RegExp *r)
{
RegExp *re = new RegExp(ITER);
re->pld.iter.re = r;
return re;
}
- static RegExp *rule(const Loc &loc, RegExp *r1, RegExp *r2,
+ static const RegExp *rule(const Loc &loc, const RegExp *r1, const RegExp *r2,
rule_rank_t rank, const Code *code, const std::string *newcond);
- static RegExp *rule_copy(const RegExp *rule, rule_rank_t rank);
+ static const RegExp *rule_copy(const RegExp *rule, rule_rank_t rank);
inline ~RegExp()
{
if (tag == RULE) {
void split(const RegExp *re, std::set<uint32_t> &cs);
void nullable_rules(const RegExp *re, std::vector<RuleInfo*> &rs);
-RegExp *mkAlt(RegExp *re1, RegExp *re2);
-RegExp *doAlt(RegExp *re1, RegExp *re2);
-RegExp *doCat(RegExp *re1, RegExp *re2);
-RegExp *repeat(RegExp *re, uint32_t n);
-RegExp *repeat_from_to(RegExp *re, uint32_t n, uint32_t m);
-RegExp *repeat_from(RegExp *re, uint32_t n);
+const RegExp *mkAlt(const RegExp *re1, const RegExp *re2);
+const RegExp *doAlt(const RegExp *re1, const RegExp *re2);
+const RegExp *doCat(const RegExp *re1, const RegExp *re2);
+const RegExp *repeat(const RegExp *re, uint32_t n);
+const RegExp *repeat_from_to(const RegExp *re, uint32_t n, uint32_t m);
+const RegExp *repeat_from(const RegExp *re, uint32_t n);
} // end namespace re2c
case RegExp::NIL:
break;
case RegExp::SYM:
- for (Range *r = re->pld.sym.range; r; r = r->next()) {
+ for (const Range *r = re->pld.sym.range; r; r = r->next()) {
cs.insert(r->lower());
cs.insert(r->upper());
}
yylval.str = new std::string (tok, tok_len());
return TOKEN_ID;
} else {
- RegExp *r = NULL;
+ const RegExp *r = NULL;
const bool casing = opts->bCaseInsensitive || opts->bCaseInverted;
for (char *s = tok; s < cur; ++s) {
const uint32_t c = static_cast<uint8_t>(*s);
}
}
-RegExp *Scanner::lex_cls(bool neg)
+const RegExp *Scanner::lex_cls(bool neg)
{
Range *r = NULL, *s;
uint32_t u, l;
*/
}
-RegExp *Scanner::lex_str(char quote, bool casing)
+const RegExp *Scanner::lex_str(char quote, bool casing)
{
- RegExp *r = NULL;
+ const RegExp *r = NULL;
for (bool end;;) {
const uint32_t c = lex_str_chr(quote, end);
if (end) {
extern void parse_cleanup();
typedef std::set<std::string> CondList;
-typedef std::list<RegExp*> RuleList;
+typedef std::list<const RegExp*> RuleList;
typedef std::map<std::string, Spec> SpecMap;
typedef std::map<std::string, std::pair<uint32_t, std::string> > SetupMap;
typedef std::map<std::string, const Code *> DefaultMap;
-typedef std::map<std::string, RegExp *> symbol_table_t;
+typedef std::map<std::string, const RegExp *> symbol_table_t;
} // namespace re2c
static std::vector<std::string> condnames;
static re2c::SpecMap specMap;
static Spec spec;
-static RegExp *specNone = NULL;
+static const RegExp *specNone = NULL;
static RuleList specStar;
-static RegExp *star_default = NULL;
+static const RegExp *star_default = NULL;
static Scanner *in = NULL;
static Scanner::ParseMode parseMode;
static SetupMap ruleSetupMap;
void context_rule
( CondList * clist
, const Loc & loc
- , RegExp * expr
- , RegExp * look
+ , const RegExp * expr
+ , const RegExp * look
, const Code * code
, const std::string * newcond
)
condnames.push_back (*it);
}
- RegExp *rule = RegExp::rule
+ const RegExp *rule = RegExp::rule
( loc
, expr
, look
context_check(clist);
for(CondList::const_iterator it = clist->begin(); it != clist->end(); ++it)
{
- RegExp * def = RegExp::rule
+ const RegExp * def = RegExp::rule
( code->loc
, in->mkDefault ()
, RegExp::nil()
%start spec
%union {
- re2c::RegExp * regexp;
+ const re2c::RegExp * regexp;
const re2c::Code * code;
char op;
re2c::ExtOp extop;
{
in->fatal("condition or '<*>' required when using -c switch");
}
- RegExp * rule = RegExp::rule
+ const RegExp * rule = RegExp::rule
( $3->loc
, $1
, $2
{
if (opts->cFlag)
in->fatal("condition or '<*>' required when using -c switch");
- RegExp * def = RegExp::rule
+ const RegExp * def = RegExp::rule
( $2->loc
, in->mkDefault ()
, RegExp::nil()
| '<' TOKEN_STAR '>' expr look newcond TOKEN_CODE
{
context_check(NULL);
- RegExp * rule = RegExp::rule
+ const RegExp * rule = RegExp::rule
( $7->loc
, $4
, $5
assert($7);
context_check(NULL);
Loc loc (in->get_fname (), in->get_cline ());
- RegExp * rule = RegExp::rule
+ const RegExp * rule = RegExp::rule
( loc
, $4
, $5
{
for (RuleList::const_iterator itOp = specStar.begin(); itOp != specStar.end(); ++itOp)
{
- RegExp *r = RegExp::rule_copy(*itOp, rank_counter.next());
+ const RegExp *r = RegExp::rule_copy(*itOp, rank_counter.next());
it->second.add (r);
}
if (star_default)
void set_sourceline ();
uint32_t lex_cls_chr();
uint32_t lex_str_chr(char quote, bool &end);
- RegExp *lex_cls(bool neg);
- RegExp *lex_str(char quote, bool casing);
- RegExp *schr(uint32_t c) const;
- RegExp *ichr(uint32_t c) const;
- RegExp *cls(Range *r) const;
+ const RegExp *lex_cls(bool neg);
+ const RegExp *lex_str(char quote, bool casing);
+ const RegExp *schr(uint32_t c) const;
+ const RegExp *ichr(uint32_t c) const;
+ const RegExp *cls(const Range *r) const;
void lex_conf ();
void lex_conf_assign ();
void fatal(const char*) const;
void fatal(ptrdiff_t, const char*) const;
- RegExp * mkDiff (RegExp * e1, RegExp * e2) const;
- RegExp * mkDot () const;
- RegExp * mkDefault () const;
+ const RegExp * mkDiff (const RegExp * e1, const RegExp * e2) const;
+ const RegExp * mkDot () const;
+ const RegExp * mkDefault () const;
FORBID_COPY (Scanner);
};
struct Spec
{
- RegExp * re;
+ const RegExp * re;
rules_t rules;
Spec ()
rules = spec.rules;
return *this;
}
- bool add_def (RegExp * r)
+ bool add_def (const RegExp * r)
{
if (std::find_if(rules.begin(), rules.end(), is_def) != rules.end())
{
return true;
}
}
- void add (RegExp * r)
+ void add (const RegExp * r)
{
rules.push_back(r->pld.rule.info);
re = mkAlt (re, r);