-/* Generated by re2c 0.16 on Fri Dec 23 13:34:59 2016 */
+/* Generated by re2c 0.16 on Fri Dec 23 15:51:34 2016 */
#line 1 "../src/parse/lex.re"
#include "src/util/c99_stdint.h"
#include <stddef.h>
for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
delay_default(it->second);
- dfa_map[it->first] = compile(it->second, o, it->first, opts->encoding.nCodeUnits ());
+ const std::string &setup = find_setup_rule(context.ruleSetupMap, it->first);
+ dfa_map[it->first] = compile(it->second, o, it->first, opts->encoding.nCodeUnits (), setup);
}
}
uint32_t ind = opts->topIndent;
size_t nCount = dfa_map.size();
for (dfa_map_t::const_iterator i = dfa_map.begin(); i != dfa_map.end(); ++i) {
- o.source.block().setup_rule = find_setup_rule(context.ruleSetupMap, i->first);
i->second->emit(o, ind, !--nCount, bPrologBrace);
}
}
}
if (!code->autogen) {
- const std::string setup = o.block().setup_rule;
- if (!setup.empty()) {
- o.wind(ind).wstring(setup).ws("\n");
+ if (!dfa.setup.empty()) {
+ o.wind(ind).wstring(dfa.setup).ws("\n");
}
o.wline_info(code->fline, code->fname.c_str())
.wind(ind).wstring(code->text).ws("\n")
, used_yyaccept (false)
, force_start_label (false)
, user_start_label ()
- , setup_rule ()
, line (0)
, types ()
, tags ()
bool used_yyaccept;
bool force_start_label;
std::string user_start_label;
- std::string setup_rule;
uint32_t line;
std::vector<std::string> types;
std::set<std::string> tags;
, const std::string &n
, const std::string &c
, uint32_t l
+ , const std::string &s
)
: accepts ()
, name (n)
, def_rule (def)
, key_size (key)
, bitmaps (std::min(ubChar, 256u))
+ , setup(s)
{
const size_t nstates = dfa.states.size();
const size_t nchars = dfa.nchars;
const size_t def_rule;
const size_t key_size;
bitmaps_t bitmaps;
+ std::string setup;
DFA ( const dfa_t &dfa
, const std::vector<size_t> &fill
, const std::string &n
, const std::string &c
, uint32_t l
+ , const std::string &s
);
~DFA ();
void reorder();
}
smart_ptr<DFA> compile(const Spec &rules, Output &output,
- const std::string &cond, uint32_t cunits)
+ const std::string &cond, uint32_t cunits, const std::string &setup)
{
const size_t defrule = !rules.empty() && RegExpRule::is_def(*rules.rbegin())
? rules.size() - 1 : Rule::NONE;
fillpoints(dfa, fill);
// ADFA stands for 'DFA with actions'
- DFA *adfa = new DFA(dfa, fill, defrule, skeleton.sizeof_key, cs, name, cond, line);
+ DFA *adfa = new DFA(dfa, fill, defrule, skeleton.sizeof_key,
+ cs, name, cond, line, setup);
// see note [reordering DFA states]
adfa->reorder();
struct Output;
smart_ptr<DFA> compile(const Spec &spec, Output &output,
- const std::string &cond, uint32_t cunits);
+ const std::string &cond, uint32_t cunits, const std::string &setup);
} // namespace re2c
for (it = context.specMap.begin(); it != context.specMap.end(); ++it) {
delay_default(it->second);
- dfa_map[it->first] = compile(it->second, o, it->first, opts->encoding.nCodeUnits ());
+ const std::string &setup = find_setup_rule(context.ruleSetupMap, it->first);
+ dfa_map[it->first] = compile(it->second, o, it->first, opts->encoding.nCodeUnits (), setup);
}
}
uint32_t ind = opts->topIndent;
size_t nCount = dfa_map.size();
for (dfa_map_t::const_iterator i = dfa_map.begin(); i != dfa_map.end(); ++i) {
- o.source.block().setup_rule = find_setup_rule(context.ruleSetupMap, i->first);
i->second->emit(o, ind, !--nCount, bPrologBrace);
}
}