void gen_settags(code_lines_t &code, const DFA &dfa, tcid_t tcid, const opt_t *opts);
std::string vartag_name(tagver_t ver, const std::string &prefix);
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)
{
static void emit_rule (OutputFile &o, uint32_t ind, const DFA &dfa, size_t rule_idx);
static void gen_fintags (OutputFile &o, uint32_t ind, const DFA &dfa, const Rule &rule);
static void gen_goto (code_lines_t &code, const State *to, const DFA &dfa, tcid_t tcid, const opt_t *opts, bool skip);
-static std::string tagname (const Tag &tag);
static bool endstate (const State *s);
void emit_action(OutputFile &o, uint32_t ind, const DFA &dfa,
if (opts->target == opt_t::SKELETON) {
emit_action(o, ind, dfa, rule_idx);
- return;
- }
-
- if (!cond.empty() && dfa.cond != cond) {
- strrreplace(s = opts->cond_set, opts->cond_set_arg, opts->condEnumPrefix + cond);
- o.wind(ind).wstring(s);
- if (!opts->cond_set_naked) {
- o.ws("(").wstring(opts->condEnumPrefix).wstring(cond).ws(");");
+ } else {
+ if (!cond.empty() && dfa.cond != cond) {
+ strrreplace(s = opts->cond_set, opts->cond_set_arg, opts->condEnumPrefix + cond);
+ o.wind(ind).wstring(s);
+ if (!opts->cond_set_naked) {
+ o.ws("(").wstring(opts->condEnumPrefix).wstring(cond).ws(");");
+ }
+ o.ws("\n");
}
- o.ws("\n");
- }
-
- if (!code->autogen) {
- if (!dfa.setup.empty()) {
- o.wind(ind).wstring(dfa.setup).ws("\n");
+ if (!code->autogen) {
+ 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")
+ .wdelay_line_info();
+ } else if (!cond.empty()) {
+ strrreplace(s = opts->condGoto, opts->condGotoParam, opts->condPrefix + cond);
+ o.wind(ind).wstring(s).ws("\n");
}
- o.wline_info(code->fline, code->fname.c_str())
- .wind(ind).wstring(code->text).ws("\n")
- .wdelay_line_info();
- } else if (!cond.empty()) {
- strrreplace(s = opts->condGoto, opts->condGotoParam, opts->condPrefix + cond);
- o.wind(ind).wstring(s).ws("\n");
}
if (wrap) o.wind(--ind).ws("}\n");
.ws("(&i, keys, input, token, &cursor, ").wu64(rkey).ws(")");
for (size_t t = r.ltag; t < r.htag; ++t) {
- if (t == r.ttag || fixed(dfa.tags[t])) continue;
- const std::string &tag = *dfa.tags[t].name;
+ const Tag &tag = dfa.tags[t];
+ if (t == r.ttag || fixed(tag)) continue;
+ const std::string tname = tagname(tag);
o.ws("\n").wind(ind + 1).ws(" || check_tag_").wstring(name)
- .ws("(&i, keys, ").wstring(tag).ws(", input, token, \"")
- .wstring(tag).ws("\")");
+ .ws("(&i, keys, ").wstring(tname).ws(", input, token, \"")
+ .wstring(tname).ws("\")");
}
o.ws(";\n");