-/* Generated by re2c 0.16 on Sat Dec 24 11:18:49 2016 */
+/* Generated by re2c 0.16 on Sat Dec 24 11:38:35 2016 */
#line 1 "../src/parse/lex.re"
#include "src/util/c99_stdint.h"
#include <stddef.h>
static void parse_cleanup(re2c::context_t &context)
{
RegExp::flist.clear();
+ Code::flist.clear();
Range::vFreeList.clear();
RangeSuffix::freeList.clear();
context.clear();
l = std::min(l, context.spec_all[0]->code->fline);
}
if (!setups.empty()) {
- l = std::min(l, setups.begin()->second.first);
+ l = std::min(l, setups.begin()->second->fline);
}
if (context.startup) {
l = std::min(l, context.startup->fline);
const std::string c = i->first;
if (c != "*" && specs.find(c) == specs.end()) {
error("line %u: setup for non existing condition '%s' found",
- i->second.first, c.c_str());
+ i->second->fline, c.c_str());
exit(1);
}
}
if (i != setups.end()) {
error("line %u: setup for all conditions '<!*>' is illegal "
"if setup for each condition is defined explicitly",
- i->second.first);
+ i->second->fline);
exit(1);
}
}
std::stable_partition(spec.begin(), spec.end(), RegExpRule::isnt_def);
}
-static void make_rule(context_t &context, RegExpRule *rule, Code *code)
+static void make_rule(context_t &context, RegExpRule *rule, const Code *code)
{
rule->code = code;
context.specMap[""].push_back(rule);
}
static void make_cond(context_t &context, CondList *clist,
- RegExpRule *rule, Code *code)
+ RegExpRule *rule, const Code *code)
{
rule->code = code;
for(CondList::const_iterator i = clist->begin(); i != clist->end(); ++i) {
delete clist;
}
-static void make_star(context_t &context, RegExpRule *rule, Code *code)
+static void make_star(context_t &context, RegExpRule *rule, const Code *code)
{
rule->code = code;
context.spec_all.push_back(rule);
}
-static void make_zero(context_t &context, Code *code)
+static void make_zero(context_t &context, const Code *code)
{
if (context.startup) {
error("line %u: startup code is already defined at line %u",
if (ruleSetupMap.find(*i) != ruleSetupMap.end()) {
in.fatalf_at(code->fline, "code to setup rule '%s' is already defined", i->c_str());
}
- ruleSetupMap[*i] = std::make_pair(code->fline, code->text);
+ ruleSetupMap[*i] = code;
}
- delete code;
delete clist;
}
SetupMap::const_iterator e = map.end(), i;
i = map.find(key);
- if (i != e) return i->second.second;
+ if (i != e) return i->second->text;
i = map.find("*");
- if (i != e) return i->second.second;
+ if (i != e) return i->second->text;
return "";
}
static free_list<RegExpRule*> flist;
const RegExp *re;
- Code *code;
+ const Code *code;
bool def;
RegExpRule(const RegExp *r, bool d)
}
~RegExpRule()
{
- delete code;
flist.erase(this);
}
static bool is_def(const RegExpRule *r) { return r->def; }
namespace re2c
{
+free_list<Code*> Code::flist;
+
const size_t Rule::NONE = std::numeric_limits<size_t>::max();
} // namespace re2c
#include <string>
#include "src/ir/tag.h"
+#include "src/util/free_list.h"
#include "src/util/forbid_copy.h"
namespace re2c
struct Code
{
+ static free_list<Code*> flist;
+
std::string fname;
uint32_t fline;
bool autogen;
, autogen(true)
, text("")
, cond("")
- {}
+ {
+ flist.insert(this);
+ }
Code(const std::string &file, uint32_t line, const char *s, size_t slen)
: fname(file)
, fline(line)
, autogen(false)
, text(s, slen)
, cond("")
- {}
+ {
+ flist.insert(this);
+ }
+ ~Code()
+ {
+ flist.erase(this);
+ }
};
struct Rule
typedef std::set<std::string> CondList;
typedef std::vector<const RegExpRule*> Spec;
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*> SetupMap;
typedef std::map<std::string, const RegExp *> symbol_table_t;
typedef std::map<std::string, smart_ptr<DFA> > dfa_map_t;
SpecMap specMap;
Spec spec_all;
SetupMap ruleSetupMap;
- Code *startup;
+ const Code *startup;
symbol_table_t symbol_table;
context_t()
static void parse_cleanup(re2c::context_t &context)
{
RegExp::flist.clear();
+ Code::flist.clear();
Range::vFreeList.clear();
RangeSuffix::freeList.clear();
context.clear();
l = std::min(l, context.spec_all[0]->code->fline);
}
if (!setups.empty()) {
- l = std::min(l, setups.begin()->second.first);
+ l = std::min(l, setups.begin()->second->fline);
}
if (context.startup) {
l = std::min(l, context.startup->fline);
const std::string c = i->first;
if (c != "*" && specs.find(c) == specs.end()) {
error("line %u: setup for non existing condition '%s' found",
- i->second.first, c.c_str());
+ i->second->fline, c.c_str());
exit(1);
}
}
if (i != setups.end()) {
error("line %u: setup for all conditions '<!*>' is illegal "
"if setup for each condition is defined explicitly",
- i->second.first);
+ i->second->fline);
exit(1);
}
}
std::stable_partition(spec.begin(), spec.end(), RegExpRule::isnt_def);
}
-static void make_rule(context_t &context, RegExpRule *rule, Code *code)
+static void make_rule(context_t &context, RegExpRule *rule, const Code *code)
{
rule->code = code;
context.specMap[""].push_back(rule);
}
static void make_cond(context_t &context, CondList *clist,
- RegExpRule *rule, Code *code)
+ RegExpRule *rule, const Code *code)
{
rule->code = code;
for(CondList::const_iterator i = clist->begin(); i != clist->end(); ++i) {
delete clist;
}
-static void make_star(context_t &context, RegExpRule *rule, Code *code)
+static void make_star(context_t &context, RegExpRule *rule, const Code *code)
{
rule->code = code;
context.spec_all.push_back(rule);
}
-static void make_zero(context_t &context, Code *code)
+static void make_zero(context_t &context, const Code *code)
{
if (context.startup) {
error("line %u: startup code is already defined at line %u",
if (ruleSetupMap.find(*i) != ruleSetupMap.end()) {
in.fatalf_at(code->fline, "code to setup rule '%s' is already defined", i->c_str());
}
- ruleSetupMap[*i] = std::make_pair(code->fline, code->text);
+ ruleSetupMap[*i] = code;
}
- delete code;
delete clist;
}
SetupMap::const_iterator e = map.end(), i;
i = map.find(key);
- if (i != e) return i->second.second;
+ if (i != e) return i->second->text;
i = map.find("*");
- if (i != e) return i->second.second;
+ if (i != e) return i->second->text;
return "";
}